fix: commit untracked theme.ts

This commit is contained in:
Kee Jefferys 2023-10-24 13:37:42 +11:00
parent 358e95621d
commit ccd430bf0c
1 changed files with 18 additions and 0 deletions

18
ts/util/theme.ts Normal file
View File

@ -0,0 +1,18 @@
import { ThemeStateType } from '../themes/constants/colors';
export function getOppositeTheme(themeName: string): ThemeStateType {
if (themeName.includes('dark')) {
return themeName.replace('dark', 'light') as ThemeStateType;
}
if (themeName.includes('light')) {
return themeName.replace('light', 'dark') as ThemeStateType;
}
// If neither 'dark' nor 'light' is in the theme name, return the original theme name.
return themeName as ThemeStateType;
}
export function isThemeMismatched(themeName: string, prefersDark: boolean): boolean {
const isLightTheme = themeName.includes('light');
const isDarkTheme = themeName.includes('dark');
return (prefersDark && isLightTheme) || (!prefersDark && isDarkTheme);
}