Skip to content

Commit 8ff7633

Browse files
authored
Merge pull request #31 from tomoam/update-up-to-20230319
2023/03/19 迄の更新に追従
2 parents a8c1b6d + 9381178 commit 8ff7633

File tree

45 files changed

+349
-1187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+349
-1187
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ The next steps depend on whether you want to run this locally in filesystem mode
2525
## Creating new tutorials
2626

2727
Tutorials live inside `content`. Each tutorial consists of a `README.md`, which is the text to the left, and `app-a` and `app-b` folders, which represent the initial and solved state. Files that stay the same can be omitted from `app-b`. Files are marked as deleted in `app-b` if they start with `__delete`. Folders that are marked as deleted in `app-b` if they contain a file named `__delete`.
28+
29+
## Bumping tutorial dependencies
30+
31+
Bump the dependency (for example Svelte) in both the root and the `content/common` `package.json`. In the root do `pnpm i` (to update `pnpm-lock.yaml`), in `content/common` do `npm i` (to update `package-lock.json`). After deployment things might be out of date because Vercel caches things, redeploy without cache in that case.

content/tutorial/01-svelte/05-events/05-event-forwarding/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ DOM イベントとは異なり、コンポーネントのイベントは *バ
3030
import Inner from './Inner.svelte';
3131
</script>
3232
33-
<Inner on:message/>
33+
<Inner +++on:message+++/>
3434
```

content/tutorial/03-advanced-svelte/09-special-elements/01-svelte-self/app-a/src/lib/Folder.svelte

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
}
1111
</script>
1212

13-
<span class:expanded on:click={toggle}
14-
>{name}</span
15-
>
13+
<button class:expanded on:click={toggle}>{name}</button>
1614

1715
{#if expanded}
1816
<ul>
@@ -29,13 +27,14 @@
2927
{/if}
3028

3129
<style>
32-
span {
30+
button {
3331
padding: 0 0 0 1.5em;
34-
background: url(/tutorial/icons/folder.svg) 0
35-
0.1em no-repeat;
32+
background: url(/tutorial/icons/folder.svg) 0 0.1em no-repeat;
3633
background-size: 1em 1em;
3734
font-weight: bold;
3835
cursor: pointer;
36+
border: none;
37+
margin: 0;
3938
}
4039
4140
.expanded {

content/tutorial/03-advanced-svelte/09-special-elements/01-svelte-self/app-b/src/lib/File.svelte

Lines changed: 0 additions & 17 deletions
This file was deleted.

content/tutorial/03-advanced-svelte/09-special-elements/01-svelte-self/app-b/src/lib/Folder.svelte

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
}
1111
</script>
1212

13-
<span class:expanded on:click={toggle}
14-
>{name}</span
15-
>
13+
<button class:expanded on:click={toggle}>{name}</button>
1614

1715
{#if expanded}
1816
<ul>
@@ -29,13 +27,14 @@
2927
{/if}
3028

3129
<style>
32-
span {
30+
button {
3331
padding: 0 0 0 1.5em;
34-
background: url(/tutorial/icons/folder.svg) 0
35-
0.1em no-repeat;
32+
background: url(/tutorial/icons/folder.svg) 0 0.1em no-repeat;
3633
background-size: 1em 1em;
3734
font-weight: bold;
3835
cursor: pointer;
36+
border: none;
37+
margin: 0;
3938
}
4039
4140
.expanded {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: <svelte:element>
3+
---
4+
5+
どの種類の DOM 要素をレンダリングするのか事前にわからない場合があります。この場合は `<svelte:element>` が便利です。`if` ブロックを何個も並べる代わりに…
6+
7+
```html
8+
{#if selected === 'h1'}
9+
<h1>I'm a h1 tag</h1>
10+
{:else if selected === 'h3'}
11+
<h3>I'm a h3 tag</h3>
12+
{:else if selected === 'p'}
13+
<p>I'm a p tag</p>
14+
{/if}
15+
```
16+
17+
…動的なコンポーネントを1つ置きます:
18+
19+
```html
20+
<svelte:element this={selected}>I'm a {selected} tag</svelte:element>
21+
```
22+
23+
`this` の値は任意の文字列、または falsy な値です。falsy である場合、要素がレンダリングされません。
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<script>
2+
const options = ['h1', 'h3', 'p'];
3+
let selected = options[0];
4+
</script>
5+
6+
<select bind:value={selected}>
7+
{#each options as option}
8+
<option value={option}>{option}</option>
9+
{/each}
10+
</select>
11+
12+
{#if selected === 'h1'}
13+
<h1>I'm a h1 tag</h1>
14+
{:else if selected === 'h3'}
15+
<h3>I'm a h3 tag</h3>
16+
{:else if selected === 'p'}
17+
<p>I'm a p tag</p>
18+
{/if}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script>
2+
const options = ['h1', 'h3', 'p'];
3+
let selected = options[0];
4+
</script>
5+
6+
<select bind:value={selected}>
7+
{#each options as option}
8+
<option value={option}>{option}</option>
9+
{/each}
10+
</select>
11+
12+
<svelte:element this={selected}>I'm a {selected} tag</svelte:element>

0 commit comments

Comments
 (0)