We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 29b36d6 commit 06085dbCopy full SHA for 06085db
1 file changed
src/components/ThemeProvider.tsx
@@ -59,15 +59,18 @@ const themeDetectorScript = (function () {
59
function themeFn() {
60
try {
61
const storedTheme = localStorage.getItem('theme') || 'auto'
62
+ const validTheme = ['light', 'dark', 'auto'].includes(storedTheme)
63
+ ? storedTheme
64
+ : 'auto'
65
- if (storedTheme === 'auto') {
66
+ if (validTheme === 'auto') {
67
const autoTheme = window.matchMedia('(prefers-color-scheme: dark)')
68
.matches
69
? 'dark'
70
: 'light'
71
document.documentElement.classList.add(autoTheme, 'auto')
72
} else {
- document.documentElement.classList.add(storedTheme)
73
+ document.documentElement.classList.add(validTheme)
74
}
75
} catch (e) {
76
0 commit comments