File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -529,19 +529,24 @@ function historyPopStateHandler(e) {
529
529
}
530
530
}
531
531
532
+ function setTheme ( theme ) {
533
+ document . body . dataset . theme = theme
534
+ }
535
+
536
+ function toggleTheme ( ) {
537
+ setTheme ( document . body . dataset . theme === 'dark' ? 'light' : 'dark' )
538
+ // Only save to local storage if manually toggled by the user
539
+ localStorage . setItem ( 'theme' , theme )
540
+ }
541
+
532
542
function restoreSettings ( ) {
533
543
let theme = localStorage . getItem ( 'theme' )
534
- document . body . dataset . theme = theme
535
544
compactSignature = localStorage . getItem ( 'compactSignature' ) === 'true'
536
545
537
546
if ( ! theme )
538
547
theme = window . matchMedia ?. ( '(prefers-color-scheme: dark)' ) ?. matches ? 'dark' : 'light' ;
539
- }
540
548
541
- function toggleTheme ( ) {
542
- const theme = document . body . dataset . theme === 'dark' ? 'light' : 'dark'
543
- document . body . dataset . theme = theme
544
- localStorage . setItem ( 'theme' , theme )
549
+ setTheme ( theme )
545
550
}
546
551
547
552
async function setup ( ) {
You can’t perform that action at this time.
0 commit comments