Skip to content

Commit d586f26

Browse files
committed
Dark mode
1 parent 1f34754 commit d586f26

File tree

5 files changed

+40
-25
lines changed

5 files changed

+40
-25
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.4.0
4+
### Features
5+
* Dark mode.
6+
### Fixes
7+
* Prevent the feed from refreshing when closing Settings.
8+
39
## 0.3.0
410
### Features
511
* Settings.

src/Main.svelte

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<script lang="ts">
22
import appLogo from "./assets/128x128@2x.png"
3-
import { feedDownloadError, fetchingFeed, feedData, refreshInterval, refreshIntervalTimer } from "./store"
3+
import { feedDownloadError, fetchingFeed, feedData } from "./store"
44
import { tooltip } from "./tooltip"
5-
import { refreshFeed, startFeedRefreshInterval } from "./feed"
5+
import { refreshFeed } from "./feed"
66
import { round1, timestampToLocalString } from "./utils"
77
import SettingsButton from "./lib/SettingsButton.svelte"
8-
98
</script>
109

1110
<main class="w-full overflow-hide">
12-
<header class="sticky top-0 z-10 bg-gray-100">
11+
<header class="sticky top-0 z-10 bg-gray-100 dark:bg-gray-900">
1312
<div class="flex items-center justify-between gap-4 px-4 py-2">
1413
<button
1514
on:click={refreshFeed}
@@ -22,31 +21,33 @@
2221
</button>
2322

2423
{#if $fetchingFeed}
25-
<small class="font-xs text-gray-600">fetching data...</small>
24+
<small class="font-xs dark:text-gray-400">fetching data...</small>
2625
{/if}
2726

2827
{#if $feedDownloadError}
2928
<small class="font-xs text-red-600">{$feedDownloadError}</small>
3029
{/if}
3130

32-
<!-- <small class="font-xs text-gray-600" title={timestampToLocalString($lastFetchedAt)}>
31+
<!-- <small class="font-xs dark:text-gray-400" title={timestampToLocalString($lastFetchedAt)}>
3332
{diffForHumans($lastFetchedAt)}
3433
</small> -->
3534

3635
<SettingsButton />
3736
</div>
3837

3938
{#if $feedData && $feedData.type === "FeatureCollection"}
40-
<div class="w-full bg-white p-2 text-sm border-b">
39+
<div class="w-full bg-white dark:bg-gray-800 p-2 text-sm border-b dark:border-gray-600">
4140
{$feedData.metadata.title} - <small class="font-bold text-xs">{$feedData.metadata.count}</small> events
4241
</div>
4342
{/if}
4443
</header>
4544

4645
{#if $feedData && $feedData.type === "FeatureCollection"}
47-
<div class="w-full h-full min-h-screen bg-white">
46+
<div class="w-full h-full min-h-screen bg-white dark:bg-gray-800">
4847
{#each $feedData.features as feature}
49-
<div class="flex items-center justify-between border-b hover:bg-gray-100 p-2">
48+
<div
49+
class="flex items-center justify-between border-b dark:border-gray-600 hover:bg-gray-100 dark:hover:bg-gray-900 p-2"
50+
>
5051
<div class="w-full flex items-center gap-4">
5152
<div class="w-8 text-center">
5253
<span class:font-bold={feature.properties.mag >= 4.5} class:text-red-600={feature.properties.mag >= 7}>
@@ -57,20 +58,20 @@
5758
<p class:font-bold={feature.properties.mag >= 4.5} class:text-red-600={feature.properties.mag >= 7}>
5859
{feature.properties.place}
5960
</p>
60-
<small class="font-xs text-gray-600">{timestampToLocalString(feature.properties.time)}</small>
61+
<small class="font-xs dark:text-gray-400">{timestampToLocalString(feature.properties.time)}</small>
6162
</div>
6263
</div>
6364

6465
<div class="w-24 text-right">
65-
<small class="font-xs text-gray-600" title="Depth">
66+
<small class="font-xs dark:text-gray-400" title="Depth">
6667
{round1(feature.geometry.coordinates[2])} km
6768
</small>
6869
</div>
6970
</div>
7071
{/each}
7172
</div>
7273
{:else}
73-
<p class="mt-36 text-center text-gray-600">💡 click the logo to refresh earthquake data</p>
74+
<p class="mt-36 text-center dark:text-gray-400">💡 click the logo to refresh earthquake data</p>
7475
{/if}
7576
</main>
7677

src/Settings.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</script>
3535

3636
<main class="w-full overflow-hide">
37-
<header class="sticky top-0 z-10 bg-gray-100">
37+
<header class="sticky top-0 z-10 bg-gray-100 dark:bg-gray-900">
3838
<div class="flex items-center justify-between gap-4 px-4 py-2">
3939
<button
4040
on:click={closeSettings}
@@ -49,17 +49,17 @@
4949
</div>
5050
</header>
5151

52-
<section class="w-full h-full bg-white">
52+
<section class="w-full h-full bg-white dark:bg-gray-800">
5353
<!-- Theme -->
54-
<div class="w-full flex items-center gap-4 border-b p-2">
54+
<div class="w-full flex items-center gap-4 border-b dark:border-gray-600 p-2">
5555
<div class="w-1/2">
5656
<h2 class="font-bold text-right">Theme</h2>
5757
</div>
5858
<div class="w-1/2">
5959
<select
6060
bind:value={selectedTheme}
6161
on:change={saveTheme}
62-
class="bg-white appearance-none px-2 py-1 border rounded"
62+
class="bg-white dark:bg-gray-800 appearance-none px-2 py-1 border dark:border-gray-600 rounded"
6363
>
6464
{#each preferences.themes as theme}
6565
<option value={theme.value}>{theme.label}</option>
@@ -69,7 +69,7 @@
6969
</div>
7070

7171
<!-- Feed refresh interval -->
72-
<div class="w-full flex items-center gap-4 border-b p-2">
72+
<div class="w-full flex items-center gap-4 border-b dark:border-gray-600 p-2">
7373
<div class="w-1/2">
7474
<h2 class="font-bold text-right">Feed refresh interval (s)</h2>
7575
</div>
@@ -80,7 +80,7 @@
8080
step="1"
8181
bind:this={refreshIntervalInput}
8282
value={$refreshInterval}
83-
class="w-16 border px-2 py-1 rounded"
83+
class="w-16 bg-white dark:bg-gray-800 border dark:border-gray-600 px-2 py-1 rounded"
8484
/>
8585
<button
8686
on:click={saveRefreshInterval}

src/app.postcss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ body {
1414
min-height: 100vh;
1515
}
1616

17+
html.dark body {
18+
//color: rgba(255, 255, 255, 0.87);
19+
color: theme("colors.gray.300");
20+
background-color: theme("colors.gray.800");
21+
}
22+
1723
@media (prefers-color-scheme: light) {
1824
:root {
1925
/* ... */

tailwind.config.cjs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
const config = {
2-
content: ["./src/**/*.{html,js,svelte,ts}"],
2+
darkMode: "class",
33

4-
theme: {
5-
extend: {},
6-
},
4+
content: ["./src/**/*.{html,js,svelte,ts}"],
75

8-
plugins: [],
9-
};
6+
theme: {
7+
extend: {},
8+
},
109

11-
module.exports = config;
10+
plugins: [],
11+
}
12+
13+
module.exports = config

0 commit comments

Comments
 (0)