mirror of https://github.com/sveltejs/svelte
parent
2aece987c3
commit
1830d57b4c
@ -1,3 +1,3 @@
|
|||||||
<!-- https://github.com/eugenkiss/7guis/wiki#counter -->
|
<!-- https://github.com/eugenkiss/7guis/wiki#counter -->
|
||||||
<input type='number' bind:value='count'>
|
<input type=number bind:value={count}>
|
||||||
<button on:click='set({ count: count + 1 })'>count</button>
|
<button on:click="{() => count += 1}">count</button>
|
@ -1,15 +1,15 @@
|
|||||||
<label>
|
<label>
|
||||||
<input type='checkbox' bind:group='selected' value='red'>
|
<input type=checkbox bind:group={selected} value="red">
|
||||||
red
|
red
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<input type='checkbox' bind:group='selected' value='green'>
|
<input type=checkbox bind:group={selected} value="green">
|
||||||
green
|
green
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<input type='checkbox' bind:group='selected' value='blue'>
|
<input type=checkbox bind:group={selected} value="blue">
|
||||||
blue
|
blue
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
<label>
|
<label>
|
||||||
<input type='radio' bind:group='selected' value='red'>
|
<input type=radio bind:group={selected} value="red">
|
||||||
red
|
red
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<input type='radio' bind:group='selected' value='green'>
|
<input type=radio bind:group={selected} value="green">
|
||||||
green
|
green
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<input type='radio' bind:group='selected' value='blue'>
|
<input type=radio bind:group={selected} value="blue">
|
||||||
blue
|
blue
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<p style='color: {selected};'>selected {selected}</p>
|
<p style="color: {selected};">selected {selected}</p>
|
@ -1,2 +1,2 @@
|
|||||||
<input bind:value='name' placeholder='enter your name'>
|
<input bind:value={name} placeholder="enter your name">
|
||||||
<p>Hello {name || 'stranger'}!</p>
|
<p>Hello {name || 'stranger'}!</p>
|
@ -1,19 +1,15 @@
|
|||||||
<textarea bind:value='markdown' resize='none'></textarea>
|
<script>
|
||||||
<div class='output'>{@html marked(markdown)}</div>
|
import marked from 'marked';
|
||||||
|
|
||||||
|
export let markdown;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<textarea bind:value={markdown} resize="none"></textarea>
|
||||||
|
<div class="output">{@html marked(markdown)}</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
textarea {
|
textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 50%;
|
height: 50%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
|
||||||
import marked from 'marked';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
helpers: {
|
|
||||||
marked
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@ -1,17 +1,19 @@
|
|||||||
<!-- the text will flash red whenever
|
<svelte:meta immutable/>
|
||||||
the `todo` object changes -->
|
|
||||||
<span ref:span>{todo.text}</span>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
import { afterRender } from 'svelte';
|
||||||
// try commenting this out
|
|
||||||
immutable: true,
|
export let todo;
|
||||||
|
let span;
|
||||||
|
|
||||||
onupdate({ changed, current, previous }) {
|
afterRender(() => {
|
||||||
this.refs.span.style.color = 'red';
|
span.style.color = 'red';
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.refs.span.style.color = 'black';
|
span.style.color = 'black';
|
||||||
}, 400);
|
}, 400);
|
||||||
}
|
});
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<!-- the text will flash red whenever
|
||||||
|
the `todo` object changes -->
|
||||||
|
<span ref:span>{todo.text}</span>
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
<span ref:span>{todo.text}</span>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
import { afterRender } from 'svelte';
|
||||||
immutable: false,
|
|
||||||
|
export let todo;
|
||||||
|
let span;
|
||||||
|
|
||||||
onupdate({ changed, current, previous }) {
|
afterRender(() => {
|
||||||
this.refs.span.style.color = 'red';
|
span.style.color = 'red';
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.refs.span.style.color = 'black';
|
span.style.color = 'black';
|
||||||
}, 400);
|
}, 400);
|
||||||
}
|
});
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<!-- the text will flash red whenever
|
||||||
|
the `todo` object changes -->
|
||||||
|
<span ref:span>{todo.text}</span>
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
<p>This is a top-level element.</p>
|
|
||||||
<Nested/>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Nested from './Nested.html';
|
import Nested from './Nested.html';
|
||||||
|
</script>
|
||||||
|
|
||||||
export default {
|
<p>This is a top-level element.</p>
|
||||||
components: {
|
<Nested/>
|
||||||
Nested
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
@ -1,13 +1,11 @@
|
|||||||
<input type='checkbox' bind:checked=visible> visible
|
|
||||||
|
|
||||||
{#if visible}
|
|
||||||
<p transition:fade>fades in and out</p>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fade } from 'svelte-transitions';
|
import { fade } from 'svelte-transitions';
|
||||||
|
|
||||||
export default {
|
export let visible;
|
||||||
transitions: { fade }
|
</script>
|
||||||
};
|
|
||||||
</script>
|
<input type=checkbox bind:checked={visible}> visible
|
||||||
|
|
||||||
|
{#if visible}
|
||||||
|
<p transition:fade>fades in and out</p>
|
||||||
|
{/if}
|
@ -1,13 +1,11 @@
|
|||||||
<input type='checkbox' bind:checked=visible> visible
|
|
||||||
|
|
||||||
{#if visible}
|
|
||||||
<p transition:fly='{y: 200, duration: 1000}'>flies 200 pixels up, slowly</p>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fly } from 'svelte-transitions';
|
import { fly } from 'svelte-transitions';
|
||||||
|
|
||||||
export default {
|
export let visible;
|
||||||
transitions: { fly }
|
</script>
|
||||||
};
|
|
||||||
</script>
|
<input type=checkbox bind:checked={visible}> visible
|
||||||
|
|
||||||
|
{#if visible}
|
||||||
|
<p transition:fly="{{y: 200, duration: 1000}}">flies 200 pixels up, slowly</p>
|
||||||
|
{/if}
|
@ -1,13 +1,11 @@
|
|||||||
<input type='checkbox' bind:checked=visible> visible
|
|
||||||
|
|
||||||
{#if visible}
|
|
||||||
<p in:fly='{y: 50}' out:fade>flies up, fades out</p>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fade, fly } from 'svelte-transitions';
|
import { fade, fly } from 'svelte-transitions';
|
||||||
|
|
||||||
export default {
|
export let visible;
|
||||||
transitions: { fade, fly }
|
</script>
|
||||||
};
|
|
||||||
</script>
|
<input type=checkbox bind:checked={visible}> visible
|
||||||
|
|
||||||
|
{#if visible}
|
||||||
|
<p in:fly="{{y: 50}}" out:fade>flies up, fades out</p>
|
||||||
|
{/if}
|
Loading…
Reference in new issue