File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,6 +55,14 @@ const setupPreferredListener = clientOnly(() => {
5555 return ( ) => mediaQuery . removeEventListener ( 'change' , handler )
5656} )
5757
58+ const getNextTheme = clientOnly ( ( current : ThemeMode ) : ThemeMode => {
59+ const themes : ThemeMode [ ] =
60+ getSystemTheme ( ) === 'dark'
61+ ? [ 'auto' , 'light' , 'dark' ]
62+ : [ 'auto' , 'dark' , 'light' ]
63+ return themes [ ( themes . indexOf ( current ) + 1 ) % themes . length ]
64+ } )
65+
5866const themeDetectorScript = ( function ( ) {
5967 function themeFn ( ) {
6068 try {
@@ -111,9 +119,7 @@ export function ThemeProvider({ children }: ThemeProviderProps) {
111119 }
112120
113121 const toggleMode = ( ) => {
114- setTheme (
115- themeMode === 'light' ? 'dark' : themeMode === 'dark' ? 'auto' : 'light'
116- )
122+ setTheme ( getNextTheme ( themeMode ) )
117123 }
118124
119125 return (
You can’t perform that action at this time.
0 commit comments