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
```

0 commit comments

Comments
 (0)