You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			22 lines
		
	
	
		
			931 B
		
	
	
	
		
			TypeScript
		
	
			
		
		
	
	
			22 lines
		
	
	
		
			931 B
		
	
	
	
		
			TypeScript
		
	
import { ThemeStateType } from '../themes/constants/colors';
 | 
						|
 | 
						|
export const checkDarkTheme = (theme: ThemeStateType): boolean => theme?.includes('dark');
 | 
						|
export const checkLightTheme = (theme: ThemeStateType): boolean => theme?.includes('light');
 | 
						|
 | 
						|
export function getOppositeTheme(themeName: ThemeStateType): ThemeStateType {
 | 
						|
  if (checkDarkTheme(themeName)) {
 | 
						|
    return themeName.replace('dark', 'light') as ThemeStateType;
 | 
						|
  }
 | 
						|
  if (checkLightTheme(themeName)) {
 | 
						|
    return themeName.replace('light', 'dark') as ThemeStateType;
 | 
						|
  }
 | 
						|
  // If neither 'dark' nor 'light' is in the theme name, return the original theme name.
 | 
						|
  return themeName;
 | 
						|
}
 | 
						|
 | 
						|
export function isThemeMismatched(themeName: ThemeStateType, prefersDark: boolean): boolean {
 | 
						|
  const systemLightTheme = checkLightTheme(themeName);
 | 
						|
  const systemDarkTheme = checkDarkTheme(themeName);
 | 
						|
  return (prefersDark && systemLightTheme) || (!prefersDark && systemDarkTheme);
 | 
						|
}
 |