Fix: Light theme not being set by default
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import type { Writable } from 'svelte/store';
|
||||
import { persist, localStorage } from '@macfja/svelte-persistent-store';
|
||||
|
||||
export const themeStore = persist(
|
||||
export interface ThemeConfig {
|
||||
isDark: boolean;
|
||||
theme?: string;
|
||||
}
|
||||
|
||||
export const themeStore: Writable<ThemeConfig> = persist(
|
||||
writable({
|
||||
isDark: false,
|
||||
theme: ''
|
||||
isDark: false
|
||||
}),
|
||||
localStorage(),
|
||||
'themeStore'
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
|
||||
const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
|
||||
if (isDarkMode && $themeStore.theme === '') {
|
||||
setTheme('dark');
|
||||
if ($themeStore.theme === undefined) {
|
||||
setTheme(isDarkMode ? 'dark' : 'light');
|
||||
}
|
||||
|
||||
themeStore.subscribe(({ theme, isDark }) => {
|
||||
|
||||
Reference in New Issue
Block a user