Skip to content

Commit 8a3e9de

Browse files
committed
feat(4.2): Encpasulate behaviour within component types
1 parent 63bfa5e commit 8a3e9de

3 files changed

Lines changed: 26 additions & 14 deletions

File tree

src/components/Header.astro

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
import { SITE } from '$/config'
33
import SvgIcon from './SvgIcon.astro'
4-
import ModeSwitcher from './ModeSwitcher.svelte'
4+
import ModeSwitcherBtn from './ModeSwitcherBtn.svelte'
55
---
66

77
<header class="header">
@@ -28,19 +28,7 @@
2828
</a>
2929
</li>
3030
<li>
31-
<ModeSwitcher client:visible>
32-
<SvgIcon>
33-
<circle cx="12" cy="12" r="5"></circle>
34-
<line x1="12" y1="1" x2="12" y2="3"></line>
35-
<line x1="12" y1="21" x2="12" y2="23"></line>
36-
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
37-
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
38-
<line x1="1" y1="12" x2="3" y2="12"></line>
39-
<line x1="21" y1="12" x2="23" y2="12"></line>
40-
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
41-
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
42-
</SvgIcon>
43-
</ModeSwitcher>
31+
<ModeSwitcherBtn client:visible />
4432
</li>
4533
</ul>
4634
</nav>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<script lang="ts">
2+
import ModeSwitcher from './ModeSwitcher.svelte'
3+
import SvgIcon from './SvgIcon.svelte'
4+
</script>
5+
<ModeSwitcher let:theme>
6+
<SvgIcon>
7+
{#if theme === 'dark'}
8+
<circle cx="12" cy="12" r="5"></circle>
9+
<line x1="12" y1="1" x2="12" y2="3"></line>
10+
<line x1="12" y1="21" x2="12" y2="23"></line>
11+
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
12+
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
13+
<line x1="1" y1="12" x2="3" y2="12"></line>
14+
<line x1="21" y1="12" x2="23" y2="12"></line>
15+
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
16+
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
17+
{:else}
18+
<path d="M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"></path>
19+
{/if}
20+
</SvgIcon>
21+
</ModeSwitcher>

src/components/SvgIcon.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2+
<slot/>
3+
</svg>

0 commit comments

Comments
 (0)