Skip to content

Commit 1c12193

Browse files
committed
widget toggles
1 parent 343b70c commit 1c12193

File tree

7 files changed

+97
-13
lines changed

7 files changed

+97
-13
lines changed

src/App.svelte

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,29 @@
7070
7171
<main>
7272
<div class="container">
73-
<div class="top">
74-
<Clock />
75-
<Stats />
76-
</div>
77-
<div class="widgets">
78-
<Weather />
79-
<Tasks />
80-
</div>
81-
<Links />
73+
{#if settings.showClock || settings.showStats}
74+
<div class="top">
75+
{#if settings.showClock}
76+
<Clock />
77+
{/if}
78+
{#if settings.showStats}
79+
<Stats class={!settings.showClock ? 'expand' : ''} />
80+
{/if}
81+
</div>
82+
{/if}
83+
{#if settings.showWeather || settings.showTasks}
84+
<div class="widgets">
85+
{#if settings.showWeather}
86+
<Weather class={!settings.showTasks ? 'expand' : ''} />
87+
{/if}
88+
{#if settings.showTasks}
89+
<Tasks />
90+
{/if}
91+
</div>
92+
{/if}
93+
{#if settings.showLinks}
94+
<Links />
95+
{/if}
8296
</div>
8397
8498
<button

src/lib/components/Checkbox.svelte

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<script>
2+
let { checked = $bindable(false), children } = $props()
3+
</script>
4+
5+
<label>
6+
<input type="checkbox" bind:checked />
7+
<span class="checkbox-indicator">
8+
{#if checked}
9+
[<span class="checkbox-x">x</span>]
10+
{:else}
11+
[ ]
12+
{/if}
13+
</span>
14+
<span class="checkbox-content">
15+
{@render children?.()}
16+
</span>
17+
</label>
18+
19+
<style>
20+
label {
21+
display: block;
22+
cursor: pointer;
23+
}
24+
25+
label input[type='checkbox'] {
26+
display: none;
27+
}
28+
29+
.checkbox-indicator {
30+
color: var(--txt-3);
31+
}
32+
33+
.checkbox-x {
34+
color: var(--txt-2);
35+
}
36+
37+
label:hover .checkbox-indicator {
38+
color: var(--txt-2);
39+
}
40+
</style>

src/lib/components/Links.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<style>
4040
.panel {
4141
display: flex;
42+
gap: 1.5rem;
4243
}
4344
.link:hover span {
4445
color: var(--txt-2);
@@ -47,6 +48,6 @@
4748
color: var(--txt-3);
4849
}
4950
.column {
50-
width: 100%;
51+
flex-grow: 1;
5152
}
5253
</style>

src/lib/components/Settings.svelte

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
} from '../settings-store.svelte.js'
88
import { themeNames, themes } from '../themes.js'
99
import RadioButton from './RadioButton.svelte'
10+
import Checkbox from './Checkbox.svelte'
1011
import { createTaskBackend } from '../backends/index.js'
1112
import { isChrome } from '../browser-detect.js'
1213
@@ -202,6 +203,18 @@
202203
</div>
203204

204205
<div class="content">
206+
<div class="group">
207+
<div class="setting-label">widgets</div>
208+
<div class="checkbox-group">
209+
<Checkbox bind:checked={settings.showClock}>clock</Checkbox>
210+
<Checkbox bind:checked={settings.showStats}>stats</Checkbox>
211+
<Checkbox bind:checked={settings.showWeather}>
212+
weather
213+
</Checkbox>
214+
<Checkbox bind:checked={settings.showTasks}>tasks</Checkbox>
215+
<Checkbox bind:checked={settings.showLinks}>links</Checkbox>
216+
</div>
217+
</div>
205218
<div class="group">
206219
<div class="setting-label">theme</div>
207220
<div class="theme-grid">
@@ -671,7 +684,8 @@
671684
font-size: 0.9rem;
672685
flex: 1;
673686
}
674-
.radio-group {
687+
.radio-group,
688+
.checkbox-group {
675689
display: flex;
676690
gap: 3ch;
677691
}

src/lib/components/Stats.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script>
22
import { onMount, onDestroy } from 'svelte'
33
4+
let { class: className = '' } = $props()
5+
46
let loadTime = $state(0)
57
let latency = $state(null)
68
let viewportWidth = $state(0)
@@ -91,7 +93,7 @@
9193
})
9294
</script>
9395

94-
<div class="panel-wrapper">
96+
<div class="panel-wrapper {className}">
9597
<div class="panel-label">stats</div>
9698
<div class="panel">
9799
<div>load <span class="bright">{loadTime} ms</span></div>
@@ -105,4 +107,7 @@
105107
</div>
106108

107109
<style>
110+
.panel-wrapper.expand {
111+
flex-grow: 1;
112+
}
108113
</style>

src/lib/components/Weather.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import WeatherAPI from '../weather-api.js'
44
import { settings } from '../settings-store.svelte.js'
55
6+
let { class: className = '' } = $props()
7+
68
let current = $state(null)
79
let forecast = $state([])
810
let loading = $state(false)
@@ -135,7 +137,7 @@
135137
})
136138
</script>
137139

138-
<div class="panel-wrapper">
140+
<div class="panel-wrapper {className}">
139141
<button class="widget-label" onclick={refreshWeather} disabled={loading}>
140142
{loading ? 'loading...' : 'weather'}
141143
</button>
@@ -203,6 +205,9 @@
203205
.panel-wrapper {
204206
flex-shrink: 0;
205207
}
208+
.panel-wrapper.expand {
209+
flex-grow: 1;
210+
}
206211
.temp {
207212
font-size: 2rem;
208213
font-weight: 300;

src/lib/settings-store.svelte.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ let defaultSettings = {
3333
{ title: 'feedly', url: 'https://feedly.com' },
3434
],
3535
customCSS: '',
36+
showClock: true,
37+
showStats: true,
38+
showWeather: true,
39+
showTasks: true,
40+
showLinks: true,
3641
}
3742

3843
function loadSettings() {

0 commit comments

Comments
 (0)