Improve the theme detection logic
This commit is contained in:
		
							parent
							
								
									6816d4800b
								
							
						
					
					
						commit
						5955f45a30
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -16,8 +16,8 @@
 | 
			
		|||
  const darkSchemeWatch = window.matchMedia('(prefers-color-scheme: dark)');
 | 
			
		||||
 | 
			
		||||
  function detectThemeAndSwitchStyle() {
 | 
			
		||||
    let theme = localStorage.getItem('themeOverride') || 'browser';
 | 
			
		||||
    if (theme === 'browser') {
 | 
			
		||||
    let theme = localStorage.getItem('themeOverride');
 | 
			
		||||
    if (theme !== 'light' && theme !== 'dark') {
 | 
			
		||||
      theme = darkSchemeWatch.matches ? 'dark' : 'light';
 | 
			
		||||
    }
 | 
			
		||||
    console.log(`Switching theme to ${theme}.`)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue