Completely fixed theme colors

This commit is contained in:
Hazem Krimi
2021-09-05 16:44:33 +01:00
parent d665157e23
commit 9d4327f3c7
12 changed files with 50 additions and 46 deletions
+13 -2
View File
@@ -21,8 +21,19 @@ const reducer = (state: boolean, action: { type: string }) => {
const DarkMode: FC = ({ children }) => {
const [dark, dispatch] = useReducer(reducer, false);
const toggle = () => {
if (dark) window.localStorage.setItem('theme', 'light');
else window.localStorage.setItem('theme', 'dark');
const root = window.document.documentElement;
if (dark) {
window.localStorage.setItem('theme', 'light');
root.style.setProperty('--background', '#F9F9F9');
root.style.setProperty('--secondary-background', 'white');
root.style.setProperty('--text', 'black');
} else {
window.localStorage.setItem('theme', 'dark');
root.style.setProperty('--background', '#262626');
root.style.setProperty('--secondary-background', '#2F2F2F');
root.style.setProperty('--text', 'white');
}
dispatch({ type: 'TOGGLE' });
};