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
<script lang="ts">
import { frameworks } from './data'
const query = state('', { debounce: 250 })
const searches = state(0)
const results = derived(() => {
const q = query.trim().toLowerCase()
if (!q) return frameworks
return frameworks.filter((f) => f.name.toLowerCase().includes(q) || f.tagline.toLowerCase().includes(q))
})
update(() => {
if (query) searches.set(searches.peek() + 1)
})
const split = (text: string): [string, string, string] => {
const q = query.trim()
const i = q ? text.toLowerCase().indexOf(q.toLowerCase()) : -1
return i < 0 ? [text, '', ''] : [text.slice(0, i), text.slice(i, i + q.length), text.slice(i + q.length)]
}
</script>
<input type="search" bind:value={query} placeholder="Search frameworks…" />
<p class="stats">{results.length} results · {searches} searches run</p>
<ul>
{results.map((f) => (
<li key={f.name}>
<strong>{split(f.name)[0]}<mark>{split(f.name)[1]}</mark>{split(f.name)[2]}</strong>
<span>{f.tagline}</span>
<small>{f.year}</small>
</li>
))}
</ul>
{results.length === 0 && <p class="empty">No framework matches “{query}”.</p>}
<style>
input {
width: 100%;
font-size: 1rem;
}
.stats {
margin: 0.5rem 0;
font-size: 0.8rem;
color: var(--muted);
}
ul {
list-style: none;
margin: 0;
padding: 0;
display: grid;
gap: 2px;
}
li {
display: grid;
grid-template-columns: 6.5rem 1fr auto;
gap: 0.75rem;
align-items: baseline;
padding: 0.45rem 0.75rem;
border-radius: 8px;
}
li:hover {
background: var(--hover);
}
strong {
font-weight: 500;
}
small {
font-family: var(--font-mono);
font-size: 0.75rem;
}
span,
small,
.empty {
color: var(--muted);
}
mark {
background: color-mix(in srgb, var(--warning) 35%, transparent);
color: inherit;
border-radius: 3px;
}
</style>