diff --git a/apps/dokploy/components/ui/modeToggle.tsx b/apps/dokploy/components/ui/modeToggle.tsx index 65ffdb6d06..95189c0ee9 100644 --- a/apps/dokploy/components/ui/modeToggle.tsx +++ b/apps/dokploy/components/ui/modeToggle.tsx @@ -1,25 +1,61 @@ "use client"; -import { Moon, Sun } from "lucide-react"; +import { Moon, Sun, Laptop } from "lucide-react"; import { useTheme } from "next-themes"; +import { useEffect, useState } from "react"; + import { Button } from "@/components/ui/button"; +type Theme = "light" | "dark" | "system"; + +const THEME_CYCLE: Record = { + light: "dark", + dark: "system", + system: "light", +} as const; + +const getThemeIcon = (theme: Theme) => { + const iconClass = "h-[1.2rem] w-[1.2rem]"; + + switch (theme) { + case "light": + return ; + case "dark": + return ; + case "system": + return ; + } +}; + export function ModeToggle() { const { theme, setTheme } = useTheme(); + const [mounted, setMounted] = useState(false); + + useEffect(() => { + setMounted(true); + }, []); + + if (!mounted) { + return ( + + ); + } - const toggleTheme = () => { - if (theme === "dark") { - setTheme("light"); - } else { - setTheme("dark"); - } - }; + const currentTheme = (theme as Theme | undefined) ?? "system"; + const nextTheme = THEME_CYCLE[currentTheme]; return ( - ); }