summaryrefslogtreecommitdiff
path: root/examples/framework-svelte/src/components/Counter.svelte
diff options
context:
space:
mode:
authorGravatar Jacob Jenkins <jacob_jenkins@live.com> 2024-11-14 15:31:51 +0000
committerGravatar GitHub <noreply@github.com> 2024-11-14 23:31:51 +0800
commit9fc2ab8cc848739a21bfa3f754e9bec4926dc034 (patch)
treea184ada6711296569a064c01defd2fa6a74f63c5 /examples/framework-svelte/src/components/Counter.svelte
parentbdc0890061533466da19660ff83a331a3136f6c4 (diff)
downloadastro-9fc2ab8cc848739a21bfa3f754e9bec4926dc034.tar.gz
astro-9fc2ab8cc848739a21bfa3f754e9bec4926dc034.tar.zst
astro-9fc2ab8cc848739a21bfa3f754e9bec4926dc034.zip
Update to svelte 5 (#12364)
Co-authored-by: bluwy <bjornlu.dev@gmail.com>
Diffstat (limited to 'examples/framework-svelte/src/components/Counter.svelte')
-rw-r--r--examples/framework-svelte/src/components/Counter.svelte15
1 files changed, 11 insertions, 4 deletions
diff --git a/examples/framework-svelte/src/components/Counter.svelte b/examples/framework-svelte/src/components/Counter.svelte
index 1353736aa..a11538645 100644
--- a/examples/framework-svelte/src/components/Counter.svelte
+++ b/examples/framework-svelte/src/components/Counter.svelte
@@ -1,5 +1,12 @@
<script lang="ts">
- let count = 0;
+ import type { Snippet } from 'svelte';
+
+ interface Props {
+ children?: Snippet
+ }
+
+ let { children }: Props = $props();
+ let count = $state(0);
function add() {
count += 1;
@@ -11,12 +18,12 @@
</script>
<div class="counter">
- <button on:click={subtract}>-</button>
+ <button onclick={subtract}>-</button>
<pre>{count}</pre>
- <button on:click={add}>+</button>
+ <button onclick={add}>+</button>
</div>
<div class="message">
- <slot />
+ {@render children?.()}
</div>
<style>