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
<script lang="ts">
import { Dynamic } from '@inflector/keeno'
import Profile from './Profile.kn'
import Settings from './Settings.kn'
import Stats from './Stats.kn'
const tabs = [
{ id: 'profile', label: 'Profile', component: Profile },
{ id: 'stats', label: 'Stats', component: Stats },
{ id: 'settings', label: 'Settings', component: Settings },
]
const active = state('profile')
const current = derived(() => tabs.find((t) => t.id === active)!)
</script>
<nav role="tablist">
{tabs.map((t) => (
<button key={t.id} role="tab" aria-selected={active === t.id} class={{ on: active === t.id }} onClick={() => active.set(t.id)}>
{t.label}
</button>
))}
</nav>
<div class="panel" role="tabpanel">
<Dynamic component={current.component} user="Ada" />
</div>
<style>
nav {
display: flex;
gap: 2px;
padding: 3px;
border: 1px solid var(--border);
border-radius: 0.625rem;
background: var(--surface);
width: fit-content;
}
nav button {
min-height: 1.75rem;
border: 1px solid transparent;
border-radius: 0.4rem;
background: none;
box-shadow: none;
color: var(--muted);
}
nav button:hover:not(:disabled) {
border-color: transparent;
background: none;
color: var(--fg);
}
nav button.on,
nav button.on:hover:not(:disabled) {
border-color: var(--border);
background: var(--bg);
color: var(--fg);
box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}
.panel {
margin-top: 1rem;
padding: 1rem;
border: 1px solid var(--border);
border-radius: 0.75rem;
min-height: 120px;
}
</style>