diff --git a/frontend/components/Header.js b/frontend/components/Header.js index 6c0a992..9008bbb 100644 --- a/frontend/components/Header.js +++ b/frontend/components/Header.js @@ -73,7 +73,11 @@ function Header({ darkMode, setDarkMode }) { } const handleToggleDarkMode = () => { - setDarkMode(prevMode => !prevMode) + setDarkMode(prevMode => { + const newMode = !prevMode + localStorage.setItem('darkMode', newMode ? '1' : '0') + return newMode + }) } return ( diff --git a/frontend/pages/_app.js b/frontend/pages/_app.js index 279e032..58bfd92 100644 --- a/frontend/pages/_app.js +++ b/frontend/pages/_app.js @@ -22,6 +22,11 @@ export default function MyApp(props) { if (jssStyles) { jssStyles.parentElement.removeChild(jssStyles) } + + const darkModePreference = localStorage.getItem('darkMode') + if (darkModePreference) { + setDarkMode(darkModePreference === '1') + } }, []) const light = createTheme({