Improve the theme detection logic
This commit is contained in:
parent
6816d4800b
commit
5955f45a30
1 changed files with 2 additions and 2 deletions
|
@ -16,8 +16,8 @@
|
||||||
const darkSchemeWatch = window.matchMedia('(prefers-color-scheme: dark)');
|
const darkSchemeWatch = window.matchMedia('(prefers-color-scheme: dark)');
|
||||||
|
|
||||||
function detectThemeAndSwitchStyle() {
|
function detectThemeAndSwitchStyle() {
|
||||||
let theme = localStorage.getItem('themeOverride') || 'browser';
|
let theme = localStorage.getItem('themeOverride');
|
||||||
if (theme === 'browser') {
|
if (theme !== 'light' && theme !== 'dark') {
|
||||||
theme = darkSchemeWatch.matches ? 'dark' : 'light';
|
theme = darkSchemeWatch.matches ? 'dark' : 'light';
|
||||||
}
|
}
|
||||||
console.log(`Switching theme to ${theme}.`)
|
console.log(`Switching theme to ${theme}.`)
|
||||||
|
|
Loading…
Reference in a new issue