From 188ee0567cf374cb0bb3deb0bb3dcb78ffccc140 Mon Sep 17 00:00:00 2001 From: Sascha Date: Sat, 6 Mar 2021 17:04:20 +0100 Subject: Ignore system prefered colorscheme mode Currently this introduces to much state problems. --- webui/src/components/Themer.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'webui/src/components/Themer.tsx') diff --git a/webui/src/components/Themer.tsx b/webui/src/components/Themer.tsx index 4adef24a..badd543b 100644 --- a/webui/src/components/Themer.tsx +++ b/webui/src/components/Themer.tsx @@ -1,6 +1,6 @@ import React, { createContext, useContext, useState } from 'react'; -import { ThemeProvider, useMediaQuery } from '@material-ui/core'; +import { ThemeProvider } from '@material-ui/core'; import IconButton from '@material-ui/core/IconButton/IconButton'; import Tooltip from '@material-ui/core/Tooltip/Tooltip'; import { Theme } from '@material-ui/core/styles'; @@ -35,22 +35,20 @@ type Props = { darkTheme: Theme; }; const Themer = ({ children, lightTheme, darkTheme }: Props) => { - const preferseDarkMode = useMediaQuery('(prefers-color-scheme: dark)'); - const browserMode = preferseDarkMode ? 'dark' : 'light'; const savedMode = localStorage.getItem('themeMode'); - const preferedMode = savedMode != null ? savedMode : browserMode; - const [curMode, setMode] = useState(preferedMode); + const preferedMode = savedMode != null ? savedMode : 'light'; + const [mode, setMode] = useState(preferedMode); const toggleMode = () => { - const preferedMode = curMode === 'light' ? 'dark' : 'light'; + const preferedMode = mode === 'light' ? 'dark' : 'light'; localStorage.setItem('themeMode', preferedMode); setMode(preferedMode); }; - const preferedTheme = preferedMode === 'dark' ? darkTheme : lightTheme; + const preferedTheme = mode === 'dark' ? darkTheme : lightTheme; return ( - + {children} ); -- cgit