Fix: Light theme not being set by default

This commit is contained in:
Sidharth Vinod
2021-09-18 10:10:53 +05:30
parent 15a90149be
commit 45c5958b56
2 changed files with 10 additions and 5 deletions
+8 -3
View File
@@ -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'
+2 -2
View File
@@ -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 }) => {