forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_TableOfContents.svelte
98 lines (87 loc) · 1.78 KB
/
_TableOfContents.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<script>
export let sections = [];
export let active_section = null;
export let isLoading = false;
</script>
<style>
.examples-toc {
overflow-y: auto;
height: 100%;
border-right: 1px solid var(--second);
background-color: var(--second);
color: white;
padding: 3rem 3rem 0 3rem;
}
.examples-toc li {
display: block;
line-height: 1.2;
margin: 0 0 4.8rem 0;
}
.section-title {
display: block;
padding: 0 0 0.8rem 0;
font: 400 var(--h6) var(--font);
text-transform: uppercase;
letter-spacing: 0.12em;
font-weight: 700;
}
a {
display: flex;
position: relative;
color: var(--sidebar-text);
border-bottom: none;
padding: 0.2rem 3rem;
margin: 0 -3rem;
font-size: 1.6rem;
align-items: center;
justify-content: start;
}
a:hover {
color: white;
}
a.active {
background: rgba(0, 0, 0, 0.15) calc(100% - 3rem) 50% no-repeat
url(/icons/arrow-right.svg);
background-size: 1em 1em;
color: white;
}
a.active.loading {
background: rgba(0, 0, 0, 0.1) calc(100% - 3rem) 50% no-repeat
url(/icons/loading.svg);
background-size: 1em 1em;
color: white;
}
.thumbnail {
background-color: white;
object-fit: contain;
width: 5rem;
height: 5rem;
border-radius: 2px;
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.13);
margin: 0.2em 0.5em 0.2em 0;
}
</style>
<ul class="examples-toc">
{#each sections as section}
<li>
<span class="section-title">
{section.title}
</span>
{#each section.examples as example}
<a
href="examples#{example.slug}"
class="row"
class:active="{example.slug === active_section}"
class:loading="{isLoading}"
>
<img
class="thumbnail"
alt="{example.title} thumbnail"
src="examples/thumbnails/{example.slug}.jpg"
/>
<span>{example.title}</span>
</a>
{/each}
</li>
{/each}
</ul>