Skip to content

Commit 2c4e0df

Browse files
author
Rich Harris
committed
dark mode styles
1 parent c35016d commit 2c4e0df

File tree

10 files changed

+121
-168
lines changed

10 files changed

+121
-168
lines changed
Lines changed: 1 addition & 1 deletion
Loading

content/tutorial/02-sveltekit/04-forms/04-progressive-enhancement/app-b/src/routes/+page.svelte

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,6 @@
5656
flex: 1;
5757
}
5858
59-
button {
60-
border: none;
61-
background: url(./remove.svg) no-repeat 50% 50%;
62-
background-size: 1rem 1rem;
63-
cursor: pointer;
64-
height: 100%;
65-
aspect-ratio: 1;
66-
opacity: 0.5;
67-
transition: opacity 0.2s;
68-
}
69-
70-
button:hover {
71-
opacity: 1;
72-
}
73-
7459
.saving {
7560
opacity: 0.5;
7661
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ Open `TodoList.svelte`. First, import the `send` and `receive` transitions from
1616
+++import { send, receive } from './transition.js';+++
1717
1818
export let store;
19-
export let filter;
19+
export let done;
2020
</script>
2121
```
2222

23-
Then, add them to the `<label>` element, using the `todo.id` property as a key to match the elements:
23+
Then, add them to the `<li>` element, using the `todo.id` property as a key to match the elements:
2424

2525
```svelte
2626
/// file: TodoList.svelte
27-
<label
27+
<li
28+
class:done
2829
+++in:receive={{ key: todo.id }}+++
2930
+++out:send={{ key: todo.id }}+++
3031
>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525

2626
<div class="todo">
2727
<h2>todo</h2>
28-
<TodoList store={todos} filter={(t) => !t.done} />
28+
<TodoList store={todos} done={false} />
2929
</div>
3030

3131
<div class="done">
3232
<h2>done</h2>
33-
<TodoList store={todos} filter={(t) => t.done} />
33+
<TodoList store={todos} done={true} />
3434
</div>
3535
</div>
3636

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,44 @@
11
<script>
22
export let store;
3-
export let filter;
3+
export let done;
44
</script>
55

6-
{#each $store.filter(filter) as todo (todo.id)}
7-
<label>
8-
<input
9-
type="checkbox"
10-
checked={todo.done}
11-
on:change={(e) => store.mark(todo, e.currentTarget.checked)}
12-
/>
13-
14-
<span>{todo.description}</span>
15-
16-
<button on:click={() => store.remove(todo)} aria-label="Remove" />
17-
</label>
18-
{/each}
6+
<ul class="todos">
7+
{#each $store.filter((todo) => todo.done === done) as todo (todo.id)}
8+
<li
9+
class:done
10+
>
11+
<label>
12+
<input
13+
type="checkbox"
14+
checked={todo.done}
15+
on:change={(e) => store.mark(todo, e.currentTarget.checked)}
16+
/>
17+
18+
<span>{todo.description}</span>
19+
20+
<button on:click={() => store.remove(todo)} aria-label="Remove" />
21+
</label>
22+
</li>
23+
{/each}
24+
</ul>
1925

2026
<style>
2127
label {
22-
position: relative;
28+
width: 100%;
29+
height: 100%;
2330
display: flex;
24-
align-items: center;
25-
padding: 0.6em;
26-
margin: 0 0 0.5em 0;
27-
gap: 0.5em;
28-
border-radius: 5px;
29-
user-select: none;
30-
background: white;
31-
color: var(--label);
32-
filter: var(--filter);
31+
}
32+
33+
.done {
34+
opacity: 0.5;
3335
}
3436
3537
span {
3638
flex: 1;
3739
}
3840
3941
button {
40-
width: 2em;
41-
height: 2em;
42-
border: none;
43-
background: url(./remove.svg) no-repeat 50% 50%;
44-
background-size: 75%;
45-
opacity: 0;
46-
transition: opacity 0.2s;
47-
cursor: pointer;
48-
}
49-
50-
label:hover {
51-
background: #fafafa;
52-
}
53-
54-
label:hover button {
55-
opacity: 0.2;
56-
}
57-
58-
label:hover button:hover {
59-
opacity: 0.5;
42+
background-image: url(./remove.svg);
6043
}
6144
</style>
Lines changed: 1 addition & 1 deletion
Loading

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

Lines changed: 29 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,47 @@
22
import { send, receive } from './transition.js';
33
44
export let store;
5-
export let filter;
5+
export let done;
66
</script>
77

8-
{#each $store.filter(filter) as todo (todo.id)}
9-
<label
10-
in:receive={{ key: todo.id }}
11-
out:send={{ key: todo.id }}
12-
>
13-
<input
14-
type="checkbox"
15-
checked={todo.done}
16-
on:change={(e) => store.mark(todo, e.currentTarget.checked)}
17-
/>
18-
19-
<span>{todo.description}</span>
20-
21-
<button on:click={() => store.remove(todo)} aria-label="Remove" />
22-
</label>
23-
{/each}
8+
<ul class="todos">
9+
{#each $store.filter((todo) => todo.done === done) as todo (todo.id)}
10+
<li
11+
class:done
12+
in:receive={{ key: todo.id }}
13+
out:send={{ key: todo.id }}
14+
>
15+
<label>
16+
<input
17+
type="checkbox"
18+
checked={todo.done}
19+
on:change={(e) => store.mark(todo, e.currentTarget.checked)}
20+
/>
21+
22+
<span>{todo.description}</span>
23+
24+
<button on:click={() => store.remove(todo)} aria-label="Remove" />
25+
</label>
26+
</li>
27+
{/each}
28+
</ul>
2429

2530
<style>
2631
label {
27-
position: relative;
32+
width: 100%;
33+
height: 100%;
2834
display: flex;
29-
align-items: center;
30-
padding: 0.6em;
31-
margin: 0 0 0.5em 0;
32-
gap: 0.5em;
33-
border-radius: 5px;
34-
user-select: none;
35-
background: white;
36-
color: var(--label);
37-
filter: var(--filter);
35+
}
36+
37+
.done {
38+
opacity: 0.5;
3839
}
3940
4041
span {
4142
flex: 1;
4243
}
4344
4445
button {
45-
width: 2em;
46-
height: 2em;
47-
border: none;
48-
background: url(./remove.svg) no-repeat 50% 50%;
49-
background-size: 75%;
50-
opacity: 0;
51-
transition: opacity 0.2s;
52-
cursor: pointer;
53-
}
54-
55-
label:hover {
56-
background: #fafafa;
57-
}
58-
59-
label:hover button {
60-
opacity: 0.2;
61-
}
62-
63-
label:hover button:hover {
64-
opacity: 0.5;
46+
background-image: url(./remove.svg);
6547
}
6648
</style>

content/tutorial/03-advanced-svelte/03-animations/01-animate/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ First, import the `flip` function — flip stands for ['First, Last, Invert, Pla
1515
import { send, receive } from './transition.js';
1616
1717
export let store;
18-
export let filter;
18+
export let done;
1919
</script>
2020
```
2121

22-
Then add it to the `<label>` elements:
22+
Then add it to the `<li>` elements:
2323

2424
```svelte
2525
/// file: TodoList.svelte
26-
<label
26+
<li
27+
class:done
2728
in:receive={{ key: todo.id }}
2829
out:send={{ key: todo.id }}
2930
+++animate:flip+++
@@ -34,7 +35,8 @@ The movement is a little slow in this case, so we can add a `duration` parameter
3435

3536
```svelte
3637
/// file: TodoList.svelte
37-
<label
38+
<li
39+
class:done
3840
in:receive={{ key: todo.id }}
3941
out:send={{ key: todo.id }}
4042
animate:flip+++={{ duration: 200 }}+++

content/tutorial/03-advanced-svelte/03-animations/01-animate/app-b/src/lib/TodoList.svelte

Lines changed: 30 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,66 +3,48 @@
33
import { send, receive } from './transition.js';
44
55
export let store;
6-
export let filter;
6+
export let done;
77
</script>
88

9-
{#each $store.filter(filter) as todo (todo.id)}
10-
<label
11-
in:receive={{ key: todo.id }}
12-
out:send={{ key: todo.id }}
13-
animate:flip={{ duration: 200 }}
14-
>
15-
<input
16-
type="checkbox"
17-
checked={todo.done}
18-
on:change={(e) => store.mark(todo, e.currentTarget.checked)}
19-
/>
20-
21-
<span>{todo.description}</span>
22-
23-
<button on:click={() => store.remove(todo)} aria-label="Remove" />
24-
</label>
25-
{/each}
9+
<ul class="todos">
10+
{#each $store.filter((todo) => todo.done === done) as todo (todo.id)}
11+
<li
12+
class:done
13+
in:receive={{ key: todo.id }}
14+
out:send={{ key: todo.id }}
15+
animate:flip={{ duration: 200 }}
16+
>
17+
<label>
18+
<input
19+
type="checkbox"
20+
checked={todo.done}
21+
on:change={(e) => store.mark(todo, e.currentTarget.checked)}
22+
/>
23+
24+
<span>{todo.description}</span>
25+
26+
<button on:click={() => store.remove(todo)} aria-label="Remove" />
27+
</label>
28+
</li>
29+
{/each}
30+
</ul>
2631

2732
<style>
2833
label {
29-
position: relative;
34+
width: 100%;
35+
height: 100%;
3036
display: flex;
31-
align-items: center;
32-
padding: 0.6em;
33-
margin: 0 0 0.5em 0;
34-
gap: 0.5em;
35-
border-radius: 5px;
36-
user-select: none;
37-
background: white;
38-
color: var(--label);
39-
filter: var(--filter);
37+
}
38+
39+
.done {
40+
opacity: 0.5;
4041
}
4142
4243
span {
4344
flex: 1;
4445
}
4546
4647
button {
47-
width: 2em;
48-
height: 2em;
49-
border: none;
50-
background: url(./remove.svg) no-repeat 50% 50%;
51-
background-size: 75%;
52-
opacity: 0;
53-
transition: opacity 0.2s;
54-
cursor: pointer;
55-
}
56-
57-
label:hover {
58-
background: #fafafa;
59-
}
60-
61-
label:hover button {
62-
opacity: 0.2;
63-
}
64-
65-
label:hover button:hover {
66-
opacity: 0.5;
48+
background-image: url(./remove.svg);
6749
}
6850
</style>

0 commit comments

Comments
 (0)