Skip to content

Commit 217cd6c

Browse files
committed
move example data into components
1 parent dd6a962 commit 217cd6c

File tree

57 files changed

+252
-560
lines changed

Some content is hidden

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

57 files changed

+252
-560
lines changed

site/content/examples/7guis-circles/data.json5

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script>
2+
let count = 0;
3+
</script>
4+
15
<!-- https://github.com/eugenkiss/7guis/wiki#counter -->
26
<input type=number bind:value={count}>
37
<button on:click="{() => count += 1}">count</button>

site/content/examples/7guis-counter/data.json5

-3
This file was deleted.

site/content/examples/7guis-crud/App.svelte

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
<!-- https://eugenkiss.github.io/7guis/tasks#crud -->
22

33
<script>
4-
export let people = [];
4+
let people = [
5+
{
6+
first: 'Hans',
7+
last: 'Emil'
8+
},
9+
{
10+
first: 'Max',
11+
last: 'Mustermann'
12+
},
13+
{
14+
first: 'Roman',
15+
last: 'Tisch'
16+
}
17+
];
518
619
let prefix = '';
720
let first = '';

site/content/examples/7guis-crud/data.json5

-16
This file was deleted.

site/content/examples/7guis-flight-booker/data.json5

-1
This file was deleted.

site/content/examples/7guis-temperature/data.json5

-3
This file was deleted.

site/content/examples/7guis-timer/data.json5

-1
This file was deleted.

site/content/examples/await-block/data.json5

-1
This file was deleted.

site/content/examples/bar-chart/App.svelte

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<script>
22
import { scaleLinear } from 'd3-scale';
33
4-
export let points;
4+
const points = [
5+
{ year: 1990, birthrate: 16.7 },
6+
{ year: 1995, birthrate: 14.6 },
7+
{ year: 2000, birthrate: 14.4 },
8+
{ year: 2005, birthrate: 14 },
9+
{ year: 2010, birthrate: 13 },
10+
{ year: 2015, birthrate: 12.4 }
11+
];
512
613
const xTicks = [1990, 1995, 2000, 2005, 2010, 2015];
714
const yTicks = [0, 5, 10, 15, 20];

site/content/examples/bar-chart/data.json5

-28
This file was deleted.

site/content/examples/binding-input-checkbox-group/App.svelte

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script>
2+
const selected = ['blue'];
3+
</script>
4+
15
<label>
26
<input type=checkbox bind:group={selected} value="red">
37
red

site/content/examples/binding-input-checkbox-group/data.json5

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
{#each todos as todo}
2-
<div class="todo {todo.done ? 'done': ''}">
3-
<input type=checkbox bind:checked={todo.done}>
4-
<input type=text bind:value={todo.description}>
5-
</div>
6-
{/each}
1+
<script>
2+
const todos = [
3+
{
4+
description: "Buy some milk",
5+
done: true
6+
},
7+
{
8+
description: "Do the laundry",
9+
done: true
10+
},
11+
{
12+
description: "Find life's true purpose",
13+
done: false
14+
}
15+
];
16+
</script>
717

818
<style>
919
input[type="text"] {
@@ -14,4 +24,11 @@
1424
.done {
1525
opacity: 0.6;
1626
}
17-
</style>
27+
</style>
28+
29+
{#each todos as todo}
30+
<div class="todo {todo.done ? 'done': ''}">
31+
<input type=checkbox bind:checked={todo.done}>
32+
<input type=text bind:value={todo.description}>
33+
</div>
34+
{/each}

site/content/examples/binding-input-checkbox/data.json5

-16
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
<!-- number and range inputs are bound to numeric values -->
2-
<input bind:value={a} type=number min=0 max=10>
3-
<input bind:value={b} type=range min=0 max=10>
4-
5-
<p>{a} * {b} = {a * b}</p>
1+
<script>
2+
let a = 5;
3+
let b = 5;
4+
</script>
65

76
<style>
87
input {
98
display: block;
109
width: 10em
1110
}
12-
</style>
11+
</style>
12+
13+
<!-- number and range inputs are bound to numeric values -->
14+
<input bind:value={a} type=number min=0 max=10>
15+
<input bind:value={b} type=range min=0 max=10>
16+
17+
<p>{a} * {b} = {a * b}</p>

site/content/examples/binding-input-numeric/data.json5

-4
This file was deleted.

site/content/examples/binding-input-radio/App.svelte

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script>
2+
let selected = 'blue';
3+
</script>
4+
15
<label>
26
<input type=radio bind:group={selected} value="red">
37
red

site/content/examples/binding-input-radio/data.json5

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
<script>
2+
let name = '';
3+
</script>
4+
15
<input bind:value={name} placeholder="enter your name">
26
<p>Hello {name || 'stranger'}!</p>

site/content/examples/binding-input-text/data.json5

-3
This file was deleted.

site/content/examples/binding-media-elements/data.json5

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<script>
22
import marked from 'marked';
33
4-
export let markdown;
4+
let markdown = `# Markdown editor\n\nTODOs:\n\n* make a Svelte app\n* think of a third item for this list`;
55
</script>
66

7-
<textarea bind:value={markdown} resize="none"></textarea>
8-
<div class="output">{@html marked(markdown)}</div>
9-
107
<style>
118
textarea {
129
width: 100%;
1310
height: 50%;
1411
}
15-
</style>
12+
</style>
13+
14+
<textarea bind:value={markdown} resize="none"></textarea>
15+
<div class="output">{@html marked(markdown)}</div>

site/content/examples/binding-textarea/data.json5

-3
This file was deleted.

site/content/examples/each-blocks/App.svelte

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
<script>
2+
const cats = [
3+
{
4+
name: 'Keyboard Cat',
5+
video: 'https://www.youtube.com/watch?v=J---aiyznGQ'
6+
},
7+
{
8+
name: 'Maru',
9+
video: 'https://www.youtube.com/watch?v=z_AbfPXTKms'
10+
},
11+
{
12+
name: 'Henri The Existential Cat',
13+
video: 'https://www.youtube.com/watch?v=OUtn3pvWmpg'
14+
}
15+
];
16+
</script>
17+
118
<h1>Cats of YouTube</h1>
219

320
<ul>

site/content/examples/each-blocks/data.json5

-16
This file was deleted.

site/content/examples/hacker-news/data.json5

-1
This file was deleted.
+4-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
<h1>Hello {name}!</h1>
1+
<script>
2+
let name = 'world';
3+
</script>
24

3-
<!--
4-
This is a Svelte component. Click 'JS output' in
5-
the output section to see compiled code.
6-
7-
You can interact with this component via your
8-
browser's console - try running the following:
9-
10-
app.name = 'everybody';
11-
12-
You can also update the name via the props
13-
editor on this page.
14-
-->
5+
<h1>Hello {name}!</h1>

site/content/examples/hello-world/data.json5

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
<script>
2+
let name = 'world';
3+
</script>
4+
15
<h1>Hello {name}!</h1>

site/content/examples/homepage-demo-hello-world/data.json5

-3
This file was deleted.

site/content/examples/homepage-demo-reactivity/data.json5

-1
This file was deleted.

site/content/examples/homepage-demo-scoped-styles/data.json5

-1
This file was deleted.

site/content/examples/homepage-demo-transitions/data.json5

-1
This file was deleted.

site/content/examples/if-blocks/App.svelte

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script>
2+
let foo = true;
3+
</script>
4+
15
{#if foo}
26
<p>foo!</p>
37
{:else}

site/content/examples/if-blocks/data.json5

-3
This file was deleted.

site/content/examples/immutable/App.svelte

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
import ImmutableTodo from './ImmutableTodo.svelte';
55
import MutableTodo from './MutableTodo.svelte';
66
7-
export let todos;
7+
let todos = [
8+
{ id: 1, done: true, text: 'wash the car' },
9+
{ id: 2, done: false, text: 'take the dog for a walk' },
10+
{ id: 3, done: false, text: 'mow the lawn' }
11+
];
812
913
function toggle(id) {
1014
todos = todos.map(todo => {

0 commit comments

Comments
 (0)