From 75695b1e4f8166455de9fe8319f79a8f7076c06b Mon Sep 17 00:00:00 2001 From: PA4KEV Date: Thu, 17 Aug 2023 21:19:39 +0200 Subject: [PATCH] Pertain theme settings. --- src/ThemeContext.js | 7 ++++++- src/UI/Navigation.js | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ThemeContext.js b/src/ThemeContext.js index e5d1e8d..a354e57 100644 --- a/src/ThemeContext.js +++ b/src/ThemeContext.js @@ -8,8 +8,13 @@ export function ThemeProvider({ children }) { // document.body.className = theme; ); + const updateTheme = newTheme => { + setTheme(newTheme); + localStorage.setItem('theme', newTheme); + }; + return ( - + {children} ); diff --git a/src/UI/Navigation.js b/src/UI/Navigation.js index e1fc101..b13a943 100644 --- a/src/UI/Navigation.js +++ b/src/UI/Navigation.js @@ -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 (