Skip to content

Commit b5cb170

Browse files
committed
use ModeWatcher for skeleton 4/5 examples (already in 3) to standardize, simplify, and fixes initial mode issue
1 parent 8d04906 commit b5cb170

9 files changed

Lines changed: 44 additions & 72 deletions

File tree

examples/skeleton-4/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@sveltejs/vite-plugin-svelte": "^7.1.2",
2222
"@tailwindcss/vite": "^4.3.0",
2323
"layerchart": "workspace:*",
24+
"mode-watcher": "^1.1.0",
2425
"prettier": "^3.8.3",
2526
"prettier-plugin-svelte": "^4.1.0",
2627
"prettier-plugin-tailwindcss": "^0.8.0",

examples/skeleton-4/src/app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!doctype html>
2-
<html lang="en" data-theme="cerberus">
2+
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1" />

examples/skeleton-4/src/lib/components/Lightswitch.svelte

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<script lang="ts">
2-
import '../app.css';
3-
import Lightswitch from '$lib/components/Lightswitch.svelte';
2+
import { Switch } from '@skeletonlabs/skeleton-svelte';
3+
import { ModeWatcher, mode, setMode } from 'mode-watcher';
4+
45
import favicon from '$lib/assets/favicon.svg';
6+
import '../app.css';
57
68
let { children } = $props();
79
</script>
@@ -10,9 +12,20 @@
1012
<link rel="icon" href={favicon} />
1113
</svelte:head>
1214

15+
<ModeWatcher defaultTheme="cerberus" />
16+
1317
<main class="p-4">
1418
<div class="pb-4 text-right">
15-
<Lightswitch />
19+
<Switch
20+
checked={mode.current === 'dark'}
21+
onCheckedChange={(e) => setMode(e.checked ? 'dark' : 'light')}
22+
>
23+
<Switch.Control>
24+
<Switch.Thumb />
25+
</Switch.Control>
26+
<Switch.HiddenInput />
27+
</Switch>
1628
</div>
17-
{@render children()}
29+
30+
{@render children?.()}
1831
</main>

examples/skeleton-5/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@sveltejs/vite-plugin-svelte": "^7.1.2",
2222
"@tailwindcss/vite": "^4.3.0",
2323
"layerchart": "workspace:*",
24+
"mode-watcher": "^1.1.0",
2425
"prettier": "^3.8.3",
2526
"prettier-plugin-svelte": "^4.1.0",
2627
"prettier-plugin-tailwindcss": "^0.8.0",

examples/skeleton-5/src/app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!doctype html>
2-
<html lang="en" data-theme="cerberus">
2+
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1" />

examples/skeleton-5/src/lib/components/Lightswitch.svelte

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<script lang="ts">
2-
import '../app.css';
3-
import Lightswitch from '$lib/components/Lightswitch.svelte';
2+
import { Switch } from '@skeletonlabs/skeleton-svelte';
3+
import { ModeWatcher, mode, setMode } from 'mode-watcher';
4+
45
import favicon from '$lib/assets/favicon.svg';
6+
import '../app.css';
57
68
let { children } = $props();
79
</script>
@@ -10,9 +12,20 @@
1012
<link rel="icon" href={favicon} />
1113
</svelte:head>
1214

15+
<ModeWatcher defaultTheme="cerberus" />
16+
1317
<main class="p-4">
1418
<div class="pb-4 text-right">
15-
<Lightswitch />
19+
<Switch
20+
checked={mode.current === 'dark'}
21+
onCheckedChange={(e) => setMode(e.checked ? 'dark' : 'light')}
22+
>
23+
<Switch.Control>
24+
<Switch.Thumb />
25+
</Switch.Control>
26+
<Switch.HiddenInput />
27+
</Switch>
1628
</div>
17-
{@render children()}
29+
30+
{@render children?.()}
1831
</main>

pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)