Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/editor/src/app/editMode/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Input } from "@/components/ui/input"
import { Folder, File, Plus, X, ChevronRight, ChevronDown, Trash2 } from "lucide-react"
import { motion, AnimatePresence } from "framer-motion"
import { fetchAllContent } from '@/src/lib/getContents'
import { ThemeToggle } from "@/components/ui/ThemeToggle"

const API_URL = process.env.NEXT_PUBLIC_BACKEND_API_URL || 'http://localhost:3001'

Expand Down Expand Up @@ -408,9 +409,12 @@ export default function ImprovedFileTreeUI() {

return (
<div className="p-6 bg-background min-h-screen text-foreground">
<h1 className="text-3xl font-bold mb-6 text-foreground">
Project Explorer
</h1>
<div className="flex items-center justify-between mb-6">
<h1 className="text-3xl font-bold text-foreground">
Project Explorer
</h1>
<ThemeToggle />
</div>
<div className="bg-card rounded-lg shadow-xl p-6 border">
<motion.div
initial={{ opacity: 0, y: 20 }}
Expand Down
14 changes: 12 additions & 2 deletions packages/editor/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Metadata } from "next";
import localFont from "next/font/local";
import "./globals.css";
import { ThemeProvider } from "next-themes";
import { Toaster } from "sonner";

const geistSans = localFont({
src: "./fonts/GeistVF.woff",
Expand All @@ -24,11 +26,19 @@ export default function RootLayout({
children: React.ReactNode;
}>) {
return (
<html lang="en">
<html lang="en" suppressHydrationWarning>
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
{children}
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
{children}
<Toaster position="bottom-right" />
</ThemeProvider>
</body>
</html>
);
Expand Down
20 changes: 12 additions & 8 deletions packages/editor/src/components/layout/TitleBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ArrowLeft, Save } from 'lucide-react'
import { Button } from "@/components/ui/button"
import Link from "next/link"
import { usePathname } from 'next/navigation'
import { ThemeToggle } from "@/components/ui/ThemeToggle"

interface TitleBarProps {
onSave: () => void
Expand Down Expand Up @@ -34,14 +35,17 @@ export function TitleBar({ onSave, isSaving = false }: TitleBarProps) {
<h1 className="text-lg font-medium">{filename}</h1>
</div>

<Button
onClick={onSave}
disabled={isSaving}
className="flex items-center space-x-2"
>
<Save className="w-4 h-4" />
<span>{isSaving ? 'Saving...' : 'Save'}</span>
</Button>
<div className="flex items-center space-x-4">
<Button
onClick={onSave}
disabled={isSaving}
className="flex items-center gap-2"
>
<Save className="w-4 h-4" />
{isSaving ? 'Saving...' : 'Save'}
</Button>
<ThemeToggle />
</div>
</div>
)
}
35 changes: 35 additions & 0 deletions packages/editor/src/components/ui/ThemeToggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use client'

import { Moon, Sun } from "lucide-react"
import { useTheme } from "next-themes"
import { Button } from "./button"
import { useEffect, useState } from "react"

export function ThemeToggle() {
const [mounted, setMounted] = useState(false)
const { theme, setTheme } = useTheme()

useEffect(() => {
setMounted(true)
}, [])

if (!mounted) {
return null
}

return (
<Button
variant="ghost"
size="icon"
onClick={() => setTheme(theme === "light" ? "dark" : "light")}
className="rounded-full hover:bg-muted"
>
{theme === "light" ? (
<Moon className="h-5 w-5" />
) : (
<Sun className="h-5 w-5" />
)}
<span className="sr-only">Toggle theme</span>
</Button>
)
}
Loading