From 74a4c9fe7d807b6ec5a5bbee86a43be1ae2d02e4 Mon Sep 17 00:00:00 2001 From: Eirik Vageskar Date: Mon, 21 Jun 2021 01:06:13 +0200 Subject: [PATCH] Add tutorial step for key blocks --- .../09-key-blocks/app-a/App.svelte | 19 +++++++++++++++++ .../09-key-blocks/app-b/App.svelte | 21 +++++++++++++++++++ .../10-transitions/09-key-blocks/text.md | 16 ++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 site/content/tutorial/10-transitions/09-key-blocks/app-a/App.svelte create mode 100644 site/content/tutorial/10-transitions/09-key-blocks/app-b/App.svelte create mode 100644 site/content/tutorial/10-transitions/09-key-blocks/text.md diff --git a/site/content/tutorial/10-transitions/09-key-blocks/app-a/App.svelte b/site/content/tutorial/10-transitions/09-key-blocks/app-a/App.svelte new file mode 100644 index 0000000000..3385a02339 --- /dev/null +++ b/site/content/tutorial/10-transitions/09-key-blocks/app-a/App.svelte @@ -0,0 +1,19 @@ + + +
+ The number is: + + {number} + +
+
+ diff --git a/site/content/tutorial/10-transitions/09-key-blocks/app-b/App.svelte b/site/content/tutorial/10-transitions/09-key-blocks/app-b/App.svelte new file mode 100644 index 0000000000..0e40dc57d1 --- /dev/null +++ b/site/content/tutorial/10-transitions/09-key-blocks/app-b/App.svelte @@ -0,0 +1,21 @@ + + +
+ The number is: + {#key number} + + {number} + + {/key} +
+
+ diff --git a/site/content/tutorial/10-transitions/09-key-blocks/text.md b/site/content/tutorial/10-transitions/09-key-blocks/text.md new file mode 100644 index 0000000000..1bd701fed4 --- /dev/null +++ b/site/content/tutorial/10-transitions/09-key-blocks/text.md @@ -0,0 +1,16 @@ +--- +title: Key blocks +--- + +Key blocks destroy and recreate their contents when the value of an expression changes. + +```html +{#key value} +
{value}
+{/key} +``` + +This is useful if you want an element to play its transition whenever a value changes. + +Wrap the `` element in a key block depending on `number`. This will make the +animation play whenever you press the increment button.