Skip to content

Commit

Permalink
Fix dark mode state
Browse files Browse the repository at this point in the history
  • Loading branch information
RheingoldRiver committed Nov 3, 2023
1 parent 753c254 commit 2774304
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/AppStateProvider/AppStateProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ export default function AppStateProvider({ children }: { children: ReactNode })
pentominoSize: Number(window.localStorage.getItem("size") ?? DEFAULT_APP_PREFERENCES.pentominoSize),
displayColors: displayColors,
numVisibleColors: Number(window.localStorage.getItem("numColors") ?? DEFAULT_APP_PREFERENCES.numVisibleColors),
copyImage: (window.localStorage.getItem("theme") || "light") !== "light",
copyImage: (window.localStorage.getItem("copy") || "false") === "true",
showCdot: (window.localStorage.getItem("cdot") || "false") === "true",
};
});
const [darkMode, setDarkMode] = useState<boolean>(() => {
return (
(window.localStorage.getItem("theme") || "false") === "true" ||
!!window.matchMedia("(prefers-color-scheme: dark)").matches
);
const storedTheme = window.localStorage.getItem("theme");
if (storedTheme !== undefined) {
return storedTheme === "dark";
}
return !!window.matchMedia("(prefers-color-scheme: dark)").matches;
});

function updateAppPreferences(
Expand Down

0 comments on commit 2774304

Please sign in to comment.