File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -1053,12 +1053,17 @@ <h2>Ready to Get Started?</h2>
10531053 const icon = document . getElementById ( 'theme-icon' ) ;
10541054 icon . textContent = newTheme === 'light' ? '🌙' : '☀️' ;
10551055 }
1056+
1057+ function getBrowserThemePreference ( ) {
1058+ const prefersDarkMode = window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ;
1059+ return prefersDarkMode ? 'dark' : 'light' ;
1060+ }
10561061
10571062 // Load saved theme on page load
10581063 ( function ( ) {
1059- const savedTheme = localStorage . getItem ( 'theme' ) || 'light' ;
1064+ const savedTheme = localStorage . getItem ( 'theme' ) || getBrowserThemePreference ( ) ;
10601065 document . documentElement . setAttribute ( 'data-theme' , savedTheme ) ;
1061-
1066+
10621067 // Update icon
10631068 const icon = document . getElementById ( 'theme-icon' ) ;
10641069 icon . textContent = savedTheme === 'light' ? '🌙' : '☀️' ;
You can’t perform that action at this time.
0 commit comments