Skip to content

Commit d683b28

Browse files
author
Rich Harris
committed
fix, tidy up
1 parent 96b96e6 commit d683b28

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

content/tutorial/03-advanced-svelte/02-transitions/09-deferred-transitions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A particularly powerful feature of Svelte's transition engine is the ability to
66

77
Take this pair of todo lists, in which toggling a todo sends it to the opposite list. In the real world, objects don't behave like that — instead of disappearing and reappearing in another place, they move through a series of intermediate positions. Using motion can go a long way towards helping users understand what's happening in your app.
88

9-
We can achieve this effect using the `crossfade` function, as seen in transition.js, which creates a pair of transitions called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used.
9+
We can achieve this effect using the `crossfade` function, as seen in `transition.js`, which creates a pair of transitions called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used.
1010

1111
Open `TodoList.svelte`. First, import the `send` and `receive` transitions from transition.js:
1212

content/tutorial/03-advanced-svelte/02-transitions/09-deferred-transitions/app-a/src/lib/TodoList.svelte

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@
1313

1414
<span>{todo.description}</span>
1515

16-
<button on:click={() => store.remove(todo)}>
17-
<svg viewBox="0 0 24 24">
18-
<path fill="currentColor" stroke="none" d="M22 4.2h-5.6L15 1.6c-.1-.2-.4-.4-.7-.4H9.6c-.2 0-.5.2-.6.4L7.6 4.2H2c-.4 0-.8.4-.8.8s.4.8.8.8h1.8V22c0 .4.3.8.8.8h15c.4 0 .8-.3.8-.8V5.8H22c.4 0 .8-.3.8-.8s-.4-.8-.8-.8zM10.8 16.5c0 .4-.3.8-.8.8s-.8-.3-.8-.8V10c0-.4.3-.8.8-.8s.8.3.8.8v6.5zm4 0c0 .4-.3.8-.8.8s-.8-.3-.8-.8V10c0-.4.3-.8.8-.8s.8.3.8.8v6.5z" />
19-
</svg>
20-
</button>
16+
<button on:click={() => store.remove(todo)} aria-label="Remove" />
2117
</label>
2218
{/each}
2319

@@ -42,8 +38,10 @@
4238
4339
button {
4440
width: 2em;
41+
height: 2em;
4542
border: none;
46-
background: none;
43+
background: url(./remove.svg) no-repeat 50% 50%;
44+
background-size: 75%;
4745
opacity: 0;
4846
transition: opacity 0.2s;
4947
cursor: pointer;
@@ -54,6 +52,10 @@
5452
}
5553
5654
label:hover button {
57-
opacity: 0.7;
55+
opacity: 0.2;
56+
}
57+
58+
label:hover button:hover {
59+
opacity: 0.5;
5860
}
5961
</style>
Lines changed: 3 additions & 0 deletions
Loading

content/tutorial/03-advanced-svelte/02-transitions/09-deferred-transitions/app-b/src/lib/TodoList.svelte

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
</script>
77

88
{#each $store.filter(filter) as todo (todo.id)}
9-
<label in:receive={{ key: todo.id }} out:send={{ key: todo.id }}>
9+
<label
10+
in:receive={{ key: todo.id }}
11+
out:send={{ key: todo.id }}
12+
>
1013
<input
1114
type="checkbox"
1215
checked={todo.done}
@@ -15,11 +18,7 @@
1518

1619
<span>{todo.description}</span>
1720

18-
<button on:click={() => store.remove(todo)}>
19-
<svg viewBox="0 0 24 24">
20-
<path fill="currentColor" stroke="none" d="M22 4.2h-5.6L15 1.6c-.1-.2-.4-.4-.7-.4H9.6c-.2 0-.5.2-.6.4L7.6 4.2H2c-.4 0-.8.4-.8.8s.4.8.8.8h1.8V22c0 .4.3.8.8.8h15c.4 0 .8-.3.8-.8V5.8H22c.4 0 .8-.3.8-.8s-.4-.8-.8-.8zM10.8 16.5c0 .4-.3.8-.8.8s-.8-.3-.8-.8V10c0-.4.3-.8.8-.8s.8.3.8.8v6.5zm4 0c0 .4-.3.8-.8.8s-.8-.3-.8-.8V10c0-.4.3-.8.8-.8s.8.3.8.8v6.5z" />
21-
</svg>
22-
</button>
21+
<button on:click={() => store.remove(todo)} aria-label="Remove" />
2322
</label>
2423
{/each}
2524

@@ -44,8 +43,10 @@
4443
4544
button {
4645
width: 2em;
46+
height: 2em;
4747
border: none;
48-
background: none;
48+
background: url(./remove.svg) no-repeat 50% 50%;
49+
background-size: 75%;
4950
opacity: 0;
5051
transition: opacity 0.2s;
5152
cursor: pointer;
@@ -56,6 +57,10 @@
5657
}
5758
5859
label:hover button {
59-
opacity: 0.7;
60+
opacity: 0.2;
61+
}
62+
63+
label:hover button:hover {
64+
opacity: 0.5;
6065
}
6166
</style>

0 commit comments

Comments
 (0)