Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Svelte 5 examples #202

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/2-templating/4-event-click/svelte5/Counter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
</script>

<p>Counter: {count}</p>
<button on:click={incrementCount}>+1</button>
<button onclick={incrementCount}>+1</button>
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
<script>
import { createEventDispatcher } from "svelte";

const dispatch = createEventDispatcher();

function clickYes() {
dispatch("yes");
}

function clickNo() {
dispatch("no");
}
let { onYes, onNo } = $props()
</script>

<button on:click={clickYes}> YES </button>
<button onclick={onYes}> YES </button>

<button on:click={clickNo}> NO </button>
<button onclick={onNo}> NO </button>
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
</script>

<p>Are you happy?</p>
<AnswerButton on:yes={onAnswerYes} on:no={onAnswerNo} />
<AnswerButton onYes={onAnswerYes} onNo={onAnswerNo} />
<p style="font-size: 50px;">{isHappy ? "😀" : "😥"}</p>
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<script>
let { children } = $props();
</script>

<button
style="background: rgba(0, 0, 0, 0.4); color: #fff; padding: 10px 20px; font-size: 30px; border: 2px solid #fff; margin: 8px; transform: scale(0.9); box-shadow: 4px 4px rgba(0, 0, 0, 0.4); transition: transform 0.2s cubic-bezier(0.34, 1.65, 0.88, 0.925) 0s; outline: 0;"
>
<slot />
{@render children()}
</button>
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<script>
let { children } = $props();
</script>

<button
style="background: rgba(0, 0, 0, 0.4); color: #fff; padding: 10px 20px; font-size: 30px; border: 2px solid #fff; margin: 8px; transform: scale(0.9); box-shadow: 4px 4px rgba(0, 0, 0, 0.4); transition: transform 0.2s cubic-bezier(0.34, 1.65, 0.88, 0.925) 0s; outline: 0;"
>
<slot>
{#if children}
{@render children()}
{:else}
<span>No content found</span>
</slot>
{/if}
</button>
3 changes: 2 additions & 1 deletion content/7-webapp-features/1-render-app/svelte5/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { mount } from "svelte"
import App from "./App.svelte";

const app = new App({
const app = mount(App, {
target: document.getElementById("app"),
});

Expand Down
Loading