diff --git a/app/admin/form/[id]/page.tsx b/app/admin/form/[id]/page.tsx index 2149661..6fc54b7 100644 --- a/app/admin/form/[id]/page.tsx +++ b/app/admin/form/[id]/page.tsx @@ -1,5 +1,4 @@ import { db } from "@/db"; -import { forms } from "@/db/schema"; import FormEditorClient from "./client"; import { notFound } from "next/navigation"; diff --git a/components/theme-toggle.tsx b/components/theme-toggle.tsx index 93560c7..718033e 100644 --- a/components/theme-toggle.tsx +++ b/components/theme-toggle.tsx @@ -12,6 +12,20 @@ import { DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" +const THEME_ICONS = { + light: Sun, + dark: Moon, + system: Monitor, +} as const + +type ThemeOption = keyof typeof THEME_ICONS + +const THEME_OPTIONS: { value: ThemeOption; label: string }[] = [ + { value: "light", label: "Light theme" }, + { value: "dark", label: "Dark theme" }, + { value: "system", label: "System" }, +] + export function ThemeToggle() { const { setTheme, theme, resolvedTheme } = useTheme() const [mounted, setMounted] = React.useState(false) @@ -20,36 +34,32 @@ export function ThemeToggle() { setMounted(true) }, []) + // Once mounted, resolve "system" to its actual rendered theme for the icon + const activeIcon = !mounted + ? Sun + : THEME_ICONS[theme === "system" ? (resolvedTheme as ThemeOption) : (theme as ThemeOption)] ?? Sun + + const Icon = activeIcon + return ( - setTheme("light")}> - - Light theme - - setTheme("dark")}> - - Dark theme - - setTheme("system")}> - - System - + {THEME_OPTIONS.map(({ value, label }) => { + const OptionIcon = THEME_ICONS[value] + return ( + setTheme(value)}> + + {label} + + ) + })} ) -} +} \ No newline at end of file