Pertain theme settings.
This commit is contained in:
parent
a4638d830c
commit
75695b1e4f
@ -8,8 +8,13 @@ export function ThemeProvider({ children }) {
|
|||||||
// document.body.className = theme;
|
// document.body.className = theme;
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const updateTheme = newTheme => {
|
||||||
|
setTheme(newTheme);
|
||||||
|
localStorage.setItem('theme', newTheme);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeContext.Provider value={{ theme, setTheme }}>
|
<ThemeContext.Provider value={{ theme, updateTheme }}>
|
||||||
{children}
|
{children}
|
||||||
</ThemeContext.Provider>
|
</ThemeContext.Provider>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -9,10 +9,10 @@ let section = window.location.pathname.split('/')[2];
|
|||||||
let chapter = window.location.pathname.split('/')[3];
|
let chapter = window.location.pathname.split('/')[3];
|
||||||
|
|
||||||
const Navigation = () => {
|
const Navigation = () => {
|
||||||
const { theme, setTheme } = useTheme();
|
const { theme, updateTheme } = useTheme();
|
||||||
|
|
||||||
const toggleTheme = () => {
|
const toggleTheme = () => {
|
||||||
setTheme((theme === 'light') ? 'dark' : 'light');
|
updateTheme((theme === 'light') ? 'dark' : 'light');
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user