| Name | Message | Date |
|---|---|---|
| 📁 [labelIndex] | 1 month ago | |
| 📄 +page.svelte | 1 month ago |
📄
src/routes/guide/+page.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<script lang="ts">
import { resolve } from "$app/paths";
import { historyStore } from "$lib/history";
import { labelsStore } from "$lib/labels";
import PatchBanner from "$lib/components/PatchBanner.svelte";
let search = $state("");
const detectedSet = $derived(new Set($historyStore.map((e) => e.labelIndex)));
const allBirds = $derived($labelsStore.map((label, index) => ({ label, index })));
const filtered = $derived(
search.trim() === ""
? allBirds
: allBirds.filter(
({ label }) =>
label.commonName.toLowerCase().includes(search.toLowerCase()) ||
label.scientificName.toLowerCase().includes(search.toLowerCase()),
),
);
</script>
<PatchBanner text="Field Guide" />
<div class="search-wrap">
<input
type="search"
bind:value={search}
placeholder="Search {$labelsStore.length} species…"
aria-label="Search species"
/>
</div>
{#if $labelsStore.length === 0}
<p class="loading">Loading guide…</p>
{:else}
<div class="grid">
{#each filtered as { label, index } (index)}
{@const detected = detectedSet.has(index)}
{#if detected}
<a href={resolve(`/guide/${index}`)} class="card">
<span class="num">#{String(index + 1).padStart(4, "0")}</span>
<span class="name">{label.commonName}</span>
</a>
{:else}
<div class="card unseen">
<span class="num">#{String(index + 1).padStart(4, "0")}</span>
<span class="name">{label.commonName}</span>
</div>
{/if}
{/each}
</div>
{/if}
<style>
.search-wrap {
padding: 0.75rem 1rem 0;
}
input[type="search"] {
width: 100%;
background: var(--bg-paper);
border: 2px solid var(--bg-near-black);
border-radius: 8px;
padding: 0.6rem 0.75rem;
color: var(--bg-near-black);
font-size: 1rem;
font-family: inherit;
outline: none;
&::placeholder {
color: var(--accent-rust);
opacity: 0.7;
}
&:focus {
outline: 2px solid var(--brand-red);
outline-offset: -2px;
}
}
.loading {
padding: 3rem 1.5rem;
text-align: center;
color: var(--accent-rust);
}
.grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.6rem;
padding: 0.75rem 1rem;
padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 1rem);
}
.card {
background: var(--bg-paper);
border: 2px solid var(--bg-near-black);
border-radius: 8px;
padding: 0.6rem 0.75rem;
position: relative;
display: flex;
flex-direction: column;
gap: 0.2rem;
text-decoration: none;
color: var(--bg-near-black);
content-visibility: auto;
contain-intrinsic-block-size: 5rem;
&::before {
content: "";
position: absolute;
inset: 4px;
border-radius: 4px;
border: 1.5px dashed var(--accent-amber);
pointer-events: none;
}
&.unseen {
opacity: 0.35;
pointer-events: none;
}
&:not(.unseen):hover {
background: var(--bg-cream);
}
.num {
font-size: 0.6rem;
font-variant-numeric: tabular-nums;
color: var(--accent-rust);
font-weight: 700;
letter-spacing: 0.05em;
}
.name {
font-size: 0.8rem;
font-weight: 700;
line-height: 1.3;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
}
</style>