diff --git a/src/lib/ui/colors.ts b/src/lib/ui/colors.ts index 3701aa42..13442d71 100644 --- a/src/lib/ui/colors.ts +++ b/src/lib/ui/colors.ts @@ -14,8 +14,11 @@ export enum Color { } import { get, writable } from 'svelte/store' +import { env } from '$env/dynamic/public' + +const configuredTheme = env.PUBLIC_THEME ?? 'system' +export const theme = writable<'system' | 'light' | 'dark'>(configuredTheme) -export const theme = writable<'system' | 'light' | 'dark'>('system') export const toggleTheme = () => { theme.update((theme) => { @@ -40,7 +43,7 @@ export const inDarkTheme = (): boolean => { if (typeof localStorage != 'undefined') { const localTheme: 'system' | 'light' | 'dark' = - (localStorage.getItem('theme') as 'system' | 'light' | 'dark') || 'system' + (localStorage.getItem('theme') as 'system' | 'light' | 'dark') || configuredTheme theme.update((theme) => localTheme)