@@ -28,12 +28,27 @@ function colorModeToggle() {
2828 }
2929
3030 let darkColors = { } ;
31+
3132 cssVariables . split ( "," ) . forEach ( function ( item ) {
32- let lightValue = computed . getPropertyValue ( `--color--${ item } ` ) ;
33- let darkValue = computed . getPropertyValue ( `--dark--${ item } ` ) ;
33+ // Clean up the variable name - remove "var(" and ")" and trim whitespace
34+ let cleanedItem = item
35+ . trim ( )
36+ . replace ( / ^ v a r \( / , "" )
37+ . replace ( / \) $ / , "" ) ;
38+
39+ // Extract the variable name (e.g., "--polygon-v3---color--primary")
40+ let lightVarName = cleanedItem ;
41+
42+ // Create dark variable name by replacing "--color--" with "--dark--"
43+ // Adjust this based on your actual CSS variable naming convention
44+ let darkVarName = cleanedItem . replace ( "---color--" , "---dark--" ) ;
45+
46+ let lightValue = computed . getPropertyValue ( lightVarName ) ;
47+ let darkValue = computed . getPropertyValue ( darkVarName ) ;
48+
3449 if ( lightValue . length ) {
3550 if ( ! darkValue . length ) darkValue = lightValue ;
36- darkColors [ `--color-- ${ item } ` ] = darkValue ;
51+ darkColors [ lightVarName ] = darkValue ;
3752 }
3853 } ) ;
3954
@@ -62,10 +77,9 @@ function colorModeToggle() {
6277 setColors ( darkColors , false ) ;
6378 }
6479
65- // Force dark mode immediately - ignore user preferences
80+ // Force dark mode immediately
6681 forceDarkMode ( ) ;
6782
68- // Also ensure dark mode is set after DOM is fully loaded
6983 window . addEventListener ( "DOMContentLoaded" , ( event ) => {
7084 forceDarkMode ( ) ;
7185 } ) ;
0 commit comments