Skip to content

Commit b12530f

Browse files
committed
feat: loading state for caches
resolves #4 Signed-off-by: Matt Gleich <git@mattglei.ch>
1 parent d81110a commit b12530f

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

src/lib/index/section.svelte

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
}
7878
7979
.section-name {
80-
background-color: #343537;
80+
background-color: var(--section-name-background-color);
8181
border: 1px solid var(--border);
8282
border-top: 0;
8383
border-left: 0;
@@ -172,12 +172,6 @@
172172
display: none;
173173
}
174174
175-
@media (prefers-color-scheme: light) {
176-
.section-name {
177-
background-color: #eaeaea;
178-
}
179-
}
180-
181175
@media (max-width: 450px) {
182176
.children {
183177
padding: 5px;

src/routes/writing/lcp/+page.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<WritingSection title="Cache Status Overview">
2020
<div class="statuses">
2121
{#await data.projects}
22-
<p>Loading projects cache...</p>
22+
<CacheStatus name="Projects" loading />
2323
{:then projects}
2424
<CacheStatus
2525
name="Projects"
@@ -28,7 +28,7 @@
2828
/>
2929
{/await}
3030
{#await data.workouts}
31-
<p>Loading workouts cache...</p>
31+
<CacheStatus name="Workouts" loading />
3232
{:then workouts}
3333
<CacheStatus
3434
name="Workouts"
@@ -37,7 +37,7 @@
3737
/>
3838
{/await}
3939
{#await data.music}
40-
<p>Loading music cache...</p>
40+
<CacheStatus name="Music" loading />
4141
{:then music}
4242
<CacheStatus
4343
name="Music"
@@ -46,7 +46,7 @@
4646
/>
4747
{/await}
4848
{#await data.games}
49-
<p>Loading games cache...</p>
49+
<CacheStatus name="Games" loading />
5050
{:then games}
5151
<CacheStatus
5252
name="Games"

src/routes/writing/lcp/cache-status.svelte

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
66
const {
77
name,
8+
loading = false,
89
updated,
910
updateFrequency
10-
}: { name: string; updated?: Date; updateFrequency: string } = $props();
11+
}: { name: string; loading?: boolean; updated?: Date; updateFrequency?: string } = $props();
1112
</script>
1213

1314
<Card padding="0">
1415
<div class="header">
1516
<p class="cache-name">{name} Cache</p>
16-
{#if updated}
17+
{#if loading}
18+
<p class="loading">LOADING</p>
19+
{:else if updated}
1720
<p class="online">ONLINE</p>
1821
{:else}
1922
<p class="offline">OFFLINE</p>
@@ -26,7 +29,9 @@
2629
<p>{updateFrequency}</p>
2730
</div>
2831
<div class="updated">
29-
{#if updated}
32+
{#if loading}
33+
Loading...
34+
{:else if updated}
3035
Updated <Since time={updated} />
3136
{:else}
3237
Cache is currently offline
@@ -41,7 +46,7 @@
4146
padding-top: 6px;
4247
font-family: 'Inter';
4348
font-weight: 700;
44-
background-color: #343537;
49+
background-color: var(--section-name-background-color);
4550
box-shadow: inset 0px 0px 6px var(--box-shadow-color);
4651
border: 1px solid var(--border);
4752
border-top: 0;
@@ -57,7 +62,8 @@
5762
}
5863
5964
.online,
60-
.offline {
65+
.offline,
66+
.loading {
6167
font-family: 'IBM Plex Mono';
6268
display: flex;
6369
align-items: center;
@@ -69,6 +75,12 @@
6975
border-bottom-left-radius: var(--border-radius);
7076
}
7177
78+
.loading {
79+
color: var(--yellow-foreground);
80+
background-color: var(--yellow-background);
81+
border: 1px solid var(--yellow-border);
82+
}
83+
7284
.online {
7385
color: var(--green-foreground);
7486
background-color: var(--green-background);

0 commit comments

Comments
 (0)