import { useTheme } from "next-themes"; import { Button } from "@radix-ui/themes"; import { Sun, Moon, Monitor } from "lucide-react"; import { useMemo } from "react"; export function ThemeToggle() { const { theme, setTheme } = useTheme(); const nextTheme = useMemo(() => { switch (theme) { case "light": return "dark"; case "dark": return "system"; case "system": return "light"; default: console.error(`Invalid theme: ${theme}`); return "system"; } }, [theme]); const icon = useMemo(() => { if (nextTheme === "system") { return ; } return nextTheme === "dark" ? : ; }, [nextTheme]); return ( ); }