diff options
Diffstat (limited to 'src/utils/helpers/themes.ts')
| -rw-r--r-- | src/utils/helpers/themes.ts | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/utils/helpers/themes.ts b/src/utils/helpers/themes.ts index 8ef3a19..66c0652 100644 --- a/src/utils/helpers/themes.ts +++ b/src/utils/helpers/themes.ts @@ -1,3 +1,6 @@ +import type { Theme } from '../../types'; +import { VALID_THEMES } from '../constants'; + /** * Check if the user prefers dark color scheme. * @@ -16,3 +19,7 @@ export const getThemeFromSystem = () => { if (prefersDarkScheme()) return 'dark'; return 'light'; }; + +export const themeValidator = (value: unknown): value is Theme => + typeof value === 'string' && + (VALID_THEMES as readonly string[]).includes(value); |
