diff --git a/apps/svelte.dev/content/examples/00-introduction/00-hello-world/+assets/App.svelte b/apps/svelte.dev/content/examples/00-introduction/00-hello-world/+assets/App.svelte new file mode 100644 index 000000000..aa19c0abc --- /dev/null +++ b/apps/svelte.dev/content/examples/00-introduction/00-hello-world/+assets/App.svelte @@ -0,0 +1,5 @@ + + +
Styled!
+ + diff --git a/apps/svelte.dev/content/examples/00-introduction/02-styling/index.md b/apps/svelte.dev/content/examples/00-introduction/02-styling/index.md new file mode 100644 index 000000000..0f91b3eb3 --- /dev/null +++ b/apps/svelte.dev/content/examples/00-introduction/02-styling/index.md @@ -0,0 +1,3 @@ +--- +title: 'Styling' +--- diff --git a/apps/svelte.dev/content/examples/00-introduction/03-nested-components/+assets/App.svelte b/apps/svelte.dev/content/examples/00-introduction/03-nested-components/+assets/App.svelte new file mode 100644 index 000000000..86f7f3a77 --- /dev/null +++ b/apps/svelte.dev/content/examples/00-introduction/03-nested-components/+assets/App.svelte @@ -0,0 +1,14 @@ + + +These styles...
+...don't affect this element
diff --git a/apps/svelte.dev/content/examples/00-introduction/03-nested-components/index.md b/apps/svelte.dev/content/examples/00-introduction/03-nested-components/index.md new file mode 100644 index 000000000..b9c08929b --- /dev/null +++ b/apps/svelte.dev/content/examples/00-introduction/03-nested-components/index.md @@ -0,0 +1,3 @@ +--- +title: 'Nested components' +--- diff --git a/apps/svelte.dev/content/examples/00-introduction/04-html-tags/+assets/App.svelte b/apps/svelte.dev/content/examples/00-introduction/04-html-tags/+assets/App.svelte new file mode 100644 index 000000000..ebc5ade2b --- /dev/null +++ b/apps/svelte.dev/content/examples/00-introduction/04-html-tags/+assets/App.svelte @@ -0,0 +1,5 @@ + + +{@html string}
diff --git a/apps/svelte.dev/content/examples/00-introduction/04-html-tags/index.md b/apps/svelte.dev/content/examples/00-introduction/04-html-tags/index.md new file mode 100644 index 000000000..83119c6fd --- /dev/null +++ b/apps/svelte.dev/content/examples/00-introduction/04-html-tags/index.md @@ -0,0 +1,3 @@ +--- +title: 'HTML tags' +--- diff --git a/apps/svelte.dev/content/examples/00-introduction/index.md b/apps/svelte.dev/content/examples/00-introduction/index.md new file mode 100644 index 000000000..22205ad84 --- /dev/null +++ b/apps/svelte.dev/content/examples/00-introduction/index.md @@ -0,0 +1,3 @@ +--- +title: 'Introduction' +--- diff --git a/apps/svelte.dev/content/examples/01-reactivity/00-reactive-assignments/+assets/App.svelte b/apps/svelte.dev/content/examples/01-reactivity/00-reactive-assignments/+assets/App.svelte new file mode 100644 index 000000000..23c8d9754 --- /dev/null +++ b/apps/svelte.dev/content/examples/01-reactivity/00-reactive-assignments/+assets/App.svelte @@ -0,0 +1,12 @@ + + + diff --git a/apps/svelte.dev/content/examples/01-reactivity/00-reactive-assignments/index.md b/apps/svelte.dev/content/examples/01-reactivity/00-reactive-assignments/index.md new file mode 100644 index 000000000..c52f07fe0 --- /dev/null +++ b/apps/svelte.dev/content/examples/01-reactivity/00-reactive-assignments/index.md @@ -0,0 +1,3 @@ +--- +title: 'Reactive assignments' +--- diff --git a/apps/svelte.dev/content/examples/01-reactivity/01-reactive-declarations/+assets/App.svelte b/apps/svelte.dev/content/examples/01-reactivity/01-reactive-declarations/+assets/App.svelte new file mode 100644 index 000000000..57cc267ef --- /dev/null +++ b/apps/svelte.dev/content/examples/01-reactivity/01-reactive-declarations/+assets/App.svelte @@ -0,0 +1,17 @@ + + + + +{count} * 2 = {doubled}
+{doubled} * 2 = {quadrupled}
diff --git a/apps/svelte.dev/content/examples/01-reactivity/01-reactive-declarations/index.md b/apps/svelte.dev/content/examples/01-reactivity/01-reactive-declarations/index.md new file mode 100644 index 000000000..042e653e2 --- /dev/null +++ b/apps/svelte.dev/content/examples/01-reactivity/01-reactive-declarations/index.md @@ -0,0 +1,3 @@ +--- +title: 'Reactive declarations' +--- diff --git a/apps/svelte.dev/content/examples/01-reactivity/02-reactive-statements/+assets/App.svelte b/apps/svelte.dev/content/examples/01-reactivity/02-reactive-statements/+assets/App.svelte new file mode 100644 index 000000000..2f042e26f --- /dev/null +++ b/apps/svelte.dev/content/examples/01-reactivity/02-reactive-statements/+assets/App.svelte @@ -0,0 +1,19 @@ + + + diff --git a/apps/svelte.dev/content/examples/01-reactivity/02-reactive-statements/index.md b/apps/svelte.dev/content/examples/01-reactivity/02-reactive-statements/index.md new file mode 100644 index 000000000..5b4e2f58a --- /dev/null +++ b/apps/svelte.dev/content/examples/01-reactivity/02-reactive-statements/index.md @@ -0,0 +1,3 @@ +--- +title: 'Reactive statements' +--- diff --git a/apps/svelte.dev/content/examples/01-reactivity/index.md b/apps/svelte.dev/content/examples/01-reactivity/index.md new file mode 100644 index 000000000..2e2368597 --- /dev/null +++ b/apps/svelte.dev/content/examples/01-reactivity/index.md @@ -0,0 +1,3 @@ +--- +title: 'Reactivity' +--- diff --git a/apps/svelte.dev/content/examples/02-props/00-declaring-props/+assets/App.svelte b/apps/svelte.dev/content/examples/02-props/00-declaring-props/+assets/App.svelte new file mode 100644 index 000000000..f64b69a87 --- /dev/null +++ b/apps/svelte.dev/content/examples/02-props/00-declaring-props/+assets/App.svelte @@ -0,0 +1,5 @@ + + +The answer is {answer}
diff --git a/apps/svelte.dev/content/examples/02-props/00-declaring-props/index.md b/apps/svelte.dev/content/examples/02-props/00-declaring-props/index.md new file mode 100644 index 000000000..d95bea339 --- /dev/null +++ b/apps/svelte.dev/content/examples/02-props/00-declaring-props/index.md @@ -0,0 +1,3 @@ +--- +title: 'Declaring props' +--- diff --git a/apps/svelte.dev/content/examples/02-props/01-default-values/+assets/App.svelte b/apps/svelte.dev/content/examples/02-props/01-default-values/+assets/App.svelte new file mode 100644 index 000000000..27e880eb5 --- /dev/null +++ b/apps/svelte.dev/content/examples/02-props/01-default-values/+assets/App.svelte @@ -0,0 +1,6 @@ + + +The answer is {answer}
diff --git a/apps/svelte.dev/content/examples/02-props/01-default-values/index.md b/apps/svelte.dev/content/examples/02-props/01-default-values/index.md new file mode 100644 index 000000000..646ca9e05 --- /dev/null +++ b/apps/svelte.dev/content/examples/02-props/01-default-values/index.md @@ -0,0 +1,3 @@ +--- +title: 'Default values' +--- diff --git a/apps/svelte.dev/content/examples/02-props/02-spread-props/+assets/App.svelte b/apps/svelte.dev/content/examples/02-props/02-spread-props/+assets/App.svelte new file mode 100644 index 000000000..d2f97713d --- /dev/null +++ b/apps/svelte.dev/content/examples/02-props/02-spread-props/+assets/App.svelte @@ -0,0 +1,12 @@ + + +
+ The {name}
package is {speed} fast. Download version {version} from
+ npm
+ and learn more here
+
{x} is greater than 10
+{:else if 5 > x} +{x} is less than 5
+{:else} +{x} is between 5 and 10
+{/if} diff --git a/apps/svelte.dev/content/examples/03-logic/02-else-if-blocks/index.md b/apps/svelte.dev/content/examples/03-logic/02-else-if-blocks/index.md new file mode 100644 index 000000000..56c2f9ce1 --- /dev/null +++ b/apps/svelte.dev/content/examples/03-logic/02-else-if-blocks/index.md @@ -0,0 +1,3 @@ +--- +title: 'Else-if blocks' +--- diff --git a/apps/svelte.dev/content/examples/03-logic/03-each-blocks/+assets/App.svelte b/apps/svelte.dev/content/examples/03-logic/03-each-blocks/+assets/App.svelte new file mode 100644 index 000000000..7d08b79ab --- /dev/null +++ b/apps/svelte.dev/content/examples/03-logic/03-each-blocks/+assets/App.svelte @@ -0,0 +1,19 @@ + + ++ initial + current +
+ + diff --git a/apps/svelte.dev/content/examples/03-logic/04-keyed-each-blocks/index.md b/apps/svelte.dev/content/examples/03-logic/04-keyed-each-blocks/index.md new file mode 100644 index 000000000..a4cbcd09c --- /dev/null +++ b/apps/svelte.dev/content/examples/03-logic/04-keyed-each-blocks/index.md @@ -0,0 +1,3 @@ +--- +title: 'Keyed each blocks' +--- diff --git a/apps/svelte.dev/content/examples/03-logic/05-await-blocks/+assets/App.svelte b/apps/svelte.dev/content/examples/03-logic/05-await-blocks/+assets/App.svelte new file mode 100644 index 000000000..837e2ef49 --- /dev/null +++ b/apps/svelte.dev/content/examples/03-logic/05-await-blocks/+assets/App.svelte @@ -0,0 +1,28 @@ + + + + +{#await promise} +...waiting
+{:then number} +The number is {number}
+{:catch error} +{error.message}
+{/await} diff --git a/apps/svelte.dev/content/examples/03-logic/05-await-blocks/index.md b/apps/svelte.dev/content/examples/03-logic/05-await-blocks/index.md new file mode 100644 index 000000000..6f7157c21 --- /dev/null +++ b/apps/svelte.dev/content/examples/03-logic/05-await-blocks/index.md @@ -0,0 +1,3 @@ +--- +title: 'Await blocks' +--- diff --git a/apps/svelte.dev/content/examples/03-logic/index.md b/apps/svelte.dev/content/examples/03-logic/index.md new file mode 100644 index 000000000..0d966e08d --- /dev/null +++ b/apps/svelte.dev/content/examples/03-logic/index.md @@ -0,0 +1,3 @@ +--- +title: 'Logic' +--- diff --git a/apps/svelte.dev/content/examples/04-events/00-dom-events/+assets/App.svelte b/apps/svelte.dev/content/examples/04-events/00-dom-events/+assets/App.svelte new file mode 100644 index 000000000..aba60dc3f --- /dev/null +++ b/apps/svelte.dev/content/examples/04-events/00-dom-events/+assets/App.svelte @@ -0,0 +1,20 @@ + + + +Hello {name || 'stranger'}!
diff --git a/apps/svelte.dev/content/examples/05-bindings/00-text-inputs/index.md b/apps/svelte.dev/content/examples/05-bindings/00-text-inputs/index.md new file mode 100644 index 000000000..76864d08d --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/00-text-inputs/index.md @@ -0,0 +1,3 @@ +--- +title: 'Text inputs' +--- diff --git a/apps/svelte.dev/content/examples/05-bindings/01-numeric-inputs/+assets/App.svelte b/apps/svelte.dev/content/examples/05-bindings/01-numeric-inputs/+assets/App.svelte new file mode 100644 index 000000000..9b0078e3c --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/01-numeric-inputs/+assets/App.svelte @@ -0,0 +1,16 @@ + + + + + + +{a} + {b} = {a + b}
diff --git a/apps/svelte.dev/content/examples/05-bindings/01-numeric-inputs/index.md b/apps/svelte.dev/content/examples/05-bindings/01-numeric-inputs/index.md new file mode 100644 index 000000000..bd4c6611f --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/01-numeric-inputs/index.md @@ -0,0 +1,3 @@ +--- +title: 'Numeric inputs' +--- diff --git a/apps/svelte.dev/content/examples/05-bindings/02-checkbox-inputs/+assets/App.svelte b/apps/svelte.dev/content/examples/05-bindings/02-checkbox-inputs/+assets/App.svelte new file mode 100644 index 000000000..f3c35e5c7 --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/02-checkbox-inputs/+assets/App.svelte @@ -0,0 +1,16 @@ + + + + +{#if yes} +Thank you. We will bombard your inbox and sell your personal details.
+{:else} +You must opt-in to continue. If you're not paying, you're the product.
+{/if} + + diff --git a/apps/svelte.dev/content/examples/05-bindings/02-checkbox-inputs/index.md b/apps/svelte.dev/content/examples/05-bindings/02-checkbox-inputs/index.md new file mode 100644 index 000000000..42a434f16 --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/02-checkbox-inputs/index.md @@ -0,0 +1,3 @@ +--- +title: 'Checkbox inputs' +--- diff --git a/apps/svelte.dev/content/examples/05-bindings/03-group-inputs/+assets/App.svelte b/apps/svelte.dev/content/examples/05-bindings/03-group-inputs/+assets/App.svelte new file mode 100644 index 000000000..e3b5e6a78 --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/03-group-inputs/+assets/App.svelte @@ -0,0 +1,49 @@ + + +Please select at least one flavour
+{:else if flavours.length > scoops} +Can't order more flavours than scoops!
+{:else} ++ You ordered {scoops} + {scoops === 1 ? 'scoop' : 'scoops'} + of {join(flavours)} +
+{/if} diff --git a/apps/svelte.dev/content/examples/05-bindings/03-group-inputs/index.md b/apps/svelte.dev/content/examples/05-bindings/03-group-inputs/index.md new file mode 100644 index 000000000..bd6160eaf --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/03-group-inputs/index.md @@ -0,0 +1,3 @@ +--- +title: 'Group inputs' +--- diff --git a/apps/svelte.dev/content/examples/05-bindings/04-textarea-inputs/+assets/App.svelte b/apps/svelte.dev/content/examples/05-bindings/04-textarea-inputs/+assets/App.svelte new file mode 100644 index 000000000..212547667 --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/04-textarea-inputs/+assets/App.svelte @@ -0,0 +1,15 @@ + + + + +{@html marked(text)} + + diff --git a/apps/svelte.dev/content/examples/05-bindings/04-textarea-inputs/index.md b/apps/svelte.dev/content/examples/05-bindings/04-textarea-inputs/index.md new file mode 100644 index 000000000..daeba6b77 --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/04-textarea-inputs/index.md @@ -0,0 +1,3 @@ +--- +title: 'Textarea inputs' +--- diff --git a/apps/svelte.dev/content/examples/05-bindings/05-file-inputs/+assets/App.svelte b/apps/svelte.dev/content/examples/05-bindings/05-file-inputs/+assets/App.svelte new file mode 100644 index 000000000..20bff917b --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/05-file-inputs/+assets/App.svelte @@ -0,0 +1,28 @@ + + + + + + + + +{#if files} +{file.name} ({file.size} bytes)
+ {/each} +{/if} diff --git a/apps/svelte.dev/content/examples/05-bindings/05-file-inputs/index.md b/apps/svelte.dev/content/examples/05-bindings/05-file-inputs/index.md new file mode 100644 index 000000000..3b4b55b95 --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/05-file-inputs/index.md @@ -0,0 +1,3 @@ +--- +title: 'File inputs' +--- diff --git a/apps/svelte.dev/content/examples/05-bindings/06-select-bindings/+assets/App.svelte b/apps/svelte.dev/content/examples/05-bindings/06-select-bindings/+assets/App.svelte new file mode 100644 index 000000000..8b99afb19 --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/06-select-bindings/+assets/App.svelte @@ -0,0 +1,42 @@ + + +selected question {selected ? selected.id : '[waiting...]'}
+ + diff --git a/apps/svelte.dev/content/examples/05-bindings/06-select-bindings/index.md b/apps/svelte.dev/content/examples/05-bindings/06-select-bindings/index.md new file mode 100644 index 000000000..66ce0b03f --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/06-select-bindings/index.md @@ -0,0 +1,3 @@ +--- +title: 'Select bindings' +--- diff --git a/apps/svelte.dev/content/examples/05-bindings/07-multiple-select-bindings/+assets/App.svelte b/apps/svelte.dev/content/examples/05-bindings/07-multiple-select-bindings/+assets/App.svelte new file mode 100644 index 000000000..0fa6aeea8 --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/07-multiple-select-bindings/+assets/App.svelte @@ -0,0 +1,50 @@ + + +Please select at least one flavour
+{:else if flavours.length > scoops} +Can't order more flavours than scoops!
+{:else} ++ You ordered {scoops} + {scoops === 1 ? 'scoop' : 'scoops'} + of {join(flavours)} +
+{/if} diff --git a/apps/svelte.dev/content/examples/05-bindings/07-multiple-select-bindings/index.md b/apps/svelte.dev/content/examples/05-bindings/07-multiple-select-bindings/index.md new file mode 100644 index 000000000..5bc73192a --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/07-multiple-select-bindings/index.md @@ -0,0 +1,3 @@ +--- +title: 'Select multiple' +--- diff --git a/apps/svelte.dev/content/examples/05-bindings/08-each-block-bindings/+assets/App.svelte b/apps/svelte.dev/content/examples/05-bindings/08-each-block-bindings/+assets/App.svelte new file mode 100644 index 000000000..01894dd01 --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/08-each-block-bindings/+assets/App.svelte @@ -0,0 +1,33 @@ + + +{remaining} remaining
+ + + + diff --git a/apps/svelte.dev/content/examples/05-bindings/08-each-block-bindings/index.md b/apps/svelte.dev/content/examples/05-bindings/08-each-block-bindings/index.md new file mode 100644 index 000000000..f9c02bf47 --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/08-each-block-bindings/index.md @@ -0,0 +1,3 @@ +--- +title: 'Each block bindings' +--- diff --git a/apps/svelte.dev/content/examples/05-bindings/09-media-elements/+assets/App.svelte b/apps/svelte.dev/content/examples/05-bindings/09-media-elements/+assets/App.svelte new file mode 100644 index 000000000..1c4804226 --- /dev/null +++ b/apps/svelte.dev/content/examples/05-bindings/09-media-elements/+assets/App.svelte @@ -0,0 +1,134 @@ + + +From Blender Studio. CC-BY
+ +size: {w}px x {h}px
+ +loading...
+ {/each} ++ The page has been open for + {seconds} + {seconds === 1 ? 'second' : 'seconds'} +
diff --git a/apps/svelte.dev/content/examples/06-lifecycle/01-ondestroy/+assets/utils.js b/apps/svelte.dev/content/examples/06-lifecycle/01-ondestroy/+assets/utils.js new file mode 100644 index 000000000..42423ff32 --- /dev/null +++ b/apps/svelte.dev/content/examples/06-lifecycle/01-ondestroy/+assets/utils.js @@ -0,0 +1,9 @@ +import { onDestroy } from 'svelte'; + +export function onInterval(callback, milliseconds) { + const interval = setInterval(callback, milliseconds); + + onDestroy(() => { + clearInterval(interval); + }); +} diff --git a/apps/svelte.dev/content/examples/06-lifecycle/01-ondestroy/index.md b/apps/svelte.dev/content/examples/06-lifecycle/01-ondestroy/index.md new file mode 100644 index 000000000..62b21a40d --- /dev/null +++ b/apps/svelte.dev/content/examples/06-lifecycle/01-ondestroy/index.md @@ -0,0 +1,3 @@ +--- +title: 'onDestroy' +--- diff --git a/apps/svelte.dev/content/examples/06-lifecycle/02-tick/+assets/App.svelte b/apps/svelte.dev/content/examples/06-lifecycle/02-tick/+assets/App.svelte new file mode 100644 index 000000000..b1fbd597c --- /dev/null +++ b/apps/svelte.dev/content/examples/06-lifecycle/02-tick/+assets/App.svelte @@ -0,0 +1,31 @@ + + + + + diff --git a/apps/svelte.dev/content/examples/06-lifecycle/02-tick/index.md b/apps/svelte.dev/content/examples/06-lifecycle/02-tick/index.md new file mode 100644 index 000000000..82de06d34 --- /dev/null +++ b/apps/svelte.dev/content/examples/06-lifecycle/02-tick/index.md @@ -0,0 +1,3 @@ +--- +title: 'tick' +--- diff --git a/apps/svelte.dev/content/examples/06-lifecycle/index.md b/apps/svelte.dev/content/examples/06-lifecycle/index.md new file mode 100644 index 000000000..274624f9a --- /dev/null +++ b/apps/svelte.dev/content/examples/06-lifecycle/index.md @@ -0,0 +1,3 @@ +--- +title: 'Lifecycle' +--- diff --git a/apps/svelte.dev/content/examples/07-stores/00-writable-stores/+assets/App.svelte b/apps/svelte.dev/content/examples/07-stores/00-writable-stores/+assets/App.svelte new file mode 100644 index 000000000..734bc083d --- /dev/null +++ b/apps/svelte.dev/content/examples/07-stores/00-writable-stores/+assets/App.svelte @@ -0,0 +1,21 @@ + + ++ This page has been open for + {$elapsed} + {$elapsed === 1 ? 'second' : 'seconds'} +
diff --git a/apps/svelte.dev/content/examples/07-stores/03-derived-stores/+assets/stores.js b/apps/svelte.dev/content/examples/07-stores/03-derived-stores/+assets/stores.js new file mode 100644 index 000000000..741f92784 --- /dev/null +++ b/apps/svelte.dev/content/examples/07-stores/03-derived-stores/+assets/stores.js @@ -0,0 +1,15 @@ +import { readable, derived } from 'svelte/store'; + +export const time = readable(new Date(), function start(set) { + const interval = setInterval(() => { + set(new Date()); + }, 1000); + + return function stop() { + clearInterval(interval); + }; +}); + +const start = new Date(); + +export const elapsed = derived(time, ($time) => Math.round(($time - start) / 1000)); diff --git a/apps/svelte.dev/content/examples/07-stores/03-derived-stores/index.md b/apps/svelte.dev/content/examples/07-stores/03-derived-stores/index.md new file mode 100644 index 000000000..1a39266f1 --- /dev/null +++ b/apps/svelte.dev/content/examples/07-stores/03-derived-stores/index.md @@ -0,0 +1,3 @@ +--- +title: 'Derived stores' +--- diff --git a/apps/svelte.dev/content/examples/07-stores/04-custom-stores/+assets/App.svelte b/apps/svelte.dev/content/examples/07-stores/04-custom-stores/+assets/App.svelte new file mode 100644 index 000000000..f06fb48ad --- /dev/null +++ b/apps/svelte.dev/content/examples/07-stores/04-custom-stores/+assets/App.svelte @@ -0,0 +1,9 @@ + + +Fades in and out
+{/if} diff --git a/apps/svelte.dev/content/examples/09-transitions/00-transition/index.md b/apps/svelte.dev/content/examples/09-transitions/00-transition/index.md new file mode 100644 index 000000000..83911f1b4 --- /dev/null +++ b/apps/svelte.dev/content/examples/09-transitions/00-transition/index.md @@ -0,0 +1,3 @@ +--- +title: 'The transition directive' +--- diff --git a/apps/svelte.dev/content/examples/09-transitions/01-adding-parameters-to-transitions/+assets/App.svelte b/apps/svelte.dev/content/examples/09-transitions/01-adding-parameters-to-transitions/+assets/App.svelte new file mode 100644 index 000000000..7127f6b67 --- /dev/null +++ b/apps/svelte.dev/content/examples/09-transitions/01-adding-parameters-to-transitions/+assets/App.svelte @@ -0,0 +1,13 @@ + + + + +{#if visible} +Flies in and out
+{/if} diff --git a/apps/svelte.dev/content/examples/09-transitions/01-adding-parameters-to-transitions/index.md b/apps/svelte.dev/content/examples/09-transitions/01-adding-parameters-to-transitions/index.md new file mode 100644 index 000000000..5e1de5655 --- /dev/null +++ b/apps/svelte.dev/content/examples/09-transitions/01-adding-parameters-to-transitions/index.md @@ -0,0 +1,3 @@ +--- +title: 'Adding parameters' +--- diff --git a/apps/svelte.dev/content/examples/09-transitions/02-in-and-out/+assets/App.svelte b/apps/svelte.dev/content/examples/09-transitions/02-in-and-out/+assets/App.svelte new file mode 100644 index 000000000..16fbda8e6 --- /dev/null +++ b/apps/svelte.dev/content/examples/09-transitions/02-in-and-out/+assets/App.svelte @@ -0,0 +1,13 @@ + + + + +{#if visible} +Flies in, fades out
+{/if} diff --git a/apps/svelte.dev/content/examples/09-transitions/02-in-and-out/index.md b/apps/svelte.dev/content/examples/09-transitions/02-in-and-out/index.md new file mode 100644 index 000000000..3070eddbc --- /dev/null +++ b/apps/svelte.dev/content/examples/09-transitions/02-in-and-out/index.md @@ -0,0 +1,3 @@ +--- +title: 'In and out' +--- diff --git a/apps/svelte.dev/content/examples/09-transitions/03-custom-css-transitions/+assets/App.svelte b/apps/svelte.dev/content/examples/09-transitions/03-custom-css-transitions/+assets/App.svelte new file mode 100644 index 000000000..8edfceb29 --- /dev/null +++ b/apps/svelte.dev/content/examples/09-transitions/03-custom-css-transitions/+assets/App.svelte @@ -0,0 +1,49 @@ + + + + +{#if visible} +The quick brown fox jumps over the lazy dog
+{/if} diff --git a/apps/svelte.dev/content/examples/09-transitions/04-custom-js-transitions/index.md b/apps/svelte.dev/content/examples/09-transitions/04-custom-js-transitions/index.md new file mode 100644 index 000000000..71523362f --- /dev/null +++ b/apps/svelte.dev/content/examples/09-transitions/04-custom-js-transitions/index.md @@ -0,0 +1,3 @@ +--- +title: 'Custom JS transitions' +--- diff --git a/apps/svelte.dev/content/examples/09-transitions/05-transition-events/+assets/App.svelte b/apps/svelte.dev/content/examples/09-transitions/05-transition-events/+assets/App.svelte new file mode 100644 index 000000000..48a926e26 --- /dev/null +++ b/apps/svelte.dev/content/examples/09-transitions/05-transition-events/+assets/App.svelte @@ -0,0 +1,25 @@ + + +status: {status}
+ + + +{#if visible} +(status = 'intro started')} + onoutrostart={() => (status = 'outro started')} + onintroend={() => (status = 'intro ended')} + onoutroend={() => (status = 'outro ended')} + > + Flies in and out +
+{/if} diff --git a/apps/svelte.dev/content/examples/09-transitions/05-transition-events/index.md b/apps/svelte.dev/content/examples/09-transitions/05-transition-events/index.md new file mode 100644 index 000000000..7a3e96afc --- /dev/null +++ b/apps/svelte.dev/content/examples/09-transitions/05-transition-events/index.md @@ -0,0 +1,3 @@ +--- +title: 'Transition events' +--- diff --git a/apps/svelte.dev/content/examples/09-transitions/06-deferred-transitions/+assets/App.svelte b/apps/svelte.dev/content/examples/09-transitions/06-deferred-transitions/+assets/App.svelte new file mode 100644 index 000000000..8135dbe92 --- /dev/null +++ b/apps/svelte.dev/content/examples/09-transitions/06-deferred-transitions/+assets/App.svelte @@ -0,0 +1,155 @@ + + ++ via Flickr + – + {d.license.name} +
++ Average September extent. Source: NSIDC/NASA +
+ + diff --git a/apps/svelte.dev/content/examples/12-svg/03-area-chart/+assets/data.js b/apps/svelte.dev/content/examples/12-svg/03-area-chart/+assets/data.js new file mode 100644 index 000000000..e50c29c9a --- /dev/null +++ b/apps/svelte.dev/content/examples/12-svg/03-area-chart/+assets/data.js @@ -0,0 +1,45 @@ +export default [ + { x: 1979, y: 7.19 }, + { x: 1980, y: 7.83 }, + { x: 1981, y: 7.24 }, + { x: 1982, y: 7.44 }, + { x: 1983, y: 7.51 }, + { x: 1984, y: 7.1 }, + { x: 1985, y: 6.91 }, + { x: 1986, y: 7.53 }, + { x: 1987, y: 7.47 }, + { x: 1988, y: 7.48 }, + { x: 1989, y: 7.03 }, + { x: 1990, y: 6.23 }, + { x: 1991, y: 6.54 }, + { x: 1992, y: 7.54 }, + { x: 1993, y: 6.5 }, + { x: 1994, y: 7.18 }, + { x: 1995, y: 6.12 }, + { x: 1996, y: 7.87 }, + { x: 1997, y: 6.73 }, + { x: 1998, y: 6.55 }, + { x: 1999, y: 6.23 }, + { x: 2000, y: 6.31 }, + { x: 2001, y: 6.74 }, + { x: 2002, y: 5.95 }, + { x: 2003, y: 6.13 }, + { x: 2004, y: 6.04 }, + { x: 2005, y: 5.56 }, + { x: 2006, y: 5.91 }, + { x: 2007, y: 4.29 }, + { x: 2008, y: 4.72 }, + { x: 2009, y: 5.38 }, + { x: 2010, y: 4.92 }, + { x: 2011, y: 4.61 }, + { x: 2012, y: 3.62 }, + { x: 2013, y: 5.35 }, + { x: 2014, y: 5.28 }, + { x: 2015, y: 4.63 }, + { x: 2016, y: 4.72 }, + { x: 2017, y: 4.82 }, + { x: 2018, y: 4.79 }, + { x: 2019, y: 4.36 }, + { x: 2020, y: 4 }, + { x: 2021, y: 4.92 } +]; diff --git a/apps/svelte.dev/content/examples/12-svg/03-area-chart/index.md b/apps/svelte.dev/content/examples/12-svg/03-area-chart/index.md new file mode 100644 index 000000000..2c3da85ea --- /dev/null +++ b/apps/svelte.dev/content/examples/12-svg/03-area-chart/index.md @@ -0,0 +1,3 @@ +--- +title: 'Area chart' +--- diff --git a/apps/svelte.dev/content/examples/12-svg/04-scatterplot/+assets/App.svelte b/apps/svelte.dev/content/examples/12-svg/04-scatterplot/+assets/App.svelte new file mode 100644 index 000000000..186193b11 --- /dev/null +++ b/apps/svelte.dev/content/examples/12-svg/04-scatterplot/+assets/App.svelte @@ -0,0 +1,24 @@ + + +congratulations, you pressed and held for {duration}ms
+{/if} diff --git a/apps/svelte.dev/content/examples/13-actions/01-adding-parameters-to-actions/+assets/longpress.js b/apps/svelte.dev/content/examples/13-actions/01-adding-parameters-to-actions/+assets/longpress.js new file mode 100644 index 000000000..240ecd002 --- /dev/null +++ b/apps/svelte.dev/content/examples/13-actions/01-adding-parameters-to-actions/+assets/longpress.js @@ -0,0 +1,26 @@ +export function longpress(node, duration) { + let timer; + + const handleMousedown = () => { + timer = setTimeout(() => { + node.dispatchEvent(new CustomEvent('longpress')); + }, duration); + }; + + const handleMouseup = () => { + clearTimeout(timer); + }; + + node.addEventListener('mousedown', handleMousedown); + node.addEventListener('mouseup', handleMouseup); + + return { + update(newDuration) { + duration = newDuration; + }, + destroy() { + node.removeEventListener('mousedown', handleMousedown); + node.removeEventListener('mouseup', handleMouseup); + } + }; +} diff --git a/apps/svelte.dev/content/examples/13-actions/01-adding-parameters-to-actions/index.md b/apps/svelte.dev/content/examples/13-actions/01-adding-parameters-to-actions/index.md new file mode 100644 index 000000000..5e1de5655 --- /dev/null +++ b/apps/svelte.dev/content/examples/13-actions/01-adding-parameters-to-actions/index.md @@ -0,0 +1,3 @@ +--- +title: 'Adding parameters' +--- diff --git a/apps/svelte.dev/content/examples/13-actions/03-actions-pannable/+assets/App.svelte b/apps/svelte.dev/content/examples/13-actions/03-actions-pannable/+assets/App.svelte new file mode 100644 index 000000000..ce93e9d29 --- /dev/null +++ b/apps/svelte.dev/content/examples/13-actions/03-actions-pannable/+assets/App.svelte @@ -0,0 +1,55 @@ + + + + + diff --git a/apps/svelte.dev/content/examples/13-actions/03-actions-pannable/+assets/pannable.js b/apps/svelte.dev/content/examples/13-actions/03-actions-pannable/+assets/pannable.js new file mode 100644 index 000000000..d7d476662 --- /dev/null +++ b/apps/svelte.dev/content/examples/13-actions/03-actions-pannable/+assets/pannable.js @@ -0,0 +1,53 @@ +export function pannable(node) { + let x; + let y; + + function handleMousedown(event) { + x = event.clientX; + y = event.clientY; + + node.dispatchEvent( + new CustomEvent('panstart', { + detail: { x, y } + }) + ); + + window.addEventListener('mousemove', handleMousemove); + window.addEventListener('mouseup', handleMouseup); + } + + function handleMousemove(event) { + const dx = event.clientX - x; + const dy = event.clientY - y; + x = event.clientX; + y = event.clientY; + + node.dispatchEvent( + new CustomEvent('panmove', { + detail: { x, y, dx, dy } + }) + ); + } + + function handleMouseup(event) { + x = event.clientX; + y = event.clientY; + + node.dispatchEvent( + new CustomEvent('panend', { + detail: { x, y } + }) + ); + + window.removeEventListener('mousemove', handleMousemove); + window.removeEventListener('mouseup', handleMouseup); + } + + node.addEventListener('mousedown', handleMousedown); + + return { + destroy() { + node.removeEventListener('mousedown', handleMousedown); + } + }; +} diff --git a/apps/svelte.dev/content/examples/13-actions/03-actions-pannable/index.md b/apps/svelte.dev/content/examples/13-actions/03-actions-pannable/index.md new file mode 100644 index 000000000..8661a7c86 --- /dev/null +++ b/apps/svelte.dev/content/examples/13-actions/03-actions-pannable/index.md @@ -0,0 +1,3 @@ +--- +title: 'A more complex action' +--- diff --git a/apps/svelte.dev/content/examples/13-actions/index.md b/apps/svelte.dev/content/examples/13-actions/index.md new file mode 100644 index 000000000..dafdab061 --- /dev/null +++ b/apps/svelte.dev/content/examples/13-actions/index.md @@ -0,0 +1,3 @@ +--- +title: 'Actions' +--- diff --git a/apps/svelte.dev/content/examples/14-classes/00-classes/+assets/App.svelte b/apps/svelte.dev/content/examples/14-classes/00-classes/+assets/App.svelte new file mode 100644 index 000000000..f96741845 --- /dev/null +++ b/apps/svelte.dev/content/examples/14-classes/00-classes/+assets/App.svelte @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/apps/svelte.dev/content/examples/14-classes/00-classes/index.md b/apps/svelte.dev/content/examples/14-classes/00-classes/index.md new file mode 100644 index 000000000..266b27c78 --- /dev/null +++ b/apps/svelte.dev/content/examples/14-classes/00-classes/index.md @@ -0,0 +1,3 @@ +--- +title: 'The class directive' +--- diff --git a/apps/svelte.dev/content/examples/14-classes/01-class-shorthand/+assets/App.svelte b/apps/svelte.dev/content/examples/14-classes/01-class-shorthand/+assets/App.svelte new file mode 100644 index 000000000..95866b40a --- /dev/null +++ b/apps/svelte.dev/content/examples/14-classes/01-class-shorthand/+assets/App.svelte @@ -0,0 +1,18 @@ + + + + +This is a box. It can contain anything.
+This is a box. It can contain anything.
+I am being hovered upon.
+ {:else} +Hover over me!
+ {/if} +I am being hovered upon.
+ {:else} +Hover over me!
+ {/if} +I am being hovered upon.
+ {:else} +Hover over me!
+ {/if} +{keyCode}
+ {:else} +Focus this window and press any key
+ {/if} +Select this text to fire events
+Selection: {selection}
diff --git a/apps/svelte.dev/content/examples/17-special-elements/04-svelte-document/index.md b/apps/svelte.dev/content/examples/17-special-elements/04-svelte-document/index.md new file mode 100644 index 000000000..b78852c7c --- /dev/null +++ b/apps/svelte.dev/content/examples/17-special-elements/04-svelte-document/index.md @@ -0,0 +1,3 @@ +--- +title: '{composer} / performed by {performer}
+ + +adjust diameter of circle at {selected.cx}, {selected.cy}
+ +loading...
+{/if} + + diff --git a/apps/svelte.dev/content/examples/21-miscellaneous/02-hacker-news/+assets/Summary.svelte b/apps/svelte.dev/content/examples/21-miscellaneous/02-hacker-news/+assets/Summary.svelte new file mode 100644 index 000000000..0754e3a0b --- /dev/null +++ b/apps/svelte.dev/content/examples/21-miscellaneous/02-hacker-news/+assets/Summary.svelte @@ -0,0 +1,34 @@ + + ++ Did you enjoy your lunch, mom? You drank it fast enough. I know, I just call her Annabelle cause + she's shaped like a…she's the belle of the ball! YOU'RE the Chiclet! Not me. Caw ca caw, caw ca + caw, caw ca caw! A Colombian cartel that WON'T kidnap and kill you. You go buy a tape recorder + and record yourself for a whole day. I think you'll be surprised at some of your phrasing. +
+{a} + {b} = {a + b}
diff --git a/apps/svelte.dev/content/examples/99-embeds/20190420-blog-write-less-code/index.md b/apps/svelte.dev/content/examples/99-embeds/20190420-blog-write-less-code/index.md new file mode 100644 index 000000000..f51787b6d --- /dev/null +++ b/apps/svelte.dev/content/examples/99-embeds/20190420-blog-write-less-code/index.md @@ -0,0 +1,3 @@ +--- +title: - +--- diff --git a/apps/svelte.dev/content/examples/99-embeds/index.md b/apps/svelte.dev/content/examples/99-embeds/index.md new file mode 100644 index 000000000..7e8d5444f --- /dev/null +++ b/apps/svelte.dev/content/examples/99-embeds/index.md @@ -0,0 +1,3 @@ +--- +title: Embeds (invisible in the examples selection) +--- diff --git a/apps/svelte.dev/content/examples/index.md b/apps/svelte.dev/content/examples/index.md new file mode 100644 index 000000000..42f7ed417 --- /dev/null +++ b/apps/svelte.dev/content/examples/index.md @@ -0,0 +1,3 @@ +--- +title: Examples +--- diff --git a/apps/svelte.dev/src/constants.js b/apps/svelte.dev/src/constants.js deleted file mode 100644 index 14cbd17a1..000000000 --- a/apps/svelte.dev/src/constants.js +++ /dev/null @@ -1,9 +0,0 @@ -export const CONTENT_BASE = '../../content'; - -/** All the paths are relative to the project root when being run on server or built */ -export const CONTENT_BASE_PATHS = { - BLOG: `${CONTENT_BASE}/blog`, - TUTORIAL: `${CONTENT_BASE}/tutorial`, - DOCS: `${CONTENT_BASE}/docs`, - EXAMPLES: `${CONTENT_BASE}/examples` -}; diff --git a/apps/svelte.dev/src/lib/generated/examples-data.js b/apps/svelte.dev/src/lib/generated/examples-data.js deleted file mode 100644 index 1027cba88..000000000 --- a/apps/svelte.dev/src/lib/generated/examples-data.js +++ /dev/null @@ -1 +0,0 @@ -export default [{"title":"Introduction","slug":"introduction","examples":[{"title":"Hello world","slug":"hello-world","files":[{"name":"App.svelte","type":"svelte","content":"\n\nStyled!
\n\n\n"}]},{"title":"Nested components","slug":"nested-components","files":[{"name":"App.svelte","type":"svelte","content":"\n\nThese styles...
\n...don't affect this element
\n"}]},{"title":"HTML tags","slug":"html-tags","files":[{"name":"App.svelte","type":"svelte","content":"\n\n{@html string}
\n"}]}]},{"title":"Reactivity","slug":"reactivity","examples":[{"title":"Reactive assignments","slug":"reactive-assignments","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n"}]},{"title":"Reactive declarations","slug":"reactive-declarations","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\n{count} * 2 = {doubled}
\n{doubled} * 2 = {quadrupled}
\n"}]},{"title":"Reactive statements","slug":"reactive-statements","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n"}]}]},{"title":"Props","slug":"props","examples":[{"title":"Declaring props","slug":"declaring-props","files":[{"name":"App.svelte","type":"svelte","content":"\n\nThe answer is {answer}
\n"}]},{"title":"Default values","slug":"default-values","files":[{"name":"App.svelte","type":"svelte","content":"\n\nThe answer is {answer}
\n"}]},{"title":"Spread props","slug":"spread-props","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\tThe {name}
package is {speed} fast. Download version {version} from\n\tnpm\n\tand learn more here\n
{x} is greater than 10
\n{:else if 5 > x}\n\t{x} is less than 5
\n{:else}\n\t{x} is between 5 and 10
\n{/if}\n"}]},{"title":"Each blocks","slug":"each-blocks","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\tinitial\n\tcurrent\n
\n\n\n"}]},{"title":"Await blocks","slug":"await-blocks","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\n{#await promise}\n\t...waiting
\n{:then number}\n\tThe number is {number}
\n{:catch error}\n\t{error.message}
\n{/await}\n"}]}]},{"title":"Events","slug":"events","examples":[{"title":"DOM events","slug":"dom-events","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\nHello {name || 'stranger'}!
\n"}]},{"title":"Numeric inputs","slug":"numeric-inputs","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\n\n\n{a} + {b} = {a + b}
\n"}]},{"title":"Checkbox inputs","slug":"checkbox-inputs","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\n{#if yes}\n\tThank you. We will bombard your inbox and sell your personal details.
\n{:else}\n\tYou must opt-in to continue. If you're not paying, you're the product.
\n{/if}\n\n\n"}]},{"title":"Group inputs","slug":"group-inputs","files":[{"name":"App.svelte","type":"svelte","content":"\n\nPlease select at least one flavour
\n{:else if flavours.length > scoops}\n\tCan't order more flavours than scoops!
\n{:else}\n\t\n\t\tYou ordered {scoops}\n\t\t{scoops === 1 ? 'scoop' : 'scoops'}\n\t\tof {join(flavours)}\n\t
\n{/if}\n"}]},{"title":"Textarea inputs","slug":"textarea-inputs","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\n{@html marked(text)}\n\n\n"}]},{"title":"File inputs","slug":"file-inputs","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\n\n\n\n\n{#if files}\n\t{file.name} ({file.size} bytes)
\n\t{/each}\n{/if}\n"}]},{"title":"Select bindings","slug":"select-bindings","files":[{"name":"App.svelte","type":"svelte","content":"\n\nselected question {selected ? selected.id : '[waiting...]'}
\n\n\n"}]},{"title":"Select multiple","slug":"multiple-select-bindings","files":[{"name":"App.svelte","type":"svelte","content":"\n\nPlease select at least one flavour
\n{:else if flavours.length > scoops}\n\tCan't order more flavours than scoops!
\n{:else}\n\t\n\t\tYou ordered {scoops}\n\t\t{scoops === 1 ? 'scoop' : 'scoops'}\n\t\tof {join(flavours)}\n\t
\n{/if}\n"}]},{"title":"Each block bindings","slug":"each-block-bindings","files":[{"name":"App.svelte","type":"svelte","content":"\n\n{remaining} remaining
\n\n\n\n\n"}]},{"title":"Media elements","slug":"media-elements","files":[{"name":"App.svelte","type":"svelte","content":"\n\nFrom Blender Studio. CC-BY
\n\nsize: {w}px x {h}px
\n\nloading...
\n\t{/each}\n\n\tThe page has been open for\n\t{seconds}\n\t{seconds === 1 ? 'second' : 'seconds'}\n
\n"},{"name":"utils.js","type":"js","content":"import { onDestroy } from 'svelte';\n\nexport function onInterval(callback, milliseconds) {\n\tconst interval = setInterval(callback, milliseconds);\n\n\tonDestroy(() => {\n\t\tclearInterval(interval);\n\t});\n}\n"}]},{"title":"beforeUpdate and afterUpdate","slug":"update","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\tThis page has been open for\n\t{$elapsed}\n\t{$elapsed === 1 ? 'second' : 'seconds'}\n
\n"},{"name":"stores.js","type":"js","content":"import { readable, derived } from 'svelte/store';\n\nexport const time = readable(new Date(), function start(set) {\n\tconst interval = setInterval(() => {\n\t\tset(new Date());\n\t}, 1000);\n\n\treturn function stop() {\n\t\tclearInterval(interval);\n\t};\n});\n\nconst start = new Date();\n\nexport const elapsed = derived(time, ($time) => Math.round(($time - start) / 1000));\n"}]},{"title":"Custom stores","slug":"custom-stores","files":[{"name":"App.svelte","type":"svelte","content":"\n\nFades in and out
\n{/if}\n"}]},{"title":"Adding parameters","slug":"adding-parameters-to-transitions","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\n{#if visible}\n\tFlies in and out
\n{/if}\n"}]},{"title":"In and out","slug":"in-and-out","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\n{#if visible}\n\tFlies in, fades out
\n{/if}\n"}]},{"title":"Custom CSS transitions","slug":"custom-css-transitions","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\n{#if visible}\n\tThe quick brown fox jumps over the lazy dog
\n{/if}\n"}]},{"title":"Transition events","slug":"transition-events","files":[{"name":"App.svelte","type":"svelte","content":"\n\nstatus: {status}
\n\n\n\n{#if visible}\n\t(status = 'intro started')}\n\t\ton:outrostart={() => (status = 'outro started')}\n\t\ton:introend={() => (status = 'intro ended')}\n\t\ton:outroend={() => (status = 'outro ended')}\n\t>\n\t\tFlies in and out\n\t
\n{/if}\n"}]},{"title":"Deferred transitions","slug":"deferred-transitions","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\t\t\t\t\t\tvia Flickr\n\t\t\t\t\t\t–\n\t\t\t\t\t\t{d.license.name}\n\t\t\t\t\t
\n\t\t\t\t\n\tAverage September extent. Source: NSIDC/NASA\n
\n\n\n"},{"name":"data.js","type":"js","content":"export default [\n\t{ x: 1979, y: 7.19 },\n\t{ x: 1980, y: 7.83 },\n\t{ x: 1981, y: 7.24 },\n\t{ x: 1982, y: 7.44 },\n\t{ x: 1983, y: 7.51 },\n\t{ x: 1984, y: 7.1 },\n\t{ x: 1985, y: 6.91 },\n\t{ x: 1986, y: 7.53 },\n\t{ x: 1987, y: 7.47 },\n\t{ x: 1988, y: 7.48 },\n\t{ x: 1989, y: 7.03 },\n\t{ x: 1990, y: 6.23 },\n\t{ x: 1991, y: 6.54 },\n\t{ x: 1992, y: 7.54 },\n\t{ x: 1993, y: 6.5 },\n\t{ x: 1994, y: 7.18 },\n\t{ x: 1995, y: 6.12 },\n\t{ x: 1996, y: 7.87 },\n\t{ x: 1997, y: 6.73 },\n\t{ x: 1998, y: 6.55 },\n\t{ x: 1999, y: 6.23 },\n\t{ x: 2000, y: 6.31 },\n\t{ x: 2001, y: 6.74 },\n\t{ x: 2002, y: 5.95 },\n\t{ x: 2003, y: 6.13 },\n\t{ x: 2004, y: 6.04 },\n\t{ x: 2005, y: 5.56 },\n\t{ x: 2006, y: 5.91 },\n\t{ x: 2007, y: 4.29 },\n\t{ x: 2008, y: 4.72 },\n\t{ x: 2009, y: 5.38 },\n\t{ x: 2010, y: 4.92 },\n\t{ x: 2011, y: 4.61 },\n\t{ x: 2012, y: 3.62 },\n\t{ x: 2013, y: 5.35 },\n\t{ x: 2014, y: 5.28 },\n\t{ x: 2015, y: 4.63 },\n\t{ x: 2016, y: 4.72 },\n\t{ x: 2017, y: 4.82 },\n\t{ x: 2018, y: 4.79 },\n\t{ x: 2019, y: 4.36 },\n\t{ x: 2020, y: 4 },\n\t{ x: 2021, y: 4.92 }\n];\n"}]},{"title":"Scatterplot","slug":"scatterplot","files":[{"name":"App.svelte","type":"svelte","content":"\n\ncongratulations, you pressed and held for {duration}ms
\n{/if}\n"},{"name":"longpress.js","type":"js","content":"export function longpress(node, duration) {\n\tlet timer;\n\n\tconst handleMousedown = () => {\n\t\ttimer = setTimeout(() => {\n\t\t\tnode.dispatchEvent(new CustomEvent('longpress'));\n\t\t}, duration);\n\t};\n\n\tconst handleMouseup = () => {\n\t\tclearTimeout(timer);\n\t};\n\n\tnode.addEventListener('mousedown', handleMousedown);\n\tnode.addEventListener('mouseup', handleMouseup);\n\n\treturn {\n\t\tupdate(newDuration) {\n\t\t\tduration = newDuration;\n\t\t},\n\t\tdestroy() {\n\t\t\tnode.removeEventListener('mousedown', handleMousedown);\n\t\t\tnode.removeEventListener('mouseup', handleMouseup);\n\t\t}\n\t};\n}\n"}]},{"title":"A more complex action","slug":"actions-pannable","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\n\n"},{"name":"pannable.js","type":"js","content":"export function pannable(node) {\n\tlet x;\n\tlet y;\n\n\tfunction handleMousedown(event) {\n\t\tx = event.clientX;\n\t\ty = event.clientY;\n\n\t\tnode.dispatchEvent(\n\t\t\tnew CustomEvent('panstart', {\n\t\t\t\tdetail: { x, y }\n\t\t\t})\n\t\t);\n\n\t\twindow.addEventListener('mousemove', handleMousemove);\n\t\twindow.addEventListener('mouseup', handleMouseup);\n\t}\n\n\tfunction handleMousemove(event) {\n\t\tconst dx = event.clientX - x;\n\t\tconst dy = event.clientY - y;\n\t\tx = event.clientX;\n\t\ty = event.clientY;\n\n\t\tnode.dispatchEvent(\n\t\t\tnew CustomEvent('panmove', {\n\t\t\t\tdetail: { x, y, dx, dy }\n\t\t\t})\n\t\t);\n\t}\n\n\tfunction handleMouseup(event) {\n\t\tx = event.clientX;\n\t\ty = event.clientY;\n\n\t\tnode.dispatchEvent(\n\t\t\tnew CustomEvent('panend', {\n\t\t\t\tdetail: { x, y }\n\t\t\t})\n\t\t);\n\n\t\twindow.removeEventListener('mousemove', handleMousemove);\n\t\twindow.removeEventListener('mouseup', handleMouseup);\n\t}\n\n\tnode.addEventListener('mousedown', handleMousedown);\n\n\treturn {\n\t\tdestroy() {\n\t\t\tnode.removeEventListener('mousedown', handleMousedown);\n\t\t}\n\t};\n}\n"}]}]},{"title":"Classes","slug":"classes","examples":[{"title":"The class directive","slug":"classes","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\n\n\n\n\n\n"}]},{"title":"Shorthand class directive","slug":"class-shorthand","files":[{"name":"App.svelte","type":"svelte","content":"\n\n\n\nThis is a box. It can contain anything.
\nThis is a box. It can contain anything.
\nI am being hovered upon.
\n\t\t{:else}\n\t\t\tHover over me!
\n\t\t{/if}\n\tI am being hovered upon.
\n\t\t{:else}\n\t\t\tHover over me!
\n\t\t{/if}\n\tI am being hovered upon.
\n\t\t{:else}\n\t\t\tHover over me!
\n\t\t{/if}\n\t{keyCode}
\n\t{:else}\n\t\tFocus this window and press any key
\n\t{/if}\nSelect this text to fire events
\nSelection: {selection}
\n"}]},{"title":"{composer} / performed by {performer}
\n\n\t\nadjust diameter of circle at {selected.cx}, {selected.cy}
\n\t\t\n\tloading...
\n{/if}\n\n\n"},{"name":"Summary.svelte","type":"svelte","content":"\n\n\n\t\tDid you enjoy your lunch, mom? You drank it fast enough. I know, I just call her Annabelle cause\n\t\tshe's shaped like a…she's the belle of the ball! YOU'RE the Chiclet! Not me. Caw ca caw, caw ca\n\t\tcaw, caw ca caw! A Colombian cartel that WON'T kidnap and kill you. You go buy a tape recorder\n\t\tand record yourself for a whole day. I think you'll be surprised at some of your phrasing.\n\t
\n{a} + {b} = {a + b}
\n"}]}]}] \ No newline at end of file diff --git a/apps/svelte.dev/src/lib/server/content.ts b/apps/svelte.dev/src/lib/server/content.ts index 6a02ca613..718731afe 100644 --- a/apps/svelte.dev/src/lib/server/content.ts +++ b/apps/svelte.dev/src/lib/server/content.ts @@ -111,3 +111,5 @@ function create_docs() { } export const docs = create_docs(); + +export const examples = index.examples.children; diff --git a/apps/svelte.dev/src/lib/server/examples/index.js b/apps/svelte.dev/src/lib/server/examples/index.js deleted file mode 100644 index 759a72746..000000000 --- a/apps/svelte.dev/src/lib/server/examples/index.js +++ /dev/null @@ -1,98 +0,0 @@ -import { CONTENT_BASE_PATHS } from '../../../constants.js'; - -/** - * @param {import('./types').ExamplesData} examples_data - * @param {string} slug - */ -export function get_example(examples_data, slug) { - for (const section of examples_data) { - for (const example of section.examples) { - if (example.slug === slug) { - return example; - } - } - } - - return null; -} - -/** - * @returns {Promise