Skip to content

Commit 55f1332

Browse files
authored
Update some content (sveltejs#70)
* add some more inline diffs * update more content * update more content * simplify deferred transitions tutorial * make filenames clickable in sidebar * replace key block tutorial * tweak styles * update animate example
1 parent 4fb0cec commit 55f1332

File tree

47 files changed

+810
-1006
lines changed

Some content is hidden

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

47 files changed

+810
-1006
lines changed

content/tutorial/01-svelte/02-reactivity/01-reactive-assignments/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Assignments
44

55
At the heart of Svelte is a powerful system of _reactivity_ for keeping the DOM in sync with your application state — for example, in response to an event.
66

7-
To demonstrate it, we first need to wire up an event handler (we'll learn more about these [later](/tutorial/dom-events)). Replace line 9 with this:
7+
To demonstrate it, we first need to wire up an event handler (we'll learn more about these [later](/tutorial/dom-events)):
88

99
```svelte
1010
<button +++on:click={increment}+++>

content/tutorial/03-advanced-svelte/01-motion/01-tweens/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Let's start by changing the `progress` store to a `tweened` value:
1010

1111
```svelte
1212
<script>
13-
import { tweened } from 'svelte/motion';
13+
import { +++tweened+++ } from 'svelte/+++motion+++';
1414
15-
const progress = tweened(0);
15+
const progress = +++tweened+++(0);
1616
</script>
1717
```
1818

@@ -21,12 +21,12 @@ Clicking the buttons causes the progress bar to animate to its new value. It's a
2121
```svelte
2222
<script>
2323
import { tweened } from 'svelte/motion';
24-
import { cubicOut } from 'svelte/easing';
24+
+++import { cubicOut } from 'svelte/easing';+++
2525
26-
const progress = tweened(0, {
26+
const progress = tweened(0, +++{
2727
duration: 400,
2828
easing: cubicOut
29-
});
29+
}+++);
3030
</script>
3131
```
3232

content/tutorial/03-advanced-svelte/01-motion/02-springs/README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,20 @@ In this example we have two stores — one representing the circle's coordinates
88

99
```svelte
1010
<script>
11-
import { spring } from 'svelte/motion';
11+
import { +++spring+++ } from 'svelte/+++motion+++';
1212
13-
let coords = spring({ x: 50, y: 50 });
14-
let size = spring(10);
13+
let coords = +++spring+++({ x: 50, y: 50 });
14+
let size = +++spring+++(10);
1515
</script>
1616
```
1717

1818
Both springs have default `stiffness` and `damping` values, which control the spring's, well... springiness. We can specify our own initial values:
1919

2020
```js
21-
let coords = spring(
22-
{ x: 50, y: 50 },
23-
{
24-
stiffness: 0.1,
25-
damping: 0.25
26-
}
27-
);
21+
let coords = spring({ x: 50, y: 50 }, +++{
22+
stiffness: 0.1,
23+
damping: 0.25
24+
}+++);
2825
```
2926

3027
Waggle your mouse around, and try dragging the sliders to get a feel for how they affect the spring's behaviour. Notice that you can adjust the values while the spring is still in motion.

content/tutorial/03-advanced-svelte/01-motion/02-springs/app-b/src/lib/App.svelte

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
<script>
22
import { spring } from 'svelte/motion';
33
4-
let coords = spring(
5-
{ x: 50, y: 50 },
6-
{
7-
stiffness: 0.1,
8-
damping: 0.25
9-
}
10-
);
4+
let coords = spring({ x: 50, y: 50 }, {
5+
stiffness: 0.1,
6+
damping: 0.25
7+
});
118
129
let size = spring(10);
1310
</script>

content/tutorial/03-advanced-svelte/02-transitions/01-transition/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ First, import the `fade` function from `svelte/transition`...
88

99
```svelte
1010
<script>
11-
import { fade } from 'svelte/transition';
11+
+++import { fade } from 'svelte/transition';+++
1212
let visible = true;
1313
</script>
1414
```
1515

1616
...then add it to the `<p>` element:
1717

1818
```svelte
19-
<p transition:fade>Fades in and out</p>
19+
<p +++transition:fade+++>Fades in and out</p>
2020
```

content/tutorial/03-advanced-svelte/02-transitions/02-adding-parameters-to-transitions/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ Transition functions can accept parameters. Replace the `fade` transition with `
66

77
```svelte
88
<script>
9-
import { fly } from 'svelte/transition';
9+
import { +++fly+++ } from 'svelte/transition';
1010
let visible = true;
1111
</script>
1212
```
1313

1414
...and apply it to the `<p>` along with some options:
1515

1616
```svelte
17-
<p transition:fly="{{ y: 200, duration: 2000 }}">
18-
Flies in and out
17+
<p transition:+++fly={{ y: 200, duration: 2000 }}+++>
18+
+++Flies+++ in and out
1919
</p>
2020
```
2121

content/tutorial/03-advanced-svelte/02-transitions/03-in-and-out/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ title: In and out
55
Instead of the `transition` directive, an element can have an `in` or an `out` directive, or both together. Import `fade` alongside `fly`...
66

77
```js
8-
import { fade, fly } from 'svelte/transition';
8+
import { +++fade+++, fly } from 'svelte/transition';
99
```
1010

1111
...then replace the `transition` directive with separate `in` and `out` directives:
1212

1313
```svelte
14-
<p in:fly="{{ y: 200, duration: 2000 }}" out:fade>
15-
Flies in, fades out
14+
<p +++in+++:fly={{ y: 200, duration: 2000 }} +++out:fade+++>
15+
Flies in, +++fades out+++
1616
</p>
1717
```
1818

content/tutorial/03-advanced-svelte/02-transitions/04-custom-css-transitions/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ We can get a lot more creative though. Let's make something truly gratuitous:
5151
```svelte
5252
<script>
5353
import { fade } from 'svelte/transition';
54-
import { elasticOut } from 'svelte/easing';
54+
+++import { elasticOut } from 'svelte/easing';+++
5555
5656
let visible = true;
5757
5858
function spin(node, { duration }) {
5959
return {
6060
duration,
61-
css: t => {
61+
css: t => +++{
6262
const eased = elasticOut(t);
6363
6464
return `
@@ -68,7 +68,7 @@ We can get a lot more creative though. Let's make something truly gratuitous:
6868
${Math.min(100, 1000 - 1000 * t)}%,
6969
${Math.min(50, 500 - 500 * t)}%
7070
);`
71-
}
71+
}+++
7272
};
7373
}
7474
</script>

content/tutorial/03-advanced-svelte/02-transitions/04-custom-css-transitions/app-b/src/lib/App.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
const eased = elasticOut(t);
1212
1313
return `
14-
transform: scale(${eased}) rotate(${
15-
eased * 1080
16-
}deg);
14+
transform: scale(${eased}) rotate(${eased * 1080}deg);
1715
color: hsl(
1816
${Math.trunc(t * 360)},
1917
${Math.min(100, 1000 - 1000 * t)}%,

content/tutorial/03-advanced-svelte/02-transitions/05-custom-js-transitions/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function typewriter(node, { speed = 1 }) {
1212
throw new Error(`This transition only works on elements with a single text node child`);
1313
}
1414

15-
const text = node.textContent;
15+
+++const text = node.textContent;
1616
const duration = text.length / (speed * 0.01);
1717

1818
return {
@@ -21,6 +21,6 @@ function typewriter(node, { speed = 1 }) {
2121
const i = Math.trunc(text.length * t);
2222
node.textContent = text.slice(0, i);
2323
}
24-
};
24+
};+++
2525
}
2626
```

content/tutorial/03-advanced-svelte/02-transitions/05-custom-js-transitions/app-a/src/lib/App.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
<script>
22
let visible = false;
33
4-
function typewriter(node, { speed = 50 }) {
5-
// implementation goes here
4+
function typewriter(node, { speed = 1 }) {
5+
const valid = node.childNodes.length === 1 && node.childNodes[0].nodeType === Node.TEXT_NODE;
6+
7+
if (!valid) {
8+
throw new Error(`This transition only works on elements with a single text node child`);
9+
}
610
711
return {};
812
}

content/tutorial/03-advanced-svelte/02-transitions/05-custom-js-transitions/app-b/src/lib/App.svelte

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22
let visible = false;
33
44
function typewriter(node, { speed = 1 }) {
5-
const valid =
6-
node.childNodes.length === 1 &&
7-
node.childNodes[0].nodeType ===
8-
Node.TEXT_NODE;
5+
const valid = node.childNodes.length === 1 && node.childNodes[0].nodeType === Node.TEXT_NODE;
96
107
if (!valid) {
11-
throw new Error(
12-
`This transition only works on elements with a single text node child`
13-
);
8+
throw new Error(`This transition only works on elements with a single text node child`);
149
}
1510
1611
const text = node.textContent;

content/tutorial/03-advanced-svelte/02-transitions/06-transition-events/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ It can be useful to know when transitions are beginning and ending. Svelte dispa
66

77
```svelte
88
<p
9-
transition:fly="{{ y: 200, duration: 2000 }}"
10-
on:introstart="{() => status = 'intro started'}"
11-
on:outrostart="{() => status = 'outro started'}"
12-
on:introend="{() => status = 'intro ended'}"
13-
on:outroend="{() => status = 'outro ended'}"
9+
transition:fly={{ y: 200, duration: 2000 }}
10+
+++on:introstart={() => status = 'intro started'}
11+
on:outrostart={() => status = 'outro started'}
12+
on:introend={() => status = 'intro ended'}
13+
on:outroend={() => status = 'outro ended'}+++
1414
>
1515
Flies in and out
1616
</p>

content/tutorial/03-advanced-svelte/02-transitions/07-local-transitions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Instead, we'd like transitions to play only when individual items are added and
99
We can achieve this with a _local_ transition, which only plays when the block with the transition itself is added or removed:
1010

1111
```svelte
12-
<div transition:slide|local>
12+
<div transition:slide+++|local+++>
1313
{item}
1414
</div>
1515
```

content/tutorial/03-advanced-svelte/02-transitions/07-local-transitions/app-a/src/lib/App.svelte

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,11 @@
33
44
let showItems = true;
55
let i = 5;
6-
let items = [
7-
'one',
8-
'two',
9-
'three',
10-
'four',
11-
'five',
12-
'six',
13-
'seven',
14-
'eight',
15-
'nine',
16-
'ten'
17-
];
6+
let items = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'];
187
</script>
198

209
<label>
21-
<input
22-
type="checkbox"
23-
bind:checked={showItems}
24-
/>
10+
<input type="checkbox" bind:checked={showItems} />
2511
show list
2612
</label>
2713

content/tutorial/03-advanced-svelte/02-transitions/07-local-transitions/app-b/src/lib/App.svelte

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,11 @@
33
44
let showItems = true;
55
let i = 5;
6-
let items = [
7-
'one',
8-
'two',
9-
'three',
10-
'four',
11-
'five',
12-
'six',
13-
'seven',
14-
'eight',
15-
'nine',
16-
'ten'
17-
];
6+
let items = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'];
187
</script>
198

209
<label>
21-
<input
22-
type="checkbox"
23-
bind:checked={showItems}
24-
/>
10+
<input type="checkbox" bind:checked={showItems} />
2511
show list
2612
</label>
2713

content/tutorial/03-advanced-svelte/02-transitions/08-deferred-transitions/README.md

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

0 commit comments

Comments
 (0)