invert theme logic (light theme by default)

This commit is contained in:
Franek 2025-03-29 19:58:47 +01:00
parent 398f9882a6
commit 7f5df0b4b2

View File

@ -32,14 +32,14 @@ const ThemeContext = createContext<Props>({
}); });
const ThemeProvider: React.FC<React.PropsWithChildren> = ({ children }) => { const ThemeProvider: React.FC<React.PropsWithChildren> = ({ children }) => {
const [isLightTheme, setIsLightTheme] = useState(() => localStorage.getItem("theme") === "light"); const [isDarkTheme, setIsDarkTheme] = useState(() => localStorage.getItem("theme") === "dark");
useEffect(() => { useEffect(() => {
localStorage.setItem("theme", isLightTheme ? "light" : "dark"); localStorage.setItem("theme", isDarkTheme ? "dark" : "light");
}, [isLightTheme]); }, [isDarkTheme]);
const theme = isLightTheme ? lightTheme : darkTheme; const theme = isDarkTheme ? darkTheme : lightTheme;
const toggleTheme = () => setIsLightTheme(prev => !prev); const toggleTheme = () => setIsDarkTheme(prev => !prev);
return ( return (
<ThemeContext.Provider value={{ theme, toggleTheme }}> <ThemeContext.Provider value={{ theme, toggleTheme }}>