1818
1919 < script >
2020 ( function ( ) {
21- const theme = localStorage . getItem ( 'bibliodrift_theme' ) || 'dark' ;
22- document . documentElement . setAttribute ( 'data-theme' , theme ) ;
21+ const theme = localStorage . getItem ( 'bibliodrift_theme' ) ;
22+ if ( theme === 'night' ) {
23+ document . documentElement . setAttribute ( 'data-theme' , 'night' ) ;
24+ }
2325 } ) ( ) ;
2426 </ script >
2527
@@ -699,7 +701,7 @@ <h3 style="color: var(--text-main) !important;">Ambient Sanctuary</h3>
699701
700702 function updateThemeToggleButton ( currentTheme ) {
701703 const icon = themeToggle . querySelector ( "i" ) ;
702- if ( currentTheme === "night" || currentTheme === "dark" ) {
704+ if ( currentTheme === "night" ) {
703705 icon . className = "fa-solid fa-sun" ;
704706 themeToggle . setAttribute ( "title" , "Switch to Light Mode" ) ;
705707 } else {
@@ -712,9 +714,13 @@ <h3 style="color: var(--text-main) !important;">Ambient Sanctuary</h3>
712714
713715 themeToggle . addEventListener ( "click" , ( ) => {
714716 const activeTheme = document . documentElement . getAttribute ( 'data-theme' ) ;
715- const nextTheme = ( activeTheme === "dark" || activeTheme === " night") ? "light" : "dark " ;
717+ const nextTheme = ( activeTheme === "night" ) ? "light" : "night " ;
716718
717- document . documentElement . setAttribute ( 'data-theme' , nextTheme ) ;
719+ if ( nextTheme === "night" ) {
720+ document . documentElement . setAttribute ( 'data-theme' , 'night' ) ;
721+ } else {
722+ document . documentElement . removeAttribute ( 'data-theme' ) ;
723+ }
718724 localStorage . setItem ( 'bibliodrift_theme' , nextTheme ) ;
719725 if ( typeof restoreTheme === 'function' ) restoreTheme ( ) ;
720726 updateThemeToggleButton ( nextTheme ) ;
0 commit comments