Improve the theme detection logic

This commit is contained in:
Sumner Evans 2020-04-08 00:42:06 -06:00
parent 6816d4800b
commit 5955f45a30
No known key found for this signature in database
GPG key ID: 8904527AB50022FD

View file

@ -16,8 +16,8 @@
const darkSchemeWatch = window.matchMedia('(prefers-color-scheme: dark)');
function detectThemeAndSwitchStyle() {
let theme = localStorage.getItem('themeOverride') || 'browser';
if (theme === 'browser') {
let theme = localStorage.getItem('themeOverride');
if (theme !== 'light' && theme !== 'dark') {
theme = darkSchemeWatch.matches ? 'dark' : 'light';
}
console.log(`Switching theme to ${theme}.`)