@nqmcreative/ui 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -15
- package/cli/index.mjs +81 -42
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/toast.svelte.d.ts +3 -0
- package/dist/core/trigger.d.ts +6 -0
- package/dist/core/trigger.js +13 -0
- package/dist/styles/matte/AccordionItem.svelte +5 -0
- package/dist/styles/matte/AccordionItem.svelte.d.ts +2 -0
- package/dist/styles/matte/Avatar.svelte +15 -0
- package/dist/styles/matte/Avatar.svelte.d.ts +3 -0
- package/dist/styles/matte/Badge.svelte +5 -0
- package/dist/styles/matte/Badge.svelte.d.ts +2 -0
- package/dist/styles/matte/Breadcrumb.svelte +11 -4
- package/dist/styles/matte/Breadcrumb.svelte.d.ts +3 -0
- package/dist/styles/matte/Button.svelte +62 -11
- package/dist/styles/matte/Button.svelte.d.ts +14 -2
- package/dist/styles/matte/Card.svelte +9 -4
- package/dist/styles/matte/Card.svelte.d.ts +2 -0
- package/dist/styles/matte/CheckboxGroup.svelte +6 -0
- package/dist/styles/matte/CheckboxGroup.svelte.d.ts +2 -0
- package/dist/styles/matte/Combobox.svelte +7 -2
- package/dist/styles/matte/Combobox.svelte.d.ts +3 -0
- package/dist/styles/matte/CommandPalette.svelte +38 -7
- package/dist/styles/matte/CommandPalette.svelte.d.ts +8 -0
- package/dist/styles/matte/DatePicker.svelte +2 -2
- package/dist/styles/matte/Drawer.svelte +7 -2
- package/dist/styles/matte/Drawer.svelte.d.ts +2 -0
- package/dist/styles/matte/Dropzone.svelte +1 -1
- package/dist/styles/matte/FeatureCard.svelte +1 -1
- package/dist/styles/matte/Footer.svelte +6 -2
- package/dist/styles/matte/Footer.svelte.d.ts +2 -0
- package/dist/styles/matte/Input.svelte +4 -4
- package/dist/styles/matte/Link.svelte +9 -0
- package/dist/styles/matte/Link.svelte.d.ts +4 -0
- package/dist/styles/matte/MenuItem.svelte +3 -2
- package/dist/styles/matte/Modal.svelte +8 -3
- package/dist/styles/matte/Modal.svelte.d.ts +2 -0
- package/dist/styles/matte/MultiSelect.svelte +7 -1
- package/dist/styles/matte/MultiSelect.svelte.d.ts +3 -0
- package/dist/styles/matte/Navbar.svelte +18 -4
- package/dist/styles/matte/Navbar.svelte.d.ts +2 -0
- package/dist/styles/matte/PricingCard.svelte +19 -11
- package/dist/styles/matte/PricingCard.svelte.d.ts +2 -0
- package/dist/styles/matte/RadioGroup.svelte +6 -0
- package/dist/styles/matte/RadioGroup.svelte.d.ts +2 -0
- package/dist/styles/matte/SegmentedControl.svelte +17 -3
- package/dist/styles/matte/SegmentedControl.svelte.d.ts +5 -0
- package/dist/styles/matte/Select.svelte +1 -1
- package/dist/styles/matte/Sidebar.svelte +76 -26
- package/dist/styles/matte/Sidebar.svelte.d.ts +15 -1
- package/dist/styles/matte/Stat.svelte +8 -1
- package/dist/styles/matte/Stat.svelte.d.ts +3 -0
- package/dist/styles/matte/StatsBand.svelte +1 -1
- package/dist/styles/matte/Steps.svelte +7 -0
- package/dist/styles/matte/Steps.svelte.d.ts +3 -0
- package/dist/styles/matte/Table.svelte +154 -98
- package/dist/styles/matte/Table.svelte.d.ts +12 -0
- package/dist/styles/matte/Tabs.svelte +5 -0
- package/dist/styles/matte/Tabs.svelte.d.ts +3 -0
- package/dist/styles/matte/Testimonial.svelte +2 -2
- package/dist/styles/matte/Textarea.svelte +1 -1
- package/dist/styles/matte/Toaster.svelte +3 -0
- package/dist/styles/matte/icon.d.ts +21 -0
- package/dist/styles/matte/icon.js +21 -0
- package/dist/styles/matte/index.d.ts +1 -3
- package/dist/styles/matte/index.js +0 -2
- package/dist/styles/paper/AccordionItem.svelte +5 -0
- package/dist/styles/paper/AccordionItem.svelte.d.ts +2 -0
- package/dist/styles/paper/Avatar.svelte +15 -0
- package/dist/styles/paper/Avatar.svelte.d.ts +3 -0
- package/dist/styles/paper/Badge.svelte +5 -0
- package/dist/styles/paper/Badge.svelte.d.ts +2 -0
- package/dist/styles/paper/Breadcrumb.svelte +8 -4
- package/dist/styles/paper/Breadcrumb.svelte.d.ts +3 -0
- package/dist/styles/paper/Button.svelte +58 -7
- package/dist/styles/paper/Button.svelte.d.ts +14 -2
- package/dist/styles/paper/Card.svelte +6 -1
- package/dist/styles/paper/Card.svelte.d.ts +2 -0
- package/dist/styles/paper/CheckboxGroup.svelte +6 -0
- package/dist/styles/paper/CheckboxGroup.svelte.d.ts +2 -0
- package/dist/styles/paper/Combobox.svelte +5 -0
- package/dist/styles/paper/Combobox.svelte.d.ts +3 -0
- package/dist/styles/paper/CommandPalette.svelte +31 -2
- package/dist/styles/paper/CommandPalette.svelte.d.ts +8 -0
- package/dist/styles/paper/Drawer.svelte +5 -0
- package/dist/styles/paper/Drawer.svelte.d.ts +2 -0
- package/dist/styles/paper/Footer.svelte +6 -2
- package/dist/styles/paper/Footer.svelte.d.ts +2 -0
- package/dist/styles/paper/Link.svelte +9 -0
- package/dist/styles/paper/Link.svelte.d.ts +4 -0
- package/dist/styles/paper/MenuItem.svelte +2 -1
- package/dist/styles/paper/Modal.svelte +14 -1
- package/dist/styles/paper/Modal.svelte.d.ts +2 -0
- package/dist/styles/paper/MultiSelect.svelte +7 -1
- package/dist/styles/paper/MultiSelect.svelte.d.ts +3 -0
- package/dist/styles/paper/Navbar.svelte +18 -4
- package/dist/styles/paper/Navbar.svelte.d.ts +2 -0
- package/dist/styles/paper/PricingCard.svelte +23 -15
- package/dist/styles/paper/PricingCard.svelte.d.ts +2 -0
- package/dist/styles/paper/RadioGroup.svelte +6 -0
- package/dist/styles/paper/RadioGroup.svelte.d.ts +2 -0
- package/dist/styles/paper/SegmentedControl.svelte +16 -2
- package/dist/styles/paper/SegmentedControl.svelte.d.ts +5 -0
- package/dist/styles/paper/Sidebar.svelte +76 -26
- package/dist/styles/paper/Sidebar.svelte.d.ts +15 -1
- package/dist/styles/paper/Stat.svelte +8 -1
- package/dist/styles/paper/Stat.svelte.d.ts +3 -0
- package/dist/styles/paper/Steps.svelte +7 -0
- package/dist/styles/paper/Steps.svelte.d.ts +3 -0
- package/dist/styles/paper/Table.svelte +153 -97
- package/dist/styles/paper/Table.svelte.d.ts +12 -0
- package/dist/styles/paper/Tabs.svelte +5 -0
- package/dist/styles/paper/Tabs.svelte.d.ts +3 -0
- package/dist/styles/paper/Toaster.svelte +3 -0
- package/dist/styles/paper/fonts.css +34 -7
- package/dist/styles/paper/icon.d.ts +21 -0
- package/dist/styles/paper/icon.js +21 -0
- package/dist/styles/paper/index.d.ts +1 -3
- package/dist/styles/paper/index.js +0 -2
- package/dist/styles/paper/theme.css +11 -8
- package/dist/styles/sprout/AccordionItem.svelte +5 -0
- package/dist/styles/sprout/AccordionItem.svelte.d.ts +2 -0
- package/dist/styles/sprout/Avatar.svelte +15 -0
- package/dist/styles/sprout/Avatar.svelte.d.ts +3 -0
- package/dist/styles/sprout/Badge.svelte +5 -0
- package/dist/styles/sprout/Badge.svelte.d.ts +2 -0
- package/dist/styles/sprout/Breadcrumb.svelte +8 -4
- package/dist/styles/sprout/Breadcrumb.svelte.d.ts +3 -0
- package/dist/styles/sprout/Button.svelte +58 -7
- package/dist/styles/sprout/Button.svelte.d.ts +14 -2
- package/dist/styles/sprout/Card.svelte +6 -1
- package/dist/styles/sprout/Card.svelte.d.ts +2 -0
- package/dist/styles/sprout/CheckboxGroup.svelte +6 -0
- package/dist/styles/sprout/CheckboxGroup.svelte.d.ts +2 -0
- package/dist/styles/sprout/Combobox.svelte +5 -0
- package/dist/styles/sprout/Combobox.svelte.d.ts +3 -0
- package/dist/styles/sprout/CommandPalette.svelte +31 -2
- package/dist/styles/sprout/CommandPalette.svelte.d.ts +8 -0
- package/dist/styles/sprout/Drawer.svelte +5 -0
- package/dist/styles/sprout/Drawer.svelte.d.ts +2 -0
- package/dist/styles/sprout/Footer.svelte +6 -2
- package/dist/styles/sprout/Footer.svelte.d.ts +2 -0
- package/dist/styles/sprout/Link.svelte +9 -0
- package/dist/styles/sprout/Link.svelte.d.ts +4 -0
- package/dist/styles/sprout/MenuItem.svelte +2 -1
- package/dist/styles/sprout/Modal.svelte +14 -1
- package/dist/styles/sprout/Modal.svelte.d.ts +2 -0
- package/dist/styles/sprout/MultiSelect.svelte +7 -1
- package/dist/styles/sprout/MultiSelect.svelte.d.ts +3 -0
- package/dist/styles/sprout/Navbar.svelte +18 -4
- package/dist/styles/sprout/Navbar.svelte.d.ts +2 -0
- package/dist/styles/sprout/PricingCard.svelte +23 -15
- package/dist/styles/sprout/PricingCard.svelte.d.ts +2 -0
- package/dist/styles/sprout/RadioGroup.svelte +6 -0
- package/dist/styles/sprout/RadioGroup.svelte.d.ts +2 -0
- package/dist/styles/sprout/SegmentedControl.svelte +16 -2
- package/dist/styles/sprout/SegmentedControl.svelte.d.ts +5 -0
- package/dist/styles/sprout/Sidebar.svelte +76 -26
- package/dist/styles/sprout/Sidebar.svelte.d.ts +15 -1
- package/dist/styles/sprout/Stat.svelte +8 -1
- package/dist/styles/sprout/Stat.svelte.d.ts +3 -0
- package/dist/styles/sprout/Steps.svelte +7 -0
- package/dist/styles/sprout/Steps.svelte.d.ts +3 -0
- package/dist/styles/sprout/Table.svelte +153 -97
- package/dist/styles/sprout/Table.svelte.d.ts +12 -0
- package/dist/styles/sprout/Tabs.svelte +5 -0
- package/dist/styles/sprout/Tabs.svelte.d.ts +3 -0
- package/dist/styles/sprout/Toaster.svelte +3 -0
- package/dist/styles/sprout/fonts.css +7 -8
- package/dist/styles/sprout/icon.d.ts +21 -0
- package/dist/styles/sprout/icon.js +21 -0
- package/dist/styles/sprout/index.d.ts +1 -3
- package/dist/styles/sprout/index.js +0 -2
- package/dist/styles/sprout/theme.css +6 -6
- package/package.json +2 -26
- package/registry.json +3 -36
- package/dist/styles/matte/NumberInput.svelte +0 -96
- package/dist/styles/matte/NumberInput.svelte.d.ts +0 -15
- package/dist/styles/matte/PasswordInput.svelte +0 -95
- package/dist/styles/matte/PasswordInput.svelte.d.ts +0 -12
- package/dist/styles/paper/NumberInput.svelte +0 -96
- package/dist/styles/paper/NumberInput.svelte.d.ts +0 -15
- package/dist/styles/paper/PasswordInput.svelte +0 -100
- package/dist/styles/paper/PasswordInput.svelte.d.ts +0 -12
- package/dist/styles/sprout/NumberInput.svelte +0 -97
- package/dist/styles/sprout/NumberInput.svelte.d.ts +0 -15
- package/dist/styles/sprout/PasswordInput.svelte +0 -101
- package/dist/styles/sprout/PasswordInput.svelte.d.ts +0 -12
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export interface NavItem {
|
|
3
3
|
label: string;
|
|
4
4
|
href?: string;
|
|
5
|
+
/** Leading icon, 16px. */
|
|
6
|
+
icon?: Snippet;
|
|
5
7
|
/** Marks the current page — also sets `aria-current`. */
|
|
6
8
|
active?: boolean;
|
|
7
9
|
disabled?: boolean;
|
|
@@ -15,6 +17,7 @@
|
|
|
15
17
|
<script lang="ts">
|
|
16
18
|
import type { Snippet } from 'svelte';
|
|
17
19
|
import { useLocale } from '../../core/locale.svelte.js';
|
|
20
|
+
import { iconMd } from './icon.js';
|
|
18
21
|
import { focusRing, toneRing, toneSoft, toneText, type Tone } from '../../core/tones.js';
|
|
19
22
|
import Drawer from './Drawer.svelte';
|
|
20
23
|
import Dropdown from './Dropdown.svelte';
|
|
@@ -84,6 +87,7 @@
|
|
|
84
87
|
? `${toneSoft[tone]}`
|
|
85
88
|
: 'text-text-secondary hover:bg-bg-inset hover:text-text'}"
|
|
86
89
|
>
|
|
90
|
+
{#if item.icon}<span class={iconMd}>{@render item.icon()}</span>{/if}
|
|
87
91
|
{item.label}
|
|
88
92
|
<svg class="size-3" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
89
93
|
<path
|
|
@@ -96,7 +100,12 @@
|
|
|
96
100
|
</button>
|
|
97
101
|
{/snippet}
|
|
98
102
|
{#each item.items as child (child.label)}
|
|
99
|
-
<MenuItem
|
|
103
|
+
<MenuItem
|
|
104
|
+
href={child.href}
|
|
105
|
+
disabled={child.disabled}
|
|
106
|
+
selected={child.active}
|
|
107
|
+
icon={child.icon}
|
|
108
|
+
>
|
|
100
109
|
{child.label}
|
|
101
110
|
</MenuItem>
|
|
102
111
|
{/each}
|
|
@@ -111,6 +120,7 @@
|
|
|
111
120
|
? 'pointer-events-none opacity-50'
|
|
112
121
|
: ''}"
|
|
113
122
|
>
|
|
123
|
+
{#if item.icon}<span class={iconMd}>{@render item.icon()}</span>{/if}
|
|
114
124
|
{item.label}
|
|
115
125
|
{#if item.badge !== undefined}
|
|
116
126
|
<span class="text-[11px] text-text-muted tabular-nums">{item.badge}</span>
|
|
@@ -163,7 +173,10 @@
|
|
|
163
173
|
? 'pointer-events-none opacity-50'
|
|
164
174
|
: ''}"
|
|
165
175
|
>
|
|
166
|
-
|
|
176
|
+
<span class="flex min-w-0 items-center gap-2.5">
|
|
177
|
+
{#if item.icon}<span class={iconMd}>{@render item.icon()}</span>{/if}
|
|
178
|
+
{item.label}
|
|
179
|
+
</span>
|
|
167
180
|
{#if item.badge !== undefined}
|
|
168
181
|
<span class="text-[11px] text-text-muted tabular-nums">{item.badge}</span>
|
|
169
182
|
{/if}
|
|
@@ -175,11 +188,12 @@
|
|
|
175
188
|
<a
|
|
176
189
|
href={child.href}
|
|
177
190
|
onclick={() => (menuOpen = false)}
|
|
178
|
-
class="
|
|
191
|
+
class="flex items-center gap-2.5 rounded-xl px-3 py-2 font-sans text-[13px] text-text-muted hover:bg-bg-inset {toneText[
|
|
179
192
|
tone
|
|
180
193
|
]}"
|
|
181
194
|
>
|
|
182
|
-
{child.
|
|
195
|
+
{#if child.icon}<span class={iconMd}>{@render child.icon()}</span
|
|
196
|
+
>{/if}{child.label}
|
|
183
197
|
</a>
|
|
184
198
|
</li>
|
|
185
199
|
{/each}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
4
|
import { toneBorder, toneSoft, toneSolid, type Tone } from '../../core/tones.js';
|
|
5
|
+
import { iconMd } from './icon.js';
|
|
5
6
|
import { edge, soft } from './lift.js';
|
|
6
7
|
|
|
7
8
|
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
@@ -13,6 +14,8 @@
|
|
|
13
14
|
description?: string;
|
|
14
15
|
/** One line each. Rendered with a tick. */
|
|
15
16
|
features?: string[];
|
|
17
|
+
/** Replaces the tick beside every feature. */
|
|
18
|
+
featureIcon?: Snippet;
|
|
16
19
|
/** Pill in the top corner, e.g. "Most popular". */
|
|
17
20
|
badge?: string;
|
|
18
21
|
/** Ring, lift and a tinted header — for the plan you want chosen. */
|
|
@@ -30,6 +33,7 @@
|
|
|
30
33
|
period,
|
|
31
34
|
description,
|
|
32
35
|
features = [],
|
|
36
|
+
featureIcon,
|
|
33
37
|
badge,
|
|
34
38
|
featured = false,
|
|
35
39
|
tone = 'brand',
|
|
@@ -78,21 +82,25 @@
|
|
|
78
82
|
<ul class="flex flex-1 flex-col gap-3 border-t border-hairline p-6">
|
|
79
83
|
{#each features as feature (feature)}
|
|
80
84
|
<li class="flex items-start gap-3 font-sans text-sm text-text-secondary">
|
|
81
|
-
|
|
82
|
-
class="mt-0.5
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
85
|
+
{#if featureIcon}
|
|
86
|
+
<span class="mt-0.5 {iconMd}">{@render featureIcon()}</span>
|
|
87
|
+
{:else}
|
|
88
|
+
<span
|
|
89
|
+
class="mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full {toneSoft[
|
|
90
|
+
tone
|
|
91
|
+
]}"
|
|
92
|
+
>
|
|
93
|
+
<svg class="size-2.5" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
94
|
+
<path
|
|
95
|
+
d="m3 8 3.2 3.2L13 4.4"
|
|
96
|
+
stroke="currentColor"
|
|
97
|
+
stroke-width="2.4"
|
|
98
|
+
stroke-linecap="round"
|
|
99
|
+
stroke-linejoin="round"
|
|
100
|
+
/>
|
|
101
|
+
</svg>
|
|
102
|
+
</span>
|
|
103
|
+
{/if}
|
|
96
104
|
<span class="leading-snug">{feature}</span>
|
|
97
105
|
</li>
|
|
98
106
|
{/each}
|
|
@@ -10,6 +10,8 @@ interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
|
10
10
|
description?: string;
|
|
11
11
|
/** One line each. Rendered with a tick. */
|
|
12
12
|
features?: string[];
|
|
13
|
+
/** Replaces the tick beside every feature. */
|
|
14
|
+
featureIcon?: Snippet;
|
|
13
15
|
/** Pill in the top corner, e.g. "Most popular". */
|
|
14
16
|
badge?: string;
|
|
15
17
|
/** Ring, lift and a tinted header — for the plan you want chosen. */
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
import type { HTMLFieldsetAttributes } from 'svelte/elements';
|
|
4
4
|
import Radio from './Radio.svelte';
|
|
5
5
|
import { toneBorder, toneSurface, type Tone } from '../../core/tones.js';
|
|
6
|
+
import { iconLg } from './icon.js';
|
|
6
7
|
import { edge } from './lift.js';
|
|
7
8
|
|
|
8
9
|
export interface RadioOption {
|
|
9
10
|
value: string;
|
|
10
11
|
label: string;
|
|
12
|
+
/** Leading icon, 20px. Drawn in `boxed` mode only. */
|
|
13
|
+
icon?: Snippet;
|
|
11
14
|
description?: string;
|
|
12
15
|
disabled?: boolean;
|
|
13
16
|
}
|
|
@@ -63,6 +66,9 @@
|
|
|
63
66
|
: 'border-hairline bg-bg hover:border-hairline-strong'}
|
|
64
67
|
{option.disabled ? 'pointer-events-none opacity-50' : ''}"
|
|
65
68
|
>
|
|
69
|
+
{#if option.icon}
|
|
70
|
+
<span class={iconLg}>{@render option.icon()}</span>
|
|
71
|
+
{/if}
|
|
66
72
|
<Radio
|
|
67
73
|
bind:group={value}
|
|
68
74
|
value={option.value}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
2
3
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
4
|
import { focusRing, toneRing, type Tone } from '../../core/tones.js';
|
|
5
|
+
import { iconMd } from './icon.js';
|
|
4
6
|
import { edge } from './lift.js';
|
|
5
7
|
|
|
6
8
|
export interface SegmentOption {
|
|
7
9
|
value: string;
|
|
8
10
|
label: string;
|
|
11
|
+
/** Leading icon, 16px. */
|
|
12
|
+
icon?: Snippet;
|
|
9
13
|
disabled?: boolean;
|
|
10
14
|
}
|
|
11
15
|
|
|
@@ -21,6 +25,8 @@
|
|
|
21
25
|
tone?: Tone;
|
|
22
26
|
/** Spread the segments evenly across the full width. */
|
|
23
27
|
fullWidth?: boolean;
|
|
28
|
+
/** Icons only — each option's `label` becomes its accessible name. */
|
|
29
|
+
iconOnly?: boolean;
|
|
24
30
|
label?: string;
|
|
25
31
|
disabled?: boolean;
|
|
26
32
|
onchange?: (value: string) => void;
|
|
@@ -33,6 +39,7 @@
|
|
|
33
39
|
size = 'md',
|
|
34
40
|
tone = 'brand',
|
|
35
41
|
fullWidth = false,
|
|
42
|
+
iconOnly = false,
|
|
36
43
|
label,
|
|
37
44
|
disabled = false,
|
|
38
45
|
class: className = '',
|
|
@@ -45,6 +52,11 @@
|
|
|
45
52
|
md: 'h-8 px-3.5 text-sm'
|
|
46
53
|
};
|
|
47
54
|
|
|
55
|
+
const squares: Record<SegmentedSize, string> = {
|
|
56
|
+
sm: 'size-7 text-[13px]',
|
|
57
|
+
md: 'size-8 text-sm'
|
|
58
|
+
};
|
|
59
|
+
|
|
48
60
|
function select(option: SegmentOption) {
|
|
49
61
|
if (option.disabled || disabled) return;
|
|
50
62
|
value = option.value;
|
|
@@ -75,14 +87,16 @@
|
|
|
75
87
|
type="button"
|
|
76
88
|
role="radio"
|
|
77
89
|
aria-checked={value === option.value}
|
|
90
|
+
aria-label={iconOnly ? option.label : undefined}
|
|
78
91
|
disabled={option.disabled || disabled}
|
|
79
92
|
tabindex={value === option.value ? 0 : -1}
|
|
80
93
|
onclick={() => select(option)}
|
|
81
94
|
class="inline-flex items-center justify-center rounded-xl font-sans font-medium whitespace-nowrap transition-all duration-150 ease-brand-out disabled:pointer-events-none disabled:opacity-40
|
|
82
|
-
{sizes[size]} {focusRing} {toneRing[tone]}
|
|
95
|
+
{iconOnly ? squares[size] : sizes[size]} {focusRing} {toneRing[tone]}
|
|
83
96
|
{value === option.value ? `bg-bg text-text ${edge}` : 'text-text-muted hover:text-text'}"
|
|
84
97
|
>
|
|
85
|
-
{option.
|
|
98
|
+
{#if option.icon}<span class={iconMd}>{@render option.icon()}</span>{/if}
|
|
99
|
+
{#if !iconOnly}{option.label}{/if}
|
|
86
100
|
</button>
|
|
87
101
|
{/each}
|
|
88
102
|
{#if name}<input type="hidden" {name} {value} />{/if}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
1
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
3
|
import { type Tone } from '../../core/tones.js';
|
|
3
4
|
export interface SegmentOption {
|
|
4
5
|
value: string;
|
|
5
6
|
label: string;
|
|
7
|
+
/** Leading icon, 16px. */
|
|
8
|
+
icon?: Snippet;
|
|
6
9
|
disabled?: boolean;
|
|
7
10
|
}
|
|
8
11
|
export type SegmentedSize = 'sm' | 'md';
|
|
@@ -16,6 +19,8 @@ interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'onchange'> {
|
|
|
16
19
|
tone?: Tone;
|
|
17
20
|
/** Spread the segments evenly across the full width. */
|
|
18
21
|
fullWidth?: boolean;
|
|
22
|
+
/** Icons only — each option's `label` becomes its accessible name. */
|
|
23
|
+
iconOnly?: boolean;
|
|
19
24
|
label?: string;
|
|
20
25
|
disabled?: boolean;
|
|
21
26
|
onchange?: (value: string) => void;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
export type SidebarVariant = 'plain' | 'filled' | 'floating';
|
|
5
|
+
|
|
2
6
|
export interface SidebarItem {
|
|
3
7
|
/** Stable id used for the active state. Falls back to `href`. */
|
|
4
8
|
id?: string;
|
|
@@ -6,10 +10,21 @@
|
|
|
6
10
|
href?: string;
|
|
7
11
|
disabled?: boolean;
|
|
8
12
|
badge?: string | number;
|
|
13
|
+
/**
|
|
14
|
+
* Leading glyph, 16px. The one thing a collapsed rail still shows, so
|
|
15
|
+
* an item that has to survive `collapsed` needs one.
|
|
16
|
+
*/
|
|
17
|
+
icon?: Snippet;
|
|
9
18
|
/** Nested links — the parent becomes a collapsible group. */
|
|
10
19
|
items?: SidebarItem[];
|
|
11
20
|
/** Open the group on first render. */
|
|
12
21
|
open?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* `false` pins a group open: the parent stops being a button and the
|
|
24
|
+
* children are always on show. For navigation a reader should not be
|
|
25
|
+
* able to lose.
|
|
26
|
+
*/
|
|
27
|
+
collapsible?: boolean;
|
|
13
28
|
}
|
|
14
29
|
|
|
15
30
|
export interface SidebarSection {
|
|
@@ -20,8 +35,8 @@
|
|
|
20
35
|
</script>
|
|
21
36
|
|
|
22
37
|
<script lang="ts">
|
|
23
|
-
import type { Snippet } from 'svelte';
|
|
24
38
|
import { useLocale } from '../../core/locale.svelte.js';
|
|
39
|
+
import { iconMd } from './icon.js';
|
|
25
40
|
import { focusRing, toneRing, toneSoft, type Tone } from '../../core/tones.js';
|
|
26
41
|
|
|
27
42
|
interface Props {
|
|
@@ -32,6 +47,8 @@
|
|
|
32
47
|
collapsed?: boolean;
|
|
33
48
|
/** Show the collapse button. */
|
|
34
49
|
collapsible?: boolean;
|
|
50
|
+
/** Surface treatment: bare, the framed default, or a detached card. */
|
|
51
|
+
variant?: SidebarVariant;
|
|
35
52
|
tone?: Tone;
|
|
36
53
|
header?: Snippet;
|
|
37
54
|
footer?: Snippet;
|
|
@@ -44,6 +61,7 @@
|
|
|
44
61
|
value = $bindable(''),
|
|
45
62
|
collapsed = $bindable(false),
|
|
46
63
|
collapsible = true,
|
|
64
|
+
variant = 'filled',
|
|
47
65
|
tone = 'brand',
|
|
48
66
|
header,
|
|
49
67
|
footer,
|
|
@@ -59,7 +77,8 @@
|
|
|
59
77
|
let opened = $state<Record<string, boolean>>({});
|
|
60
78
|
|
|
61
79
|
const isOpen = (item: SidebarItem) =>
|
|
62
|
-
|
|
80
|
+
item.collapsible === false ||
|
|
81
|
+
(opened[keyOf(item)] ?? (item.open || item.items!.some((child) => keyOf(child) === value)));
|
|
63
82
|
|
|
64
83
|
function toggle(item: SidebarItem) {
|
|
65
84
|
opened = { ...opened, [keyOf(item)]: !isOpen(item) };
|
|
@@ -71,13 +90,50 @@
|
|
|
71
90
|
onnavigate?.(item);
|
|
72
91
|
}
|
|
73
92
|
|
|
93
|
+
const surfaces: Record<SidebarVariant, string> = {
|
|
94
|
+
plain: 'h-full bg-transparent',
|
|
95
|
+
filled: 'h-full border-r border-hairline bg-bg-alt',
|
|
96
|
+
floating: 'm-3 h-[calc(100%-1.5rem)] rounded-2xl border border-hairline bg-bg-alt shadow-sm'
|
|
97
|
+
};
|
|
98
|
+
|
|
74
99
|
const row =
|
|
75
100
|
'flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-left font-sans text-sm transition-colors duration-150 ease-brand-out disabled:pointer-events-none disabled:opacity-40';
|
|
76
101
|
</script>
|
|
77
102
|
|
|
103
|
+
<!-- Nested links. One copy, rendered by both kinds of group. -->
|
|
104
|
+
{#snippet subitems(item: SidebarItem)}
|
|
105
|
+
<div class="ml-4 flex flex-col gap-0.5 border-l border-hairline pl-2">
|
|
106
|
+
{#each item.items as child (keyOf(child))}
|
|
107
|
+
<a
|
|
108
|
+
href={child.href}
|
|
109
|
+
onclick={() => go(child)}
|
|
110
|
+
aria-current={value === keyOf(child) ? 'page' : undefined}
|
|
111
|
+
class="{row} {focusRing} {toneRing[tone]} {value === keyOf(child)
|
|
112
|
+
? `${toneSoft[tone]} font-medium`
|
|
113
|
+
: 'text-text-muted hover:bg-bg-inset hover:text-text'} {child.disabled
|
|
114
|
+
? 'pointer-events-none opacity-40'
|
|
115
|
+
: ''}"
|
|
116
|
+
>
|
|
117
|
+
{@render glyph(child)}
|
|
118
|
+
<span class="min-w-0 flex-1 truncate">{child.label}</span>
|
|
119
|
+
{#if child.badge !== undefined}
|
|
120
|
+
<span class="shrink-0 text-[11px] tabular-nums">{child.badge}</span>
|
|
121
|
+
{/if}
|
|
122
|
+
</a>
|
|
123
|
+
{/each}
|
|
124
|
+
</div>
|
|
125
|
+
{/snippet}
|
|
126
|
+
|
|
127
|
+
<!-- One box for every glyph, so rows line up whether or not an item has one. -->
|
|
128
|
+
{#snippet glyph(item: SidebarItem)}
|
|
129
|
+
{#if item.icon}
|
|
130
|
+
<span class={iconMd}>{@render item.icon()}</span>
|
|
131
|
+
{/if}
|
|
132
|
+
{/snippet}
|
|
133
|
+
|
|
78
134
|
<aside
|
|
79
|
-
class="flex
|
|
80
|
-
{collapsed ? 'w-16' : 'w-60'} {className}"
|
|
135
|
+
class="flex shrink-0 flex-col transition-[width] duration-200 ease-brand-out
|
|
136
|
+
{surfaces[variant]} {collapsed ? 'w-16' : 'w-60'} {className}"
|
|
81
137
|
>
|
|
82
138
|
{#if header}
|
|
83
139
|
<div class="flex h-16 shrink-0 items-center gap-3 border-b border-hairline px-3">
|
|
@@ -97,16 +153,25 @@
|
|
|
97
153
|
{/if}
|
|
98
154
|
|
|
99
155
|
{#each section.items as item (keyOf(item))}
|
|
100
|
-
{#if item.items?.length}
|
|
156
|
+
{#if item.items?.length && item.collapsible === false}
|
|
157
|
+
<div class="{row} {collapsed ? 'justify-center' : ''} font-medium text-text-muted">
|
|
158
|
+
{@render glyph(item)}
|
|
159
|
+
<span class="min-w-0 flex-1 truncate {collapsed ? 'sr-only' : ''}">{item.label}</span>
|
|
160
|
+
</div>
|
|
161
|
+
{#if isOpen(item) && !collapsed}
|
|
162
|
+
{@render subitems(item)}
|
|
163
|
+
{/if}
|
|
164
|
+
{:else if item.items?.length}
|
|
101
165
|
<button
|
|
102
166
|
type="button"
|
|
103
167
|
onclick={() => toggle(item)}
|
|
104
168
|
aria-expanded={isOpen(item)}
|
|
105
169
|
title={collapsed ? item.label : undefined}
|
|
106
|
-
class="{row} {focusRing} {toneRing[
|
|
170
|
+
class="{row} {collapsed ? 'justify-center' : ''} {focusRing} {toneRing[
|
|
107
171
|
tone
|
|
108
172
|
]} text-text-secondary hover:bg-bg-inset hover:text-text"
|
|
109
173
|
>
|
|
174
|
+
{@render glyph(item)}
|
|
110
175
|
<span class="min-w-0 flex-1 truncate {collapsed ? 'sr-only' : ''}">{item.label}</span>
|
|
111
176
|
{#if !collapsed}
|
|
112
177
|
<svg
|
|
@@ -128,25 +193,7 @@
|
|
|
128
193
|
</button>
|
|
129
194
|
|
|
130
195
|
{#if isOpen(item) && !collapsed}
|
|
131
|
-
|
|
132
|
-
{#each item.items as child (keyOf(child))}
|
|
133
|
-
<a
|
|
134
|
-
href={child.href}
|
|
135
|
-
onclick={() => go(child)}
|
|
136
|
-
aria-current={value === keyOf(child) ? 'page' : undefined}
|
|
137
|
-
class="{row} {focusRing} {toneRing[tone]} {value === keyOf(child)
|
|
138
|
-
? `${toneSoft[tone]} font-medium`
|
|
139
|
-
: 'text-text-muted hover:bg-bg-inset hover:text-text'} {child.disabled
|
|
140
|
-
? 'pointer-events-none opacity-40'
|
|
141
|
-
: ''}"
|
|
142
|
-
>
|
|
143
|
-
<span class="min-w-0 flex-1 truncate">{child.label}</span>
|
|
144
|
-
{#if child.badge !== undefined}
|
|
145
|
-
<span class="shrink-0 text-[11px] tabular-nums">{child.badge}</span>
|
|
146
|
-
{/if}
|
|
147
|
-
</a>
|
|
148
|
-
{/each}
|
|
149
|
-
</div>
|
|
196
|
+
{@render subitems(item)}
|
|
150
197
|
{/if}
|
|
151
198
|
{:else}
|
|
152
199
|
<a
|
|
@@ -154,12 +201,15 @@
|
|
|
154
201
|
onclick={() => go(item)}
|
|
155
202
|
aria-current={value === keyOf(item) ? 'page' : undefined}
|
|
156
203
|
title={collapsed ? item.label : undefined}
|
|
157
|
-
class="{row} {focusRing} {toneRing[
|
|
204
|
+
class="{row} {collapsed ? 'justify-center' : ''} {focusRing} {toneRing[
|
|
205
|
+
tone
|
|
206
|
+
]} {value === keyOf(item)
|
|
158
207
|
? `${toneSoft[tone]} font-medium`
|
|
159
208
|
: 'text-text-secondary hover:bg-bg-inset hover:text-text'} {item.disabled
|
|
160
209
|
? 'pointer-events-none opacity-40'
|
|
161
210
|
: ''}"
|
|
162
211
|
>
|
|
212
|
+
{@render glyph(item)}
|
|
163
213
|
<span class="min-w-0 flex-1 truncate {collapsed ? 'sr-only' : ''}">{item.label}</span>
|
|
164
214
|
{#if item.badge !== undefined && !collapsed}
|
|
165
215
|
<span class="shrink-0 text-[11px] text-text-muted tabular-nums">{item.badge}</span>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type SidebarVariant = 'plain' | 'filled' | 'floating';
|
|
1
3
|
export interface SidebarItem {
|
|
2
4
|
/** Stable id used for the active state. Falls back to `href`. */
|
|
3
5
|
id?: string;
|
|
@@ -5,17 +7,27 @@ export interface SidebarItem {
|
|
|
5
7
|
href?: string;
|
|
6
8
|
disabled?: boolean;
|
|
7
9
|
badge?: string | number;
|
|
10
|
+
/**
|
|
11
|
+
* Leading glyph, 16px. The one thing a collapsed rail still shows, so
|
|
12
|
+
* an item that has to survive `collapsed` needs one.
|
|
13
|
+
*/
|
|
14
|
+
icon?: Snippet;
|
|
8
15
|
/** Nested links — the parent becomes a collapsible group. */
|
|
9
16
|
items?: SidebarItem[];
|
|
10
17
|
/** Open the group on first render. */
|
|
11
18
|
open?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* `false` pins a group open: the parent stops being a button and the
|
|
21
|
+
* children are always on show. For navigation a reader should not be
|
|
22
|
+
* able to lose.
|
|
23
|
+
*/
|
|
24
|
+
collapsible?: boolean;
|
|
12
25
|
}
|
|
13
26
|
export interface SidebarSection {
|
|
14
27
|
/** Small heading above a run of items. */
|
|
15
28
|
label?: string;
|
|
16
29
|
items: SidebarItem[];
|
|
17
30
|
}
|
|
18
|
-
import type { Snippet } from 'svelte';
|
|
19
31
|
import { type Tone } from '../../core/tones.js';
|
|
20
32
|
interface Props {
|
|
21
33
|
sections: SidebarSection[];
|
|
@@ -25,6 +37,8 @@ interface Props {
|
|
|
25
37
|
collapsed?: boolean;
|
|
26
38
|
/** Show the collapse button. */
|
|
27
39
|
collapsible?: boolean;
|
|
40
|
+
/** Surface treatment: bare, the framed default, or a detached card. */
|
|
41
|
+
variant?: SidebarVariant;
|
|
28
42
|
tone?: Tone;
|
|
29
43
|
header?: Snippet;
|
|
30
44
|
footer?: Snippet;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
2
3
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
4
|
import { toneText, type Tone } from '../../core/tones.js';
|
|
5
|
+
import { iconMd } from './icon.js';
|
|
4
6
|
|
|
5
7
|
export type StatTrend = 'up' | 'down' | 'flat';
|
|
6
8
|
|
|
@@ -11,6 +13,8 @@
|
|
|
11
13
|
delta?: string;
|
|
12
14
|
trend?: StatTrend;
|
|
13
15
|
hint?: string;
|
|
16
|
+
/** Leading icon on the label row. */
|
|
17
|
+
icon?: Snippet;
|
|
14
18
|
/** Colour of the value itself. Leave unset for plain `text`. */
|
|
15
19
|
tone?: Tone;
|
|
16
20
|
}
|
|
@@ -21,6 +25,7 @@
|
|
|
21
25
|
delta,
|
|
22
26
|
trend = 'flat',
|
|
23
27
|
hint,
|
|
28
|
+
icon,
|
|
24
29
|
tone,
|
|
25
30
|
class: className = '',
|
|
26
31
|
...rest
|
|
@@ -31,7 +36,9 @@
|
|
|
31
36
|
</script>
|
|
32
37
|
|
|
33
38
|
<div class="flex flex-col gap-1 font-sans {className}" {...rest}>
|
|
34
|
-
<span class="text-sm font-medium text-text-muted"
|
|
39
|
+
<span class="flex items-center gap-2 text-sm font-medium text-text-muted"
|
|
40
|
+
>{#if icon}<span class={iconMd}>{@render icon()}</span>{/if}{label}</span
|
|
41
|
+
>
|
|
35
42
|
<div class="flex items-baseline gap-2">
|
|
36
43
|
<span
|
|
37
44
|
class="font-heading text-3xl font-semibold tracking-tight tabular-nums {tone
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
1
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
3
|
import { type Tone } from '../../core/tones.js';
|
|
3
4
|
export type StatTrend = 'up' | 'down' | 'flat';
|
|
@@ -8,6 +9,8 @@ interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
|
8
9
|
delta?: string;
|
|
9
10
|
trend?: StatTrend;
|
|
10
11
|
hint?: string;
|
|
12
|
+
/** Leading icon on the label row. */
|
|
13
|
+
icon?: Snippet;
|
|
11
14
|
/** Colour of the value itself. Leave unset for plain `text`. */
|
|
12
15
|
tone?: Tone;
|
|
13
16
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
2
4
|
export interface StepItem {
|
|
3
5
|
label: string;
|
|
4
6
|
description?: string;
|
|
7
|
+
/** Replaces the step number. A finished step still shows its check. */
|
|
8
|
+
icon?: Snippet;
|
|
5
9
|
/** Marks the step as failed — shown in `danger` regardless of position. */
|
|
6
10
|
error?: boolean;
|
|
7
11
|
disabled?: boolean;
|
|
@@ -10,6 +14,7 @@
|
|
|
10
14
|
|
|
11
15
|
<script lang="ts">
|
|
12
16
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
17
|
+
import { iconMd } from './icon.js';
|
|
13
18
|
import { focusRing, toneFill, toneRing, toneText, type Tone } from '../../core/tones.js';
|
|
14
19
|
import { liftSm } from './lift.js';
|
|
15
20
|
|
|
@@ -75,6 +80,8 @@
|
|
|
75
80
|
stroke-linejoin="round"
|
|
76
81
|
/>
|
|
77
82
|
</svg>
|
|
83
|
+
{:else if item.icon}
|
|
84
|
+
<span class={iconMd}>{@render item.icon()}</span>
|
|
78
85
|
{:else}
|
|
79
86
|
{index + 1}
|
|
80
87
|
{/if}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
1
2
|
export interface StepItem {
|
|
2
3
|
label: string;
|
|
3
4
|
description?: string;
|
|
5
|
+
/** Replaces the step number. A finished step still shows its check. */
|
|
6
|
+
icon?: Snippet;
|
|
4
7
|
/** Marks the step as failed — shown in `danger` regardless of position. */
|
|
5
8
|
error?: boolean;
|
|
6
9
|
disabled?: boolean;
|