11// Has to be in the head tag, otherwise a flicker effect will occur.
22
3- // Toggle through light, dark, and system theme settings.
3+ // Toggle between light and dark theme settings.
44let toggleThemeSetting = ( ) => {
55 let themeSetting = determineThemeSetting ( ) ;
6- if ( themeSetting == "system" ) {
7- setThemeSetting ( "light" ) ;
8- } else if ( themeSetting == "light" ) {
6+ if ( themeSetting == "light" ) {
97 setThemeSetting ( "dark" ) ;
108 } else {
11- setThemeSetting ( "system " ) ;
9+ setThemeSetting ( "light " ) ;
1210 }
1311} ;
1412
@@ -251,30 +249,19 @@ let transTheme = () => {
251249 } , 500 ) ;
252250} ;
253251
254- // Determine the expected state of the theme toggle, which can be "dark", "light", or
255- // "system". Default is "system".
252+ // Determine the expected state of the theme toggle, which can be "dark" or "light". Default is "light".
256253let determineThemeSetting = ( ) => {
257254 let themeSetting = localStorage . getItem ( "theme" ) ;
258- if ( themeSetting != "dark" && themeSetting != "light" && themeSetting != "system" ) {
259- themeSetting = "system " ;
255+ if ( themeSetting != "dark" && themeSetting != "light" ) {
256+ themeSetting = "light " ;
260257 }
261258 return themeSetting ;
262259} ;
263260
264- // Determine the computed theme, which can be "dark" or "light". If the theme setting is
265- // "system", the computed theme is determined based on the user's system preference.
261+ // Determine the computed theme, which can be "dark" or "light".
266262let determineComputedTheme = ( ) => {
267263 let themeSetting = determineThemeSetting ( ) ;
268- if ( themeSetting == "system" ) {
269- const userPref = window . matchMedia ;
270- if ( userPref && userPref ( "(prefers-color-scheme: dark)" ) . matches ) {
271- return "dark" ;
272- } else {
273- return "light" ;
274- }
275- } else {
276- return themeSetting ;
277- }
264+ return themeSetting ;
278265} ;
279266
280267let initTheme = ( ) => {
@@ -291,8 +278,5 @@ let initTheme = () => {
291278 } ) ;
292279 } ) ;
293280
294- // Add event listener to the system theme preference change.
295- window . matchMedia ( "(prefers-color-scheme: dark)" ) . addEventListener ( "change" , ( { matches } ) => {
296- applyTheme ( ) ;
297- } ) ;
281+ // System theme preference listener removed - only light/dark modes supported
298282} ;
0 commit comments