File tree Expand file tree Collapse file tree 5 files changed +21
-56
lines changed
Expand file tree Collapse file tree 5 files changed +21
-56
lines changed Original file line number Diff line number Diff line change 1111 const defaultTheme = '__DEFAULT_THEME__'
1212
1313 try {
14- const stored = localStorage . getItem ( 'themeSettings ' )
14+ const stored = localStorage . getItem ( 'settings ' )
1515 let themeName = defaultTheme
1616 if ( stored ) {
1717 const parsed = JSON . parse ( stored )
Original file line number Diff line number Diff line change 11<script >
22 import ' @fontsource-variable/geist-mono'
33 import { settings } from ' ./lib/settings-store.svelte.js'
4+ import { themes } from ' ./lib/themes.js'
45 import Clock from ' ./lib/components/Clock.svelte'
56 import Links from ' ./lib/components/Links.svelte'
67 import Settings from ' ./lib/components/Settings.svelte'
78 import Stats from ' ./lib/components/Stats.svelte'
89 import Todoist from ' ./lib/components/Todoist.svelte'
910 import Weather from ' ./lib/components/Weather.svelte'
11+ import { saveSettings } from ' ./lib/settings-store.svelte.js'
1012
1113 let showSettings = $state (false )
1214
1315 function closeSettings () {
1416 showSettings = false
1517 }
1618
19+ function applyTheme (themeName ) {
20+ const theme = themes[themeName] || themes[' defaultTheme' ]
21+ const root = document .documentElement
22+ for (const [key , value ] of Object .entries (theme .colors )) {
23+ root .style .setProperty (key, value)
24+ }
25+ }
26+
1727 $effect (() => {
1828 const fontName = settings .font ? .trim () || ' Geist Mono Variable'
1929 document .documentElement .style .setProperty (
2030 ' --font-family' ,
2131 ` '${ fontName} ', monospace`
2232 )
2333 })
34+
35+ $effect (() => {
36+ applyTheme (settings .currentTheme )
37+ })
38+
39+ $effect (() => {
40+ saveSettings (settings)
41+ })
2442< / script>
2543
2644< main>
Original file line number Diff line number Diff line change 11<script >
22 import { fade , fly } from ' svelte/transition'
33 import { saveSettings , settings } from ' ../settings-store.svelte.js'
4- import { getTheme , setTheme } from ' ../theme-store.svelte.js'
54 import { themeNames , themes } from ' ../themes.js'
65 import RadioButton from ' ./RadioButton.svelte'
76
109 // @ts-ignore
1110 const version = __APP_VERSION__
1211
13- // Reactive theme binding
14- let currentTheme = $state (getTheme ())
15- $effect (() => {
16- setTheme (currentTheme)
17- })
18-
1912 function addLink () {
2013 settings .links = [... settings .links , { title: ' ' , url: ' ' }]
2114 }
6154 {#each themeNames as themeName }
6255 <div class =" theme-option" >
6356 <RadioButton
64- bind:group ={currentTheme }
57+ bind:group ={settings . currentTheme }
6558 value ={themeName }
6659 >
6760 <div class =" theme-preview" >
Original file line number Diff line number Diff line change 11let defaultSettings = {
22 timeFormat : '12hr' ,
33 font : 'Geist Mono Variable' ,
4+ currentTheme : 'default' ,
45 todoistApiToken : '' ,
56 latitude : null ,
67 longitude : null ,
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments