1
0

Pertain theme settings.

This commit is contained in:
PA4KEV 2023-08-17 21:19:39 +02:00
parent a4638d830c
commit 75695b1e4f
2 changed files with 8 additions and 3 deletions

View File

@ -8,8 +8,13 @@ export function ThemeProvider({ children }) {
// document.body.className = theme;
);
const updateTheme = newTheme => {
setTheme(newTheme);
localStorage.setItem('theme', newTheme);
};
return (
<ThemeContext.Provider value={{ theme, setTheme }}>
<ThemeContext.Provider value={{ theme, updateTheme }}>
{children}
</ThemeContext.Provider>
);

View File

@ -9,10 +9,10 @@ let section = window.location.pathname.split('/')[2];
let chapter = window.location.pathname.split('/')[3];
const Navigation = () => {
const { theme, setTheme } = useTheme();
const { theme, updateTheme } = useTheme();
const toggleTheme = () => {
setTheme((theme === 'light') ? 'dark' : 'light');
updateTheme((theme === 'light') ? 'dark' : 'light');
}
return (