dssoca 0.5.0 → 0.9.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 +39 -13
- package/dist/components/Accordion.svelte +297 -0
- package/dist/components/Accordion.svelte.d.ts +51 -0
- package/dist/components/Badge.svelte +113 -18
- package/dist/components/Badge.svelte.d.ts +28 -2
- package/dist/components/BottomNav.svelte +254 -0
- package/dist/components/BottomNav.svelte.d.ts +32 -0
- package/dist/components/Button.svelte +147 -10
- package/dist/components/Button.svelte.d.ts +21 -4
- package/dist/components/Card.svelte +173 -8
- package/dist/components/Card.svelte.d.ts +16 -1
- package/dist/components/Container.svelte +55 -0
- package/dist/components/Container.svelte.d.ts +16 -0
- package/dist/components/EmptyState.svelte +91 -9
- package/dist/components/EmptyState.svelte.d.ts +20 -3
- package/dist/components/Heading.svelte +83 -0
- package/dist/components/Heading.svelte.d.ts +17 -0
- package/dist/components/Icon.svelte +199 -24
- package/dist/components/Icon.svelte.d.ts +70 -2
- package/dist/components/Image.svelte +428 -0
- package/dist/components/Image.svelte.d.ts +49 -0
- package/dist/components/Input.svelte +173 -39
- package/dist/components/Input.svelte.d.ts +22 -0
- package/dist/components/Link.svelte +183 -0
- package/dist/components/Link.svelte.d.ts +29 -0
- package/dist/components/LogStream.svelte +403 -47
- package/dist/components/LogStream.svelte.d.ts +35 -7
- package/dist/components/Menu.svelte +408 -0
- package/dist/components/Menu.svelte.d.ts +66 -0
- package/dist/components/MetricTile.svelte +124 -12
- package/dist/components/MetricTile.svelte.d.ts +20 -0
- package/dist/components/SegmentedControl.svelte +220 -0
- package/dist/components/SegmentedControl.svelte.d.ts +37 -0
- package/dist/components/ServiceCard.svelte +226 -30
- package/dist/components/ServiceCard.svelte.d.ts +13 -1
- package/dist/components/Sidebar.svelte +377 -40
- package/dist/components/Sidebar.svelte.d.ts +18 -7
- package/dist/components/Sparkline.svelte +198 -13
- package/dist/components/Sparkline.svelte.d.ts +20 -1
- package/dist/components/Spinner.svelte +124 -0
- package/dist/components/Spinner.svelte.d.ts +74 -0
- package/dist/components/Textarea.svelte +214 -0
- package/dist/components/Textarea.svelte.d.ts +38 -0
- package/dist/components/Toaster.svelte +209 -12
- package/dist/components/Toaster.svelte.d.ts +3 -0
- package/dist/components/Topbar.svelte +293 -42
- package/dist/components/Topbar.svelte.d.ts +48 -1
- package/dist/dssoca.config.d.ts +1 -1
- package/dist/dssoca.config.js +10 -0
- package/dist/index.d.ts +16 -3
- package/dist/index.js +18 -2
- package/dist/theme.css +406 -24
- package/dist/toast.svelte.d.ts +49 -5
- package/dist/toast.svelte.js +165 -9
- package/dist/tokens.css +597 -0
- package/package.json +25 -4
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { IconName } from './Icon.svelte'
|
|
3
|
+
|
|
4
|
+
/** One tab in the bottom navigation bar. */
|
|
5
|
+
export interface BottomNavItem {
|
|
6
|
+
/** Stable id — matched against `active` and passed to `onSelect`. */
|
|
7
|
+
id: string
|
|
8
|
+
/** Visible label rendered under the icon. */
|
|
9
|
+
label: string
|
|
10
|
+
/** Leading glyph (shared `Icon` component). */
|
|
11
|
+
icon: IconName
|
|
12
|
+
/** Optional URL — when set the tab renders as a real `<a href>`. */
|
|
13
|
+
href?: string
|
|
14
|
+
/** Optional count/label rendered as a small square badge on the icon. */
|
|
15
|
+
badge?: string | number
|
|
16
|
+
/** Renders the tab inert: no navigation/onSelect, `aria-disabled`, out of the tab order. */
|
|
17
|
+
disabled?: boolean
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
import Icon from './Icon.svelte'
|
|
23
|
+
import { resolveComponentSize, type Size } from '../config.js'
|
|
24
|
+
|
|
25
|
+
interface Props {
|
|
26
|
+
/** Tabs to render, left → right, in equal-width columns. */
|
|
27
|
+
items?: BottomNavItem[]
|
|
28
|
+
/** Id of the active tab; highlighted + `aria-current="page"`. */
|
|
29
|
+
active?: string
|
|
30
|
+
/** Fired with the tab id on activation (also fires for `href` tabs as an SPA fallback). */
|
|
31
|
+
onSelect?: (id: string) => void
|
|
32
|
+
/** Accessible name for the wrapping `<nav>` landmark. */
|
|
33
|
+
ariaLabel?: string
|
|
34
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
35
|
+
size?: Size
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const DEFAULT_ITEMS: BottomNavItem[] = [
|
|
39
|
+
{ id: 'home', label: 'Home', icon: 'grid' },
|
|
40
|
+
{ id: 'services', label: 'Services', icon: 'database' },
|
|
41
|
+
{ id: 'activity', label: 'Activity', icon: 'activity' },
|
|
42
|
+
{ id: 'account', label: 'Account', icon: 'user' },
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
let { items = DEFAULT_ITEMS, active, onSelect, ariaLabel = 'Primary', size }: Props = $props()
|
|
46
|
+
|
|
47
|
+
const isActive = (item: BottomNavItem): boolean => item.id === active
|
|
48
|
+
|
|
49
|
+
const hasBadge = (item: BottomNavItem): boolean => item.badge != null && item.badge !== ''
|
|
50
|
+
|
|
51
|
+
/** Fold the count badge into the accessible name so it isn't lost to AT. */
|
|
52
|
+
function accessibleName(item: BottomNavItem): string {
|
|
53
|
+
return hasBadge(item) ? `${item.label}, ${item.badge}` : item.label
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function activate(item: BottomNavItem, e: MouseEvent) {
|
|
57
|
+
// Disabled tabs are inert (DS-0078): no navigation, no onSelect. The
|
|
58
|
+
// <button> branch is natively disabled; this also guards the <a> branch.
|
|
59
|
+
if (item.disabled) {
|
|
60
|
+
e.preventDefault()
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
// Real links navigate natively; intercept only the SPA (no-href) path so a
|
|
64
|
+
// plain <button> never submits/scrolls. onSelect fires either way.
|
|
65
|
+
if (!item.href) e.preventDefault()
|
|
66
|
+
onSelect?.(item.id)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const sizeAttr = $derived(resolveComponentSize('BottomNav', size))
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<nav class="ss-bottom-nav" aria-label={ariaLabel} data-size-variant={sizeAttr}>
|
|
73
|
+
<ul class="list">
|
|
74
|
+
{#each items as item (item.id)}
|
|
75
|
+
{@const current = isActive(item)}
|
|
76
|
+
<li class="row">
|
|
77
|
+
{#if item.href && !item.disabled}
|
|
78
|
+
<a
|
|
79
|
+
class="tab {current ? 'active' : ''}"
|
|
80
|
+
href={item.href}
|
|
81
|
+
aria-current={current ? 'page' : undefined}
|
|
82
|
+
aria-label={hasBadge(item) ? accessibleName(item) : undefined}
|
|
83
|
+
onclick={(e) => activate(item, e)}
|
|
84
|
+
>
|
|
85
|
+
<span class="glyph">
|
|
86
|
+
<Icon name={item.icon} px={20} />
|
|
87
|
+
{#if hasBadge(item)}
|
|
88
|
+
<span class="badge" aria-hidden="true">{item.badge}</span>
|
|
89
|
+
{/if}
|
|
90
|
+
</span>
|
|
91
|
+
<span class="label">{item.label}</span>
|
|
92
|
+
</a>
|
|
93
|
+
{:else}
|
|
94
|
+
<!-- Disabled href tabs also land here (DS-0078): a natively disabled
|
|
95
|
+
<button> is reliably inert + skipped by the tab order, where a
|
|
96
|
+
dead <a> would need tabindex/role juggling. -->
|
|
97
|
+
<button
|
|
98
|
+
type="button"
|
|
99
|
+
class="tab {current ? 'active' : ''}"
|
|
100
|
+
class:disabled={item.disabled}
|
|
101
|
+
disabled={item.disabled || undefined}
|
|
102
|
+
aria-disabled={item.disabled ? 'true' : undefined}
|
|
103
|
+
aria-current={current ? 'page' : undefined}
|
|
104
|
+
aria-label={hasBadge(item) ? accessibleName(item) : undefined}
|
|
105
|
+
onclick={(e) => activate(item, e)}
|
|
106
|
+
>
|
|
107
|
+
<span class="glyph">
|
|
108
|
+
<Icon name={item.icon} px={20} />
|
|
109
|
+
{#if hasBadge(item)}
|
|
110
|
+
<span class="badge" aria-hidden="true">{item.badge}</span>
|
|
111
|
+
{/if}
|
|
112
|
+
</span>
|
|
113
|
+
<span class="label">{item.label}</span>
|
|
114
|
+
</button>
|
|
115
|
+
{/if}
|
|
116
|
+
</li>
|
|
117
|
+
{/each}
|
|
118
|
+
</ul>
|
|
119
|
+
</nav>
|
|
120
|
+
|
|
121
|
+
<style>.ss-bottom-nav {
|
|
122
|
+
--_bar-h: var(--ss-bottom-nav-h, var(--ss-shell-top-h, 48px));
|
|
123
|
+
--_pad-x: var(--ss-bottom-nav-px, var(--ss-s-2, 8px));
|
|
124
|
+
--_tab-py: var(--ss-bottom-nav-tab-py, var(--ss-s-1, 4px));
|
|
125
|
+
--_gap: var(--ss-bottom-nav-gap, 4px);
|
|
126
|
+
--_label-fs: var(--ss-bottom-nav-label-fs, var(--ss-ui-xs, 11px));
|
|
127
|
+
--_badge-top: var(--ss-bottom-nav-badge-top, -6px);
|
|
128
|
+
--_badge-dx: var(--ss-bottom-nav-badge-dx, 6px);
|
|
129
|
+
--_badge-min-w: var(--ss-bottom-nav-badge-min-w, 14px);
|
|
130
|
+
--_badge-h: var(--ss-bottom-nav-badge-h, 14px);
|
|
131
|
+
--_badge-fs: var(--ss-bottom-nav-badge-fs, 9px);
|
|
132
|
+
--_badge-px: var(--ss-bottom-nav-badge-px, 3px);
|
|
133
|
+
}
|
|
134
|
+
.ss-bottom-nav[data-size-variant=sm] {
|
|
135
|
+
--_badge-top: var(--ss-bottom-nav-badge-top, -5px);
|
|
136
|
+
--_badge-dx: var(--ss-bottom-nav-badge-dx, 5px);
|
|
137
|
+
--_badge-min-w: var(--ss-bottom-nav-badge-min-w, 12px);
|
|
138
|
+
--_badge-h: var(--ss-bottom-nav-badge-h, 12px);
|
|
139
|
+
--_badge-fs: var(--ss-bottom-nav-badge-fs, 8px);
|
|
140
|
+
--_badge-px: var(--ss-bottom-nav-badge-px, 2px);
|
|
141
|
+
}
|
|
142
|
+
.ss-bottom-nav[data-size-variant=lg] {
|
|
143
|
+
--_badge-top: var(--ss-bottom-nav-badge-top, -7px);
|
|
144
|
+
--_badge-dx: var(--ss-bottom-nav-badge-dx, 7px);
|
|
145
|
+
--_badge-min-w: var(--ss-bottom-nav-badge-min-w, 16px);
|
|
146
|
+
--_badge-h: var(--ss-bottom-nav-badge-h, 16px);
|
|
147
|
+
--_badge-fs: var(--ss-bottom-nav-badge-fs, 10px);
|
|
148
|
+
--_badge-px: var(--ss-bottom-nav-badge-px, 4px);
|
|
149
|
+
}
|
|
150
|
+
.ss-bottom-nav {
|
|
151
|
+
position: fixed;
|
|
152
|
+
left: 0;
|
|
153
|
+
right: 0;
|
|
154
|
+
bottom: 0;
|
|
155
|
+
z-index: 30;
|
|
156
|
+
box-sizing: border-box;
|
|
157
|
+
padding-bottom: env(safe-area-inset-bottom, 0px);
|
|
158
|
+
background: color-mix(in srgb, var(--ss-bg) 88%, transparent);
|
|
159
|
+
backdrop-filter: blur(14px);
|
|
160
|
+
-webkit-backdrop-filter: blur(14px);
|
|
161
|
+
border-top: 1px solid var(--ss-line);
|
|
162
|
+
font-family: var(--ss-font-mono);
|
|
163
|
+
}
|
|
164
|
+
.ss-bottom-nav .list {
|
|
165
|
+
list-style: none;
|
|
166
|
+
margin: 0;
|
|
167
|
+
padding: 0;
|
|
168
|
+
display: grid;
|
|
169
|
+
grid-auto-flow: column;
|
|
170
|
+
grid-auto-columns: 1fr;
|
|
171
|
+
align-items: stretch;
|
|
172
|
+
}
|
|
173
|
+
.ss-bottom-nav .row {
|
|
174
|
+
display: flex;
|
|
175
|
+
}
|
|
176
|
+
.ss-bottom-nav .tab {
|
|
177
|
+
flex: 1 1 auto;
|
|
178
|
+
display: flex;
|
|
179
|
+
flex-direction: column;
|
|
180
|
+
align-items: center;
|
|
181
|
+
justify-content: center;
|
|
182
|
+
gap: var(--_gap);
|
|
183
|
+
width: 100%;
|
|
184
|
+
min-height: max(var(--_bar-h), 44px);
|
|
185
|
+
padding: var(--_tab-py) var(--_pad-x);
|
|
186
|
+
box-sizing: border-box;
|
|
187
|
+
cursor: pointer;
|
|
188
|
+
text-decoration: none;
|
|
189
|
+
color: var(--ss-fg-faint);
|
|
190
|
+
background: none;
|
|
191
|
+
border: 0;
|
|
192
|
+
border-top: 2px solid transparent;
|
|
193
|
+
font: inherit;
|
|
194
|
+
transition: color var(--ss-dur-fast) var(--ss-ease), background var(--ss-dur-fast) var(--ss-ease);
|
|
195
|
+
}
|
|
196
|
+
.ss-bottom-nav .tab:hover {
|
|
197
|
+
color: var(--ss-fg);
|
|
198
|
+
}
|
|
199
|
+
.ss-bottom-nav .tab:focus-visible {
|
|
200
|
+
outline: 2px solid var(--ss-primary);
|
|
201
|
+
outline-offset: -2px;
|
|
202
|
+
}
|
|
203
|
+
.ss-bottom-nav .tab.active {
|
|
204
|
+
color: var(--ss-primary);
|
|
205
|
+
background: rgba(var(--ss-primary-rgb), 0.06);
|
|
206
|
+
border-top-color: var(--ss-primary);
|
|
207
|
+
}
|
|
208
|
+
.ss-bottom-nav .tab:disabled, .ss-bottom-nav .tab.disabled {
|
|
209
|
+
cursor: default;
|
|
210
|
+
opacity: 0.45;
|
|
211
|
+
}
|
|
212
|
+
.ss-bottom-nav .tab:disabled:hover, .ss-bottom-nav .tab.disabled:hover {
|
|
213
|
+
color: var(--ss-fg-faint);
|
|
214
|
+
}
|
|
215
|
+
.ss-bottom-nav .glyph {
|
|
216
|
+
position: relative;
|
|
217
|
+
display: inline-flex;
|
|
218
|
+
align-items: center;
|
|
219
|
+
justify-content: center;
|
|
220
|
+
line-height: 0;
|
|
221
|
+
}
|
|
222
|
+
.ss-bottom-nav .badge {
|
|
223
|
+
position: absolute;
|
|
224
|
+
top: var(--_badge-top);
|
|
225
|
+
left: calc(50% + var(--_badge-dx));
|
|
226
|
+
min-width: var(--_badge-min-w);
|
|
227
|
+
height: var(--_badge-h);
|
|
228
|
+
padding: 0 var(--_badge-px);
|
|
229
|
+
box-sizing: border-box;
|
|
230
|
+
display: inline-flex;
|
|
231
|
+
align-items: center;
|
|
232
|
+
justify-content: center;
|
|
233
|
+
font-family: var(--ss-font-mono);
|
|
234
|
+
font-size: var(--_badge-fs);
|
|
235
|
+
line-height: 1;
|
|
236
|
+
font-variant-numeric: tabular-nums;
|
|
237
|
+
color: var(--ss-fg-on-primary);
|
|
238
|
+
background: var(--ss-primary);
|
|
239
|
+
border-radius: 0;
|
|
240
|
+
}
|
|
241
|
+
.ss-bottom-nav .label {
|
|
242
|
+
font-size: var(--_label-fs);
|
|
243
|
+
line-height: 1;
|
|
244
|
+
letter-spacing: 0.02em;
|
|
245
|
+
max-width: 100%;
|
|
246
|
+
overflow: hidden;
|
|
247
|
+
text-overflow: ellipsis;
|
|
248
|
+
white-space: nowrap;
|
|
249
|
+
}
|
|
250
|
+
@media (prefers-reduced-motion: reduce) {
|
|
251
|
+
.ss-bottom-nav .tab {
|
|
252
|
+
transition: none;
|
|
253
|
+
}
|
|
254
|
+
}</style>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IconName } from './Icon.svelte';
|
|
2
|
+
/** One tab in the bottom navigation bar. */
|
|
3
|
+
export interface BottomNavItem {
|
|
4
|
+
/** Stable id — matched against `active` and passed to `onSelect`. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Visible label rendered under the icon. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Leading glyph (shared `Icon` component). */
|
|
9
|
+
icon: IconName;
|
|
10
|
+
/** Optional URL — when set the tab renders as a real `<a href>`. */
|
|
11
|
+
href?: string;
|
|
12
|
+
/** Optional count/label rendered as a small square badge on the icon. */
|
|
13
|
+
badge?: string | number;
|
|
14
|
+
/** Renders the tab inert: no navigation/onSelect, `aria-disabled`, out of the tab order. */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
import { type Size } from '../config.js';
|
|
18
|
+
interface Props {
|
|
19
|
+
/** Tabs to render, left → right, in equal-width columns. */
|
|
20
|
+
items?: BottomNavItem[];
|
|
21
|
+
/** Id of the active tab; highlighted + `aria-current="page"`. */
|
|
22
|
+
active?: string;
|
|
23
|
+
/** Fired with the tab id on activation (also fires for `href` tabs as an SPA fallback). */
|
|
24
|
+
onSelect?: (id: string) => void;
|
|
25
|
+
/** Accessible name for the wrapping `<nav>` landmark. */
|
|
26
|
+
ariaLabel?: string;
|
|
27
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
28
|
+
size?: Size;
|
|
29
|
+
}
|
|
30
|
+
declare const BottomNav: import("svelte").Component<Props, {}, "">;
|
|
31
|
+
type BottomNav = ReturnType<typeof BottomNav>;
|
|
32
|
+
export default BottomNav;
|
|
@@ -1,21 +1,88 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { HTMLButtonAttributes } from 'svelte/elements'
|
|
3
4
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
4
5
|
|
|
5
|
-
interface Props {
|
|
6
|
-
variant?: 'primary' | 'secondary' | 'ghost'
|
|
6
|
+
interface Props extends HTMLButtonAttributes {
|
|
7
|
+
variant?: 'primary' | 'secondary' | 'ghost' | 'danger'
|
|
7
8
|
type?: 'button' | 'submit' | 'reset'
|
|
8
9
|
disabled?: boolean
|
|
10
|
+
/** Loading state: shows a spinner, blocks clicks, sets aria-busy; stays focusable. */
|
|
11
|
+
loading?: boolean
|
|
12
|
+
/** Accessible name while loading (keeps the name stable when the label is hidden). */
|
|
13
|
+
loadingLabel?: string
|
|
9
14
|
onclick?: (e: MouseEvent) => void
|
|
10
15
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
11
16
|
size?: Size
|
|
12
|
-
|
|
17
|
+
/** Icon-only square button — `label` is required and becomes the aria-label. */
|
|
18
|
+
iconOnly?: boolean
|
|
19
|
+
/** Accessible name; required for icon-only buttons (→ aria-label). */
|
|
20
|
+
label?: string
|
|
21
|
+
/** Block-level: stretch to fill the inline axis and center the content. */
|
|
22
|
+
fullWidth?: boolean
|
|
23
|
+
/** Leading icon snippet, rendered before children. */
|
|
24
|
+
leading?: Snippet
|
|
25
|
+
/** Trailing icon snippet, rendered after children. */
|
|
26
|
+
trailing?: Snippet
|
|
27
|
+
children?: Snippet
|
|
28
|
+
/** Bound reference to the underlying <button>. */
|
|
29
|
+
el?: HTMLButtonElement
|
|
30
|
+
}
|
|
31
|
+
let {
|
|
32
|
+
variant = 'secondary',
|
|
33
|
+
type = 'button',
|
|
34
|
+
disabled = false,
|
|
35
|
+
loading = false,
|
|
36
|
+
loadingLabel,
|
|
37
|
+
onclick,
|
|
38
|
+
size,
|
|
39
|
+
iconOnly = false,
|
|
40
|
+
label,
|
|
41
|
+
fullWidth = false,
|
|
42
|
+
leading,
|
|
43
|
+
trailing,
|
|
44
|
+
children,
|
|
45
|
+
el = $bindable(),
|
|
46
|
+
...rest
|
|
47
|
+
}: Props = $props()
|
|
48
|
+
|
|
49
|
+
// Soft-disable: keep the control focusable/announceable via aria-disabled while
|
|
50
|
+
// loading, but still emit native `disabled` so forms don't submit it.
|
|
51
|
+
let busy = $derived(loading)
|
|
52
|
+
let ariaLabel = $derived(iconOnly ? label : rest['aria-label'])
|
|
53
|
+
let accessibleName = $derived(loading ? (loadingLabel ?? ariaLabel) : ariaLabel)
|
|
54
|
+
|
|
55
|
+
function handleClick(e: MouseEvent) {
|
|
56
|
+
if (loading || disabled) {
|
|
57
|
+
e.preventDefault()
|
|
58
|
+
e.stopImmediatePropagation()
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
onclick?.(e)
|
|
13
62
|
}
|
|
14
|
-
let { variant = 'secondary', type = 'button', disabled = false, onclick, size, children }: Props = $props()
|
|
15
63
|
</script>
|
|
16
64
|
|
|
17
|
-
<button
|
|
18
|
-
{
|
|
65
|
+
<button
|
|
66
|
+
bind:this={el}
|
|
67
|
+
class="ss-btn {variant}"
|
|
68
|
+
class:icon-only={iconOnly}
|
|
69
|
+
class:full-width={fullWidth}
|
|
70
|
+
class:loading
|
|
71
|
+
{type}
|
|
72
|
+
{disabled}
|
|
73
|
+
aria-busy={busy ? 'true' : undefined}
|
|
74
|
+
aria-disabled={loading ? 'true' : undefined}
|
|
75
|
+
aria-label={accessibleName}
|
|
76
|
+
data-size-variant={resolveComponentSize('Button', size)}
|
|
77
|
+
{...rest}
|
|
78
|
+
onclick={handleClick}
|
|
79
|
+
>
|
|
80
|
+
{#if loading}
|
|
81
|
+
<span class="spinner" aria-hidden="true"></span>
|
|
82
|
+
{/if}
|
|
83
|
+
{#if leading}<span class="affix" aria-hidden="true">{@render leading()}</span>{/if}
|
|
84
|
+
{#if children}<span class="label">{@render children()}</span>{/if}
|
|
85
|
+
{#if trailing}<span class="affix" aria-hidden="true">{@render trailing()}</span>{/if}
|
|
19
86
|
</button>
|
|
20
87
|
|
|
21
88
|
<style>.ss-btn {
|
|
@@ -30,10 +97,10 @@
|
|
|
30
97
|
cursor: pointer;
|
|
31
98
|
display: inline-flex;
|
|
32
99
|
align-items: center;
|
|
33
|
-
gap:
|
|
100
|
+
gap: var(--ss-gap-sm);
|
|
34
101
|
transition: all var(--ss-dur-fast) var(--ss-ease);
|
|
35
102
|
}
|
|
36
|
-
.ss-btn:hover {
|
|
103
|
+
.ss-btn:not(:disabled):hover {
|
|
37
104
|
background: var(--ss-hover);
|
|
38
105
|
border-color: var(--ss-line-strong);
|
|
39
106
|
}
|
|
@@ -43,18 +110,88 @@
|
|
|
43
110
|
border-color: var(--ss-primary);
|
|
44
111
|
font-weight: 600;
|
|
45
112
|
}
|
|
46
|
-
.ss-btn.primary:hover {
|
|
113
|
+
.ss-btn.primary:not(:disabled):hover {
|
|
47
114
|
background: var(--ss-primary-hover);
|
|
48
115
|
border-color: var(--ss-primary-hover);
|
|
49
116
|
box-shadow: var(--ss-shadow-glow);
|
|
50
117
|
}
|
|
118
|
+
.ss-btn.danger {
|
|
119
|
+
background: var(--ss-danger);
|
|
120
|
+
color: var(--ss-fg-on-danger);
|
|
121
|
+
border-color: var(--ss-danger);
|
|
122
|
+
font-weight: 600;
|
|
123
|
+
}
|
|
124
|
+
.ss-btn.danger:not(:disabled):hover {
|
|
125
|
+
background: var(--ss-danger-hover);
|
|
126
|
+
border-color: var(--ss-danger-hover);
|
|
127
|
+
}
|
|
51
128
|
.ss-btn.ghost {
|
|
52
129
|
border-color: transparent;
|
|
53
130
|
color: var(--ss-fg-muted);
|
|
54
131
|
padding: var(--ss-control-py) var(--ss-gap-sm);
|
|
55
132
|
}
|
|
56
|
-
.ss-btn.ghost:hover {
|
|
133
|
+
.ss-btn.ghost:not(:disabled):hover {
|
|
57
134
|
color: var(--ss-fg);
|
|
58
135
|
background: var(--ss-hover);
|
|
59
136
|
border-color: transparent;
|
|
137
|
+
}
|
|
138
|
+
.ss-btn {
|
|
139
|
+
/* Icon-only: square padding derived from the vertical control token. */
|
|
140
|
+
}
|
|
141
|
+
.ss-btn.icon-only {
|
|
142
|
+
padding: var(--ss-control-py);
|
|
143
|
+
gap: 0;
|
|
144
|
+
}
|
|
145
|
+
.ss-btn {
|
|
146
|
+
/* Block-level: fill the inline axis, center the content. */
|
|
147
|
+
}
|
|
148
|
+
.ss-btn.full-width {
|
|
149
|
+
width: 100%;
|
|
150
|
+
justify-content: center;
|
|
151
|
+
}
|
|
152
|
+
.ss-btn {
|
|
153
|
+
/* Soft-disabled while loading: keep focusable, dim, block the pointer. */
|
|
154
|
+
}
|
|
155
|
+
.ss-btn.loading {
|
|
156
|
+
cursor: progress;
|
|
157
|
+
opacity: 0.8;
|
|
158
|
+
}
|
|
159
|
+
.ss-btn:disabled {
|
|
160
|
+
cursor: not-allowed;
|
|
161
|
+
opacity: 0.5;
|
|
162
|
+
box-shadow: none;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.label {
|
|
166
|
+
display: inline-flex;
|
|
167
|
+
align-items: center;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.affix {
|
|
171
|
+
display: inline-flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
justify-content: center;
|
|
174
|
+
line-height: 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/* em-sized spinner so it tracks the button font; reduced-motion safe. */
|
|
178
|
+
.spinner {
|
|
179
|
+
display: inline-block;
|
|
180
|
+
width: 1em;
|
|
181
|
+
height: 1em;
|
|
182
|
+
border: 2px solid currentColor;
|
|
183
|
+
border-top-color: transparent;
|
|
184
|
+
box-sizing: border-box;
|
|
185
|
+
animation: ss-btn-spin var(--ss-dur-xslow) linear infinite;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@keyframes ss-btn-spin {
|
|
189
|
+
to {
|
|
190
|
+
transform: rotate(360deg);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
@media (prefers-reduced-motion: reduce) {
|
|
194
|
+
.spinner {
|
|
195
|
+
animation: none;
|
|
196
|
+
}
|
|
60
197
|
}</style>
|
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
2
3
|
import { type Size } from '../config.js';
|
|
3
|
-
interface Props {
|
|
4
|
-
variant?: 'primary' | 'secondary' | 'ghost';
|
|
4
|
+
interface Props extends HTMLButtonAttributes {
|
|
5
|
+
variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
|
|
5
6
|
type?: 'button' | 'submit' | 'reset';
|
|
6
7
|
disabled?: boolean;
|
|
8
|
+
/** Loading state: shows a spinner, blocks clicks, sets aria-busy; stays focusable. */
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
/** Accessible name while loading (keeps the name stable when the label is hidden). */
|
|
11
|
+
loadingLabel?: string;
|
|
7
12
|
onclick?: (e: MouseEvent) => void;
|
|
8
13
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
9
14
|
size?: Size;
|
|
10
|
-
|
|
15
|
+
/** Icon-only square button — `label` is required and becomes the aria-label. */
|
|
16
|
+
iconOnly?: boolean;
|
|
17
|
+
/** Accessible name; required for icon-only buttons (→ aria-label). */
|
|
18
|
+
label?: string;
|
|
19
|
+
/** Block-level: stretch to fill the inline axis and center the content. */
|
|
20
|
+
fullWidth?: boolean;
|
|
21
|
+
/** Leading icon snippet, rendered before children. */
|
|
22
|
+
leading?: Snippet;
|
|
23
|
+
/** Trailing icon snippet, rendered after children. */
|
|
24
|
+
trailing?: Snippet;
|
|
25
|
+
children?: Snippet;
|
|
26
|
+
/** Bound reference to the underlying <button>. */
|
|
27
|
+
el?: HTMLButtonElement;
|
|
11
28
|
}
|
|
12
|
-
declare const Button: import("svelte").Component<Props, {}, "">;
|
|
29
|
+
declare const Button: import("svelte").Component<Props, {}, "el">;
|
|
13
30
|
type Button = ReturnType<typeof Button>;
|
|
14
31
|
export default Button;
|