import { Moon, Sun, Database, Palette } from "lucide-react"; import { useEffect, useState } from "react"; import { Outlet } from "react-router-dom"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; const themes = [ { id: "purple", name: "Purple", color: "hsl(270 80% 60%)" }, { id: "ocean", name: "Ocean", color: "hsl(210 90% 55%)" }, { id: "sunset", name: "Sunset", color: "hsl(25 95% 55%)" }, { id: "forest", name: "Forest", color: "hsl(145 70% 40%)" }, { id: "rose", name: "Rose", color: "hsl(350 80% 60%)" }, { id: "slate", name: "Slate", color: "hsl(220 15% 35%)" }, ] as const; type ThemeId = (typeof themes)[number]["id"]; type Mode = "light" | "dark"; const getInitialTheme = (): ThemeId => { if (typeof window === "undefined") return "purple"; const stored = localStorage.getItem("color-theme"); if (themes.some((t) => t.id === stored)) return stored as ThemeId; return "purple"; }; const getInitialMode = (): Mode => { if (typeof window === "undefined") return "light"; const stored = localStorage.getItem("mode"); if (stored === "light" || stored === "dark") return stored; return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; }; function App() { const [theme, setTheme] = useState(getInitialTheme); const [mode, setMode] = useState(getInitialMode); useEffect(() => { const root = document.documentElement; // Remove existing theme classes themes.forEach((t) => root.classList.remove(`theme-${t.id}`)); // Add current theme class root.classList.add(`theme-${theme}`); root.classList.toggle("dark", mode === "dark"); localStorage.setItem("color-theme", theme); localStorage.setItem("mode", mode); }, [theme, mode]); return (
TaylorDB
{/* Theme Picker */} {themes.map((t) => ( setTheme(t.id)} className="flex items-center gap-3 cursor-pointer" >
{t.name} {theme === t.id && ( )} ))} {/* Dark/Light Mode Toggle */}
); } export default App;