Add config option to set default theme

This commit is contained in:
Deluan
2021-04-18 13:51:00 -04:00
parent b6f525bda5
commit f63a912341
6 changed files with 36 additions and 4 deletions
+8 -1
View File
@@ -2,6 +2,7 @@ import { useSelector } from 'react-redux'
import useMediaQuery from '@material-ui/core/useMediaQuery'
import themes from './index'
import { AUTO_THEME_ID } from '../consts'
import config from '../config'
export default () => {
const prefersLightMode = useMediaQuery('(prefers-color-scheme: light)')
@@ -9,6 +10,12 @@ export default () => {
if (state.theme === AUTO_THEME_ID) {
return prefersLightMode ? themes.LightTheme : themes.DarkTheme
}
return themes[state.theme] || themes.DarkTheme
const themeName =
state.theme ||
Object.keys(themes).find(
(t) => themes[t].themeName === config.defaultTheme
) ||
'DarkTheme'
return themes[themeName]
})
}