Merge branch 'DarkModeEnvVar' into AddEnvVarConfig
This commit is contained in:
commit
0f7282210c
1 file changed
+5
-2
@@ -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)
|
||||
|
||||
|
||||
Reference in new issue
Block a user