mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-09-20 01:47:29 +02:00
Centralize darkThemes list, fix dark themes reverting to light on restart
This commit is contained in:
@@ -5,3 +5,37 @@ const ua = typeof navigator !== 'undefined' ? navigator.userAgent : '';
|
||||
export const isAndroid = /android/i.test(ua);
|
||||
export const isIOS = /iphone|ipad|ipod/i.test(ua);
|
||||
export const isMobile = isAndroid || isIOS;
|
||||
|
||||
// Themes that use the dark color scheme. Used by applyTheme() to toggle the
|
||||
// `dark` class on the root element. Keep this in sync when adding new themes.
|
||||
export const darkThemes = [
|
||||
'dark',
|
||||
'solarized-dark',
|
||||
'catppuccin',
|
||||
'nord',
|
||||
'tokyo-night',
|
||||
'github-dark',
|
||||
'dracula',
|
||||
'blueberry',
|
||||
'forest-green',
|
||||
'gruvbox',
|
||||
'midnight-tide',
|
||||
'cherry-blossom',
|
||||
'synthwave',
|
||||
'ember',
|
||||
'moonlit',
|
||||
'dark-coffee',
|
||||
'crimson',
|
||||
'material-dark',
|
||||
'monokai',
|
||||
'rose-pine',
|
||||
'everforest',
|
||||
'horizon',
|
||||
'cyberpunk',
|
||||
'black',
|
||||
'one-dark',
|
||||
];
|
||||
|
||||
export function isDarkTheme(theme: string): boolean {
|
||||
return darkThemes.includes(theme) || (theme === 'system' && typeof window !== 'undefined' && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user