Explorar o código

fix: limit theme mode value

GyDi %!s(int64=2) %!d(string=hai) anos
pai
achega
c1734a094c
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      src/components/layout/use-custom-theme.ts

+ 6 - 2
src/components/layout/use-custom-theme.ts

@@ -16,8 +16,12 @@ export default function useCustomTheme() {
   const [mode, setMode] = useRecoilState(atomThemeMode);
 
   useEffect(() => {
-    if (theme_mode !== "system") {
-      setMode(theme_mode ?? "light");
+    const themeMode = ["light", "dark", "system"].includes(theme_mode!)
+      ? theme_mode!
+      : "light";
+
+    if (themeMode !== "system") {
+      setMode(themeMode);
       return;
     }