File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,9 +40,7 @@ const reRenderTheme = () => {
4040 const theme : theme_option | null =
4141 JSON . parse ( localStorage . getItem ( 'theme' ) ?? 'null' ) ?? 'auto'
4242
43- const autoDark = window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches
44-
45- if ( theme === 'dark' || ( theme !== 'light' && autoDark ) ) {
43+ if ( theme === 'dark' || ( theme !== 'light' && window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ) ) {
4644 document . documentElement . classList . add ( 'dark' )
4745 } else {
4846 document . documentElement . classList . remove ( 'dark' )
Original file line number Diff line number Diff line change 11// run this in <head> as blocking to prevent flash of unstyled content. See theme-provider.tsx
22{
3- const autoDark = window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches
43 const localTheme = localStorage . getItem ( 'theme' )
54 const theme = localTheme ? JSON . parse ( localTheme ) : 'auto'
65
7- if ( theme === 'dark' || ( theme === 'auto' && autoDark ) ) {
6+ if ( theme === 'dark' || ( theme === 'auto' && window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ) ) {
87 document . documentElement . classList . add ( 'dark' )
98 }
109}
You can’t perform that action at this time.
0 commit comments