dssoca 0.11.0 → 0.12.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/dist/components/Accordion.svelte +35 -15
- package/dist/components/Accordion.svelte.d.ts +7 -0
- package/dist/components/Avatar.svelte +5 -9
- package/dist/components/Badge.svelte +27 -53
- package/dist/components/Badge.svelte.d.ts +2 -5
- package/dist/components/BottomNav.svelte +2 -2
- package/dist/components/BoxPlot.svelte +2 -8
- package/dist/components/BumpChart.svelte +2 -8
- package/dist/components/Button.svelte +50 -34
- package/dist/components/Button.svelte.d.ts +8 -2
- package/dist/components/Chart.svelte +2 -8
- package/dist/components/DateField.svelte +1 -1
- package/dist/components/FileDrop.svelte +1 -1
- package/dist/components/Icon.svelte +29 -7
- package/dist/components/Icon.svelte.d.ts +14 -2
- package/dist/components/Input.svelte +1 -1
- package/dist/components/LogStream.svelte +3 -3
- package/dist/components/Menu.svelte +1 -1
- package/dist/components/NumberField.svelte +1 -1
- package/dist/components/ScatterPlot.svelte +2 -8
- package/dist/components/Select.svelte +1 -1
- package/dist/components/ServiceCard.svelte +13 -2
- package/dist/components/Sidebar.svelte +1 -1
- package/dist/components/Spinner.svelte +26 -19
- package/dist/components/Spinner.svelte.d.ts +14 -4
- package/dist/components/Textarea.svelte +1 -1
- package/dist/components/Topbar.svelte +2 -2
- package/dist/config.d.ts +44 -3
- package/dist/config.js +52 -3
- package/dist/dssoca.config.d.ts +38 -1
- package/dist/dssoca.config.js +47 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +6 -4
- package/dist/palette.d.ts +10 -0
- package/dist/palette.js +17 -0
- package/dist/theme.css +158 -158
- package/dist/tokens.css +158 -158
- package/package.json +3 -2
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
'<circle cx="12" cy="12" r="3"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1"/>',
|
|
12
12
|
user: '<circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-7 8-7s8 3 8 7"/>',
|
|
13
13
|
arrow: '<path d="M5 12h14M13 5l7 7-7 7"/>',
|
|
14
|
+
chevron: '<path d="M8 10l4 4 4-4"/>',
|
|
14
15
|
external: '<path d="M7 17L17 7M9 7h8v8"/>',
|
|
15
16
|
film: '<rect x="3" y="4" width="18" height="16"/><path d="M3 8h4M3 16h4M17 8h4M17 16h4M3 12h18"/>',
|
|
16
17
|
note: '<rect x="4" y="3" width="16" height="18"/><path d="M8 8h8M8 12h8M8 16h6"/>',
|
|
@@ -62,14 +63,26 @@
|
|
|
62
63
|
<script lang="ts">
|
|
63
64
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
64
65
|
|
|
65
|
-
/**
|
|
66
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Icon-local size scale (DS-0109). Distinct from the global `Size` axis
|
|
68
|
+
* (`sm | md | lg`): Icon adds an `xs` (12px) dense step that has *no* global
|
|
69
|
+
* `data-size-variant` counterpart — it pins directly via {@link SIZE_PX}. The
|
|
70
|
+
* named scale is fixed at xs 12 / sm 16 / md 20 / lg 24 px.
|
|
71
|
+
*/
|
|
72
|
+
export type IconSize = 'xs' | Size
|
|
73
|
+
|
|
74
|
+
/** Fixed px for each named Icon size — used to keep absolute stroke optically constant. */
|
|
75
|
+
const SIZE_PX: Record<IconSize, number> = { xs: 12, sm: 16, md: 20, lg: 24 }
|
|
67
76
|
const DEFAULT_PX = SIZE_PX.md
|
|
68
77
|
|
|
69
78
|
interface Props {
|
|
70
79
|
name: IconName
|
|
71
|
-
/**
|
|
72
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Icon-local size (`xs | sm | md | lg`, a fixed px scale); inherits the
|
|
82
|
+
* active `--ss-icon` token when unset. `xs` (12px) is Icon-only and has no
|
|
83
|
+
* global size-variant equivalent.
|
|
84
|
+
*/
|
|
85
|
+
size?: IconSize
|
|
73
86
|
/** Explicit pixel size — overrides the token sizing. */
|
|
74
87
|
px?: number
|
|
75
88
|
/**
|
|
@@ -118,7 +131,12 @@
|
|
|
118
131
|
class: cls = '',
|
|
119
132
|
}: Props = $props()
|
|
120
133
|
|
|
121
|
-
|
|
134
|
+
// Box size: an explicit `px` wins; a named `size` pins to the fixed scale
|
|
135
|
+
// (incl. the Icon-only `xs` = 12px, which has no global token); when both are
|
|
136
|
+
// unset the icon inherits the active `--ss-icon` token through the cascade.
|
|
137
|
+
const dim = $derived(
|
|
138
|
+
px != null ? `${px}px` : size != null ? `${SIZE_PX[size]}px` : 'var(--ss-icon)',
|
|
139
|
+
)
|
|
122
140
|
|
|
123
141
|
// Resolve the glyph: explicit `paths` escape hatch → registered/built-in → warn.
|
|
124
142
|
const markup = $derived.by(() => {
|
|
@@ -134,12 +152,16 @@
|
|
|
134
152
|
})
|
|
135
153
|
|
|
136
154
|
// Optically-constant stroke: recompute weight from the resolved px so a
|
|
137
|
-
// 2u stroke at the canonical 24-unit viewBox looks the same at
|
|
155
|
+
// 2u stroke at the canonical 24-unit viewBox looks the same at 12/16/20/24px.
|
|
138
156
|
const resolvedPx = $derived(px != null ? px : (SIZE_PX[size ?? 'md'] ?? DEFAULT_PX))
|
|
139
157
|
const stroke = $derived(absoluteStroke ? (strokeWidth * 24) / resolvedPx : strokeWidth)
|
|
140
158
|
|
|
141
159
|
const isSolid = $derived(variant === 'solid')
|
|
142
160
|
|
|
161
|
+
// The global `data-size-variant` axis is sm|md|lg only; the Icon-local `xs`
|
|
162
|
+
// step has no axis equivalent (it pins via `dim` above), so it is omitted.
|
|
163
|
+
const axisSize = $derived<Size | undefined>(size === 'xs' ? undefined : size)
|
|
164
|
+
|
|
143
165
|
// Decorative unless an explicit title (or explicit decorative=false) opts in.
|
|
144
166
|
const isDecorative = $derived(decorative ?? title == null)
|
|
145
167
|
|
|
@@ -174,7 +196,7 @@
|
|
|
174
196
|
class:spin
|
|
175
197
|
class:flip-h={flip === 'horizontal'}
|
|
176
198
|
class:flip-v={flip === 'vertical'}
|
|
177
|
-
data-size-variant={resolveComponentSize('Icon',
|
|
199
|
+
data-size-variant={resolveComponentSize('Icon', axisSize)}
|
|
178
200
|
data-rotate={rotate || undefined}
|
|
179
201
|
style="width:{dim};height:{dim}"
|
|
180
202
|
role={labelled ? 'img' : undefined}
|
|
@@ -9,6 +9,7 @@ declare const BUILTIN_PATHS: {
|
|
|
9
9
|
readonly settings: "<circle cx=\"12\" cy=\"12\" r=\"3\"/><path d=\"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1\"/>";
|
|
10
10
|
readonly user: "<circle cx=\"12\" cy=\"8\" r=\"4\"/><path d=\"M4 21c0-4 4-7 8-7s8 3 8 7\"/>";
|
|
11
11
|
readonly arrow: "<path d=\"M5 12h14M13 5l7 7-7 7\"/>";
|
|
12
|
+
readonly chevron: "<path d=\"M8 10l4 4 4-4\"/>";
|
|
12
13
|
readonly external: "<path d=\"M7 17L17 7M9 7h8v8\"/>";
|
|
13
14
|
readonly film: "<rect x=\"3\" y=\"4\" width=\"18\" height=\"16\"/><path d=\"M3 8h4M3 16h4M17 8h4M17 16h4M3 12h18\"/>";
|
|
14
15
|
readonly note: "<rect x=\"4\" y=\"3\" width=\"16\" height=\"18\"/><path d=\"M8 8h8M8 12h8M8 16h6\"/>";
|
|
@@ -44,10 +45,21 @@ export declare function registerIcon(name: string, paths: string): void;
|
|
|
44
45
|
/** Look a glyph up; built-ins first, then runtime registrations. */
|
|
45
46
|
export declare function resolveIcon(name: string): string | undefined;
|
|
46
47
|
import { type Size } from '../config.js';
|
|
48
|
+
/**
|
|
49
|
+
* Icon-local size scale (DS-0109). Distinct from the global `Size` axis
|
|
50
|
+
* (`sm | md | lg`): Icon adds an `xs` (12px) dense step that has *no* global
|
|
51
|
+
* `data-size-variant` counterpart — it pins directly via {@link SIZE_PX}. The
|
|
52
|
+
* named scale is fixed at xs 12 / sm 16 / md 20 / lg 24 px.
|
|
53
|
+
*/
|
|
54
|
+
export type IconSize = 'xs' | Size;
|
|
47
55
|
interface Props {
|
|
48
56
|
name: IconName;
|
|
49
|
-
/**
|
|
50
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Icon-local size (`xs | sm | md | lg`, a fixed px scale); inherits the
|
|
59
|
+
* active `--ss-icon` token when unset. `xs` (12px) is Icon-only and has no
|
|
60
|
+
* global size-variant equivalent.
|
|
61
|
+
*/
|
|
62
|
+
size?: IconSize;
|
|
51
63
|
/** Explicit pixel size — overrides the token sizing. */
|
|
52
64
|
px?: number;
|
|
53
65
|
/**
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
}
|
|
164
164
|
.ss-field.invalid .control:focus-within {
|
|
165
165
|
border-color: var(--ss-red);
|
|
166
|
-
box-shadow: 0 0 0 3px
|
|
166
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--ss-danger) 22%, transparent);
|
|
167
167
|
}
|
|
168
168
|
.ss-field.disabled .control {
|
|
169
169
|
border-color: var(--ss-line);
|
|
@@ -316,7 +316,7 @@
|
|
|
316
316
|
font-family: var(--ss-font-mono);
|
|
317
317
|
font-size: var(--ss-ui-sm);
|
|
318
318
|
line-height: 1;
|
|
319
|
-
padding: var(--ss-
|
|
319
|
+
padding: var(--ss-chip-py) var(--ss-badge-px);
|
|
320
320
|
border: 1px solid var(--ss-line);
|
|
321
321
|
background: transparent;
|
|
322
322
|
color: var(--ss-code-fg);
|
|
@@ -350,7 +350,7 @@
|
|
|
350
350
|
min-width: 8ch;
|
|
351
351
|
font-family: var(--ss-font-mono);
|
|
352
352
|
font-size: var(--ss-ui-sm);
|
|
353
|
-
padding: var(--ss-
|
|
353
|
+
padding: var(--ss-chip-py) var(--ss-gap-sm);
|
|
354
354
|
border: 1px solid var(--ss-line);
|
|
355
355
|
background: transparent;
|
|
356
356
|
color: var(--ss-code-fg);
|
|
@@ -442,7 +442,7 @@
|
|
|
442
442
|
font-family: var(--ss-font-mono);
|
|
443
443
|
font-size: var(--ss-ui-sm);
|
|
444
444
|
line-height: 1;
|
|
445
|
-
padding: var(--ss-
|
|
445
|
+
padding: var(--ss-chip-py) var(--ss-badge-px);
|
|
446
446
|
border: 1px solid var(--ss-line-strong);
|
|
447
447
|
background: var(--ss-bg-elev);
|
|
448
448
|
color: var(--ss-fg);
|
|
@@ -369,7 +369,7 @@
|
|
|
369
369
|
}
|
|
370
370
|
.item.selected {
|
|
371
371
|
color: var(--ss-fg);
|
|
372
|
-
background:
|
|
372
|
+
background: color-mix(in srgb, var(--ss-accent) 6%, transparent);
|
|
373
373
|
}
|
|
374
374
|
.item:disabled, .item[aria-disabled=true] {
|
|
375
375
|
color: var(--ss-fg-faint);
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
}
|
|
181
181
|
.ss-numberfield.invalid .control:focus-within {
|
|
182
182
|
border-color: var(--ss-red);
|
|
183
|
-
box-shadow: 0 0 0 3px
|
|
183
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--ss-danger) 22%, transparent);
|
|
184
184
|
}
|
|
185
185
|
.ss-numberfield.disabled .control {
|
|
186
186
|
border-color: var(--ss-line);
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
14
|
<script lang="ts">
|
|
15
|
+
import { CHART_PALETTE } from '../palette.js'
|
|
15
16
|
import { scaleLinear, scaleSqrt } from 'd3-scale'
|
|
16
17
|
import { extent, max } from 'd3-array'
|
|
17
18
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
@@ -73,14 +74,7 @@
|
|
|
73
74
|
size,
|
|
74
75
|
}: Props = $props()
|
|
75
76
|
|
|
76
|
-
const PALETTE =
|
|
77
|
-
'var(--ss-primary)',
|
|
78
|
-
'var(--ss-blue)',
|
|
79
|
-
'var(--ss-purple)',
|
|
80
|
-
'var(--ss-cyan)',
|
|
81
|
-
'var(--ss-yellow)',
|
|
82
|
-
'var(--ss-lime)',
|
|
83
|
-
]
|
|
77
|
+
const PALETTE = CHART_PALETTE
|
|
84
78
|
|
|
85
79
|
const M = { top: 12, right: 16, bottom: 36, left: 48 }
|
|
86
80
|
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
}
|
|
162
162
|
.ss-select.invalid .control:focus-within {
|
|
163
163
|
border-color: var(--ss-red);
|
|
164
|
-
box-shadow: 0 0 0 3px
|
|
164
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--ss-danger) 22%, transparent);
|
|
165
165
|
}
|
|
166
166
|
.ss-select.disabled .control {
|
|
167
167
|
border-color: var(--ss-line);
|
|
@@ -56,6 +56,17 @@
|
|
|
56
56
|
status === 'deg' ? 'degraded' : status === 'maint' ? 'maintenance' : status,
|
|
57
57
|
)
|
|
58
58
|
|
|
59
|
+
// Map the service status onto a Badge semantic tone (DS-0119).
|
|
60
|
+
const badgeTone = $derived(
|
|
61
|
+
status === 'deg'
|
|
62
|
+
? 'caution'
|
|
63
|
+
: status === 'down'
|
|
64
|
+
? 'critical'
|
|
65
|
+
: status === 'maint'
|
|
66
|
+
? 'brand'
|
|
67
|
+
: 'positive',
|
|
68
|
+
)
|
|
69
|
+
|
|
59
70
|
// Status is decorative on the dot/badge, but meaningful — fold it into the label.
|
|
60
71
|
const cardLabel = $derived(`${name}, ${statusLabel}`)
|
|
61
72
|
|
|
@@ -99,7 +110,7 @@
|
|
|
99
110
|
{#if loading}
|
|
100
111
|
<div class="sk sk-badge" aria-hidden="true"></div>
|
|
101
112
|
{:else}
|
|
102
|
-
<Badge tone={
|
|
113
|
+
<Badge tone={badgeTone}>{statusLabel}</Badge>
|
|
103
114
|
<div class="latency">{latency}</div>
|
|
104
115
|
{/if}
|
|
105
116
|
</div>
|
|
@@ -285,7 +296,7 @@ a.ss-svc:focus-visible,
|
|
|
285
296
|
|
|
286
297
|
.sk-badge {
|
|
287
298
|
width: 64px;
|
|
288
|
-
height: calc(var(--ss-ui-xs) + var(--ss-
|
|
299
|
+
height: calc(var(--ss-ui-xs) + var(--ss-chip-py) * 2);
|
|
289
300
|
}
|
|
290
301
|
|
|
291
302
|
.sk-spark {
|
|
@@ -380,7 +380,7 @@
|
|
|
380
380
|
}
|
|
381
381
|
.ss-side .item.active {
|
|
382
382
|
color: var(--ss-fg);
|
|
383
|
-
background:
|
|
383
|
+
background: color-mix(in srgb, var(--ss-accent) 6%, transparent);
|
|
384
384
|
border-left-color: var(--ss-primary);
|
|
385
385
|
}
|
|
386
386
|
.ss-side .item .label {
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
+
import { type SpinnerVariant as SpinnerVariantName } from '../dssoca.config.js'
|
|
3
|
+
|
|
4
|
+
// Surfaced for backward compatibility (consumers importing from this component
|
|
5
|
+
// path); the source of truth is `dssoca.config.ts` (DS-0108). The const is a
|
|
6
|
+
// plain re-export; the type is aliased so it doesn't collide with the import.
|
|
7
|
+
export { SPINNER_VARIANT_NAMES } from '../dssoca.config.js'
|
|
8
|
+
export type SpinnerVariant = SpinnerVariantName
|
|
9
|
+
|
|
2
10
|
/**
|
|
3
11
|
* Text-frame spinner variants. Frames + intervals are embedded verbatim from
|
|
4
12
|
* sindresorhus/cli-spinners (MIT — https://github.com/sindresorhus/cli-spinners),
|
|
5
13
|
* curated for the squared/blocky glyphs that fit the DS's zero-radius look.
|
|
6
14
|
* No runtime fetch, no dependency — just data.
|
|
15
|
+
*
|
|
16
|
+
* The *variant names* are owned by `dssoca.config.ts` (`SpinnerVariant`,
|
|
17
|
+
* derived from the `spinner` manifest axis — DS-0108); this object holds the
|
|
18
|
+
* frame data and is pinned to that union via `satisfies Record<SpinnerVariant,
|
|
19
|
+
* …>`, so the two cannot drift.
|
|
7
20
|
*/
|
|
8
21
|
export interface SpinnerFrames {
|
|
9
22
|
/** Milliseconds between frames (cli-spinners' recommended cadence). */
|
|
@@ -26,19 +39,19 @@
|
|
|
26
39
|
interval: 120,
|
|
27
40
|
frames: ['▏', '▎', '▍', '▌', '▋', '▊', '▉', '▊', '▋', '▌', '▍', '▎'],
|
|
28
41
|
},
|
|
29
|
-
} as const satisfies Record<
|
|
30
|
-
|
|
31
|
-
export type SpinnerVariant = keyof typeof SPINNER_VARIANTS
|
|
32
|
-
|
|
33
|
-
export const SPINNER_VARIANT_NAMES = Object.keys(SPINNER_VARIANTS) as SpinnerVariant[]
|
|
42
|
+
} as const satisfies Record<SpinnerVariantName, SpinnerFrames>
|
|
34
43
|
</script>
|
|
35
44
|
|
|
36
45
|
<script lang="ts">
|
|
37
|
-
import { resolveComponentSize, type Size } from '../config.js'
|
|
46
|
+
import { resolveComponentSize, resolveSpinnerVariant, type Size } from '../config.js'
|
|
38
47
|
|
|
39
48
|
interface Props {
|
|
40
|
-
/**
|
|
41
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Which frame set to animate (curated from cli-spinners, MIT). When unset,
|
|
51
|
+
* falls back to the configured global default (`spinnerVariant`, default
|
|
52
|
+
* `boxBounce2`); an explicit value here always wins (DS-0108).
|
|
53
|
+
*/
|
|
54
|
+
variant?: SpinnerVariantName
|
|
42
55
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
43
56
|
size?: Size
|
|
44
57
|
/** Accessible name announced via role="status". */
|
|
@@ -50,19 +63,13 @@
|
|
|
50
63
|
/** Any remaining native attributes are forwarded to the root span. */
|
|
51
64
|
[key: string]: unknown
|
|
52
65
|
}
|
|
53
|
-
let {
|
|
54
|
-
variant = 'boxBounce2',
|
|
55
|
-
size,
|
|
56
|
-
label = 'Loading',
|
|
57
|
-
showLabel = false,
|
|
58
|
-
speed,
|
|
59
|
-
...rest
|
|
60
|
-
}: Props = $props()
|
|
66
|
+
let { variant, size, label = 'Loading', showLabel = false, speed, ...rest }: Props = $props()
|
|
61
67
|
|
|
62
|
-
|
|
68
|
+
// An explicit `variant` prop wins; otherwise fall back to the configured
|
|
69
|
+
// house default (`spinnerVariant`, from the manifest) — DS-0108.
|
|
70
|
+
const resolvedVariant = $derived(resolveSpinnerVariant(variant))
|
|
71
|
+
const spinner = $derived(SPINNER_VARIANTS[resolvedVariant])
|
|
63
72
|
const interval = $derived(speed ?? spinner.interval)
|
|
64
|
-
// 'Spinner' is not in the ComponentName union yet (manifest is owned by the
|
|
65
|
-
// integration step) — cast until dssoca.config.ts registers it.
|
|
66
73
|
const resolvedSize = $derived(resolveComponentSize('Spinner', size))
|
|
67
74
|
|
|
68
75
|
// Under prefers-reduced-motion the first frame renders statically — no cycling.
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import { type SpinnerVariant as SpinnerVariantName } from '../dssoca.config.js';
|
|
2
|
+
export { SPINNER_VARIANT_NAMES } from '../dssoca.config.js';
|
|
3
|
+
export type SpinnerVariant = SpinnerVariantName;
|
|
1
4
|
/**
|
|
2
5
|
* Text-frame spinner variants. Frames + intervals are embedded verbatim from
|
|
3
6
|
* sindresorhus/cli-spinners (MIT — https://github.com/sindresorhus/cli-spinners),
|
|
4
7
|
* curated for the squared/blocky glyphs that fit the DS's zero-radius look.
|
|
5
8
|
* No runtime fetch, no dependency — just data.
|
|
9
|
+
*
|
|
10
|
+
* The *variant names* are owned by `dssoca.config.ts` (`SpinnerVariant`,
|
|
11
|
+
* derived from the `spinner` manifest axis — DS-0108); this object holds the
|
|
12
|
+
* frame data and is pinned to that union via `satisfies Record<SpinnerVariant,
|
|
13
|
+
* …>`, so the two cannot drift.
|
|
6
14
|
*/
|
|
7
15
|
export interface SpinnerFrames {
|
|
8
16
|
/** Milliseconds between frames (cli-spinners' recommended cadence). */
|
|
@@ -52,12 +60,14 @@ export declare const SPINNER_VARIANTS: {
|
|
|
52
60
|
readonly frames: readonly ["▏", "▎", "▍", "▌", "▋", "▊", "▉", "▊", "▋", "▌", "▍", "▎"];
|
|
53
61
|
};
|
|
54
62
|
};
|
|
55
|
-
export type SpinnerVariant = keyof typeof SPINNER_VARIANTS;
|
|
56
|
-
export declare const SPINNER_VARIANT_NAMES: SpinnerVariant[];
|
|
57
63
|
import { type Size } from '../config.js';
|
|
58
64
|
interface Props {
|
|
59
|
-
/**
|
|
60
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Which frame set to animate (curated from cli-spinners, MIT). When unset,
|
|
67
|
+
* falls back to the configured global default (`spinnerVariant`, default
|
|
68
|
+
* `boxBounce2`); an explicit value here always wins (DS-0108).
|
|
69
|
+
*/
|
|
70
|
+
variant?: SpinnerVariantName;
|
|
61
71
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
62
72
|
size?: Size;
|
|
63
73
|
/** Accessible name announced via role="status". */
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
}
|
|
159
159
|
.ss-textarea.invalid .control:focus-within {
|
|
160
160
|
border-color: var(--ss-red);
|
|
161
|
-
box-shadow: 0 0 0 3px
|
|
161
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--ss-danger) 22%, transparent);
|
|
162
162
|
}
|
|
163
163
|
.ss-textarea.disabled .control {
|
|
164
164
|
border-color: var(--ss-line);
|
|
@@ -293,7 +293,7 @@
|
|
|
293
293
|
left: var(--ss-s-1);
|
|
294
294
|
top: var(--ss-s-1);
|
|
295
295
|
z-index: 20;
|
|
296
|
-
padding: var(--ss-
|
|
296
|
+
padding: var(--ss-chip-py) var(--ss-badge-px);
|
|
297
297
|
background: var(--ss-primary);
|
|
298
298
|
color: var(--ss-fg-on-primary);
|
|
299
299
|
font: 500 var(--ss-ui-md) var(--ss-font-mono);
|
|
@@ -383,7 +383,7 @@
|
|
|
383
383
|
}
|
|
384
384
|
.ss-topbar .ws .tab.active {
|
|
385
385
|
color: var(--ss-fg);
|
|
386
|
-
background:
|
|
386
|
+
background: color-mix(in srgb, var(--ss-accent) 6%, transparent);
|
|
387
387
|
box-shadow: inset 0 -2px 0 var(--ss-primary);
|
|
388
388
|
}
|
|
389
389
|
.ss-topbar .ws .tab.active .n {
|
package/dist/config.d.ts
CHANGED
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
* 2. `componentsSize[Name]` (per-component default)
|
|
13
13
|
* 3. `sizeVariant` on an ancestor (global default; `md` out of the box)
|
|
14
14
|
*/
|
|
15
|
-
import { dssocaConfig, type ColorTheme, type Size, type ComponentName, type ComponentsSize } from './dssoca.config.js';
|
|
16
|
-
export { dssocaConfig };
|
|
17
|
-
export type { ColorTheme, Size, ComponentName, ComponentsSize };
|
|
15
|
+
import { dssocaConfig, PALETTE_SLOTS, type ColorTheme, type Size, type ComponentName, type ComponentsSize, type SpinnerVariant, type Palette, type ThemePalette, type PaletteSlot } from './dssoca.config.js';
|
|
16
|
+
export { dssocaConfig, PALETTE_SLOTS };
|
|
17
|
+
export type { ColorTheme, Size, ComponentName, ComponentsSize, SpinnerVariant };
|
|
18
|
+
export type { Palette, ThemePalette, PaletteSlot };
|
|
18
19
|
export type { DssocaConfig, DesignAxis } from './dssoca.config.js';
|
|
19
20
|
export interface DesignConfig {
|
|
20
21
|
theme: ColorTheme;
|
|
@@ -22,9 +23,28 @@ export interface DesignConfig {
|
|
|
22
23
|
sizeVariant: Size;
|
|
23
24
|
/** Per-component default sizes; components not listed inherit `sizeVariant`. */
|
|
24
25
|
componentsSize: ComponentsSize;
|
|
26
|
+
/**
|
|
27
|
+
* Global default Spinner glyph (DS-0108). Unlike `theme`/`sizeVariant` this is
|
|
28
|
+
* NOT a CSS axis — it is never painted as a `data-*` attribute (see
|
|
29
|
+
* `designAttributes`, which intentionally omits it). It threads to the Spinner
|
|
30
|
+
* component through `resolveSpinnerVariant`; a per-usage `variant` prop wins.
|
|
31
|
+
*/
|
|
32
|
+
spinnerVariant: SpinnerVariant;
|
|
33
|
+
/**
|
|
34
|
+
* Custom root palette (color rework) — both themes' 19 slot values, e.g.
|
|
35
|
+
* generated by the docs Theme Builder. `null` = the built-in palette.
|
|
36
|
+
* Tri-state in `applyDesignConfig` partials: omit to keep the current
|
|
37
|
+
* palette, pass a `Palette` to set one, pass `null` to clear back to the
|
|
38
|
+
* stylesheet values. Applied as inline custom properties for the ACTIVE
|
|
39
|
+
* theme only, and re-written on every call so a theme flip never gets
|
|
40
|
+
* masked by stale inline values.
|
|
41
|
+
*/
|
|
42
|
+
palette: Palette | null;
|
|
25
43
|
}
|
|
26
44
|
/** Defaults derived from the manifest — change them in `dssoca.config.ts`. */
|
|
27
45
|
export declare const defaultDesignConfig: DesignConfig;
|
|
46
|
+
/** camelCase slot → its CSS custom property ('brightBlack' → '--ss-bright-black'). */
|
|
47
|
+
export declare const paletteSlotVar: (slot: PaletteSlot) => string;
|
|
28
48
|
/** Current resolved config (last applied, or defaults). */
|
|
29
49
|
export declare function getDesignConfig(): DesignConfig;
|
|
30
50
|
/**
|
|
@@ -32,6 +52,10 @@ export declare function getDesignConfig(): DesignConfig;
|
|
|
32
52
|
* correct theme + size paint on the first frame with no flash.
|
|
33
53
|
*
|
|
34
54
|
* <html {...designAttributes({ sizeVariant: 'sm' })}> … </html>
|
|
55
|
+
*
|
|
56
|
+
* Only the CSS axes (`theme`, `sizeVariant`) appear here. `spinnerVariant` is a
|
|
57
|
+
* default-prop axis, not a CSS one, so it is deliberately omitted (DS-0108) — it
|
|
58
|
+
* is consumed via `resolveSpinnerVariant`, never as a `data-*` attribute.
|
|
35
59
|
*/
|
|
36
60
|
export declare function designAttributes(config?: Partial<DesignConfig>): {
|
|
37
61
|
'data-theme': ColorTheme;
|
|
@@ -43,6 +67,15 @@ export declare function designAttributes(config?: Partial<DesignConfig>): {
|
|
|
43
67
|
* merged key-by-key). SSR-safe: no-op when no document and no explicit target.
|
|
44
68
|
*/
|
|
45
69
|
export declare function applyDesignConfig(config?: Partial<DesignConfig>, target?: HTMLElement): DesignConfig;
|
|
70
|
+
/**
|
|
71
|
+
* Emit a custom palette as a CSS override block — the zero-JS / SSR path. Ship
|
|
72
|
+
* it AFTER `dssoca/theme.css` in source order (equal specificity, order wins):
|
|
73
|
+
*
|
|
74
|
+
* <style>{paletteToCss(palette)}</style>
|
|
75
|
+
*
|
|
76
|
+
* The docs Theme Builder's "CSS" export is exactly this output.
|
|
77
|
+
*/
|
|
78
|
+
export declare function paletteToCss(palette: Palette): string;
|
|
46
79
|
/**
|
|
47
80
|
* Resolve the size a component should APPLY on its own root (as
|
|
48
81
|
* `data-size-variant`), or `undefined` to inherit the global `sizeVariant`
|
|
@@ -50,3 +83,11 @@ export declare function applyDesignConfig(config?: Partial<DesignConfig>, target
|
|
|
50
83
|
* `componentsSize[name]` → inherit.
|
|
51
84
|
*/
|
|
52
85
|
export declare function resolveComponentSize(name: ComponentName, size?: Size): Size | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Resolve the Spinner glyph a component should render: an explicit `variant`
|
|
88
|
+
* wins, else the configured global `spinnerVariant` (DS-0108). Mirrors
|
|
89
|
+
* `resolveComponentSize`, but ALWAYS returns a concrete variant (never
|
|
90
|
+
* `undefined`) — there is no CSS cascade for the glyph, so the component needs a
|
|
91
|
+
* definite value to pick frames.
|
|
92
|
+
*/
|
|
93
|
+
export declare function resolveSpinnerVariant(variant?: SpinnerVariant): SpinnerVariant;
|
package/dist/config.js
CHANGED
|
@@ -12,28 +12,41 @@
|
|
|
12
12
|
* 2. `componentsSize[Name]` (per-component default)
|
|
13
13
|
* 3. `sizeVariant` on an ancestor (global default; `md` out of the box)
|
|
14
14
|
*/
|
|
15
|
-
import { dssocaConfig, } from './dssoca.config.js';
|
|
15
|
+
import { dssocaConfig, PALETTE_SLOTS, } from './dssoca.config.js';
|
|
16
16
|
// Re-exported so the `dssoca` / `./config` import paths expose the config vocab.
|
|
17
|
-
export { dssocaConfig };
|
|
17
|
+
export { dssocaConfig, PALETTE_SLOTS };
|
|
18
18
|
/** Defaults derived from the manifest — change them in `dssoca.config.ts`. */
|
|
19
19
|
export const defaultDesignConfig = {
|
|
20
20
|
theme: dssocaConfig.theme.default,
|
|
21
21
|
sizeVariant: dssocaConfig.size.default,
|
|
22
22
|
componentsSize: {},
|
|
23
|
+
spinnerVariant: dssocaConfig.spinner.default,
|
|
24
|
+
palette: null,
|
|
23
25
|
};
|
|
24
26
|
let current = {
|
|
25
27
|
...defaultDesignConfig,
|
|
26
28
|
componentsSize: { ...defaultDesignConfig.componentsSize },
|
|
27
29
|
};
|
|
30
|
+
const copyPalette = (p) => p === null ? null : { dark: { ...p.dark }, light: { ...p.light } };
|
|
31
|
+
/** camelCase slot → its CSS custom property ('brightBlack' → '--ss-bright-black'). */
|
|
32
|
+
export const paletteSlotVar = (slot) => '--ss-' + slot.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());
|
|
28
33
|
/** Current resolved config (last applied, or defaults). */
|
|
29
34
|
export function getDesignConfig() {
|
|
30
|
-
return {
|
|
35
|
+
return {
|
|
36
|
+
...current,
|
|
37
|
+
componentsSize: { ...current.componentsSize },
|
|
38
|
+
palette: copyPalette(current.palette),
|
|
39
|
+
};
|
|
31
40
|
}
|
|
32
41
|
/**
|
|
33
42
|
* Build the `data-*` attribute map for a config — handy for SSR / markup so the
|
|
34
43
|
* correct theme + size paint on the first frame with no flash.
|
|
35
44
|
*
|
|
36
45
|
* <html {...designAttributes({ sizeVariant: 'sm' })}> … </html>
|
|
46
|
+
*
|
|
47
|
+
* Only the CSS axes (`theme`, `sizeVariant`) appear here. `spinnerVariant` is a
|
|
48
|
+
* default-prop axis, not a CSS one, so it is deliberately omitted (DS-0108) — it
|
|
49
|
+
* is consumed via `resolveSpinnerVariant`, never as a `data-*` attribute.
|
|
37
50
|
*/
|
|
38
51
|
export function designAttributes(config = {}) {
|
|
39
52
|
const merged = { ...defaultDesignConfig, ...config };
|
|
@@ -49,14 +62,40 @@ export function applyDesignConfig(config = {}, target) {
|
|
|
49
62
|
...current,
|
|
50
63
|
...config,
|
|
51
64
|
componentsSize: { ...current.componentsSize, ...(config.componentsSize ?? {}) },
|
|
65
|
+
// Tri-state: absent = keep, Palette = set (defensive copy), null = clear.
|
|
66
|
+
palette: config.palette === undefined ? current.palette : copyPalette(config.palette),
|
|
52
67
|
};
|
|
53
68
|
const el = target ?? (typeof document !== 'undefined' ? document.documentElement : undefined);
|
|
54
69
|
if (el) {
|
|
55
70
|
el.setAttribute('data-theme', current.theme);
|
|
56
71
|
el.setAttribute('data-size-variant', current.sizeVariant);
|
|
72
|
+
// Palette runs on EVERY call: inline slot values always track the active
|
|
73
|
+
// theme (a later theme flip re-writes the other set), and clearing removes
|
|
74
|
+
// them so the stylesheet palette resumes.
|
|
75
|
+
for (const slot of PALETTE_SLOTS) {
|
|
76
|
+
if (current.palette)
|
|
77
|
+
el.style.setProperty(paletteSlotVar(slot), current.palette[current.theme][slot]);
|
|
78
|
+
else
|
|
79
|
+
el.style.removeProperty(paletteSlotVar(slot));
|
|
80
|
+
}
|
|
57
81
|
}
|
|
58
82
|
return getDesignConfig();
|
|
59
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Emit a custom palette as a CSS override block — the zero-JS / SSR path. Ship
|
|
86
|
+
* it AFTER `dssoca/theme.css` in source order (equal specificity, order wins):
|
|
87
|
+
*
|
|
88
|
+
* <style>{paletteToCss(palette)}</style>
|
|
89
|
+
*
|
|
90
|
+
* The docs Theme Builder's "CSS" export is exactly this output.
|
|
91
|
+
*/
|
|
92
|
+
export function paletteToCss(palette) {
|
|
93
|
+
const block = (selector, theme) => `${selector} {\n${PALETTE_SLOTS.map((s) => ` ${paletteSlotVar(s)}: ${theme[s]};`).join('\n')}\n}`;
|
|
94
|
+
return [
|
|
95
|
+
block(`:root,\n[data-theme='dark']`, palette.dark),
|
|
96
|
+
block(`[data-theme='light']`, palette.light),
|
|
97
|
+
].join('\n\n');
|
|
98
|
+
}
|
|
60
99
|
/**
|
|
61
100
|
* Resolve the size a component should APPLY on its own root (as
|
|
62
101
|
* `data-size-variant`), or `undefined` to inherit the global `sizeVariant`
|
|
@@ -66,3 +105,13 @@ export function applyDesignConfig(config = {}, target) {
|
|
|
66
105
|
export function resolveComponentSize(name, size) {
|
|
67
106
|
return size ?? current.componentsSize[name];
|
|
68
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Resolve the Spinner glyph a component should render: an explicit `variant`
|
|
110
|
+
* wins, else the configured global `spinnerVariant` (DS-0108). Mirrors
|
|
111
|
+
* `resolveComponentSize`, but ALWAYS returns a concrete variant (never
|
|
112
|
+
* `undefined`) — there is no CSS cascade for the glyph, so the component needs a
|
|
113
|
+
* definite value to pick frames.
|
|
114
|
+
*/
|
|
115
|
+
export function resolveSpinnerVariant(variant) {
|
|
116
|
+
return variant ?? current.spinnerVariant;
|
|
117
|
+
}
|
package/dist/dssoca.config.d.ts
CHANGED
|
@@ -20,11 +20,27 @@ export interface DesignAxis<Values extends readonly string[] = readonly string[]
|
|
|
20
20
|
/** The value applied when a consumer sets nothing. */
|
|
21
21
|
readonly default: Values[number];
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Shape of the manifest — one entry per axis the design system understands.
|
|
25
|
+
*
|
|
26
|
+
* Note the asymmetry: `theme` and `size` are *CSS axes* (painted as
|
|
27
|
+
* `data-theme` / `data-size-variant`); `spinner` is a plain default-prop axis
|
|
28
|
+
* (the chosen Spinner glyph) with no `data-*` attribute — it threads through the
|
|
29
|
+
* config to `resolveSpinnerVariant`, not the cascade (DS-0108).
|
|
30
|
+
*/
|
|
24
31
|
export interface DssocaConfig {
|
|
25
32
|
readonly theme: DesignAxis;
|
|
26
33
|
readonly size: DesignAxis;
|
|
34
|
+
readonly spinner: DesignAxis;
|
|
27
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Single source of truth for the Spinner *variant names* (DS-0108). The frame
|
|
38
|
+
* data lives in `Spinner.svelte`'s `SPINNER_VARIANTS`, but its keys are pinned
|
|
39
|
+
* to this list (`satisfies Record<SpinnerVariant, …>`) so the two cannot drift.
|
|
40
|
+
*/
|
|
41
|
+
export declare const SPINNER_VARIANT_NAMES: readonly ["boxBounce2", "boxBounce", "squareCorners", "toggle2", "toggle3", "toggle4", "pipe", "line", "growVertical", "growHorizontal"];
|
|
42
|
+
/** Spinner variant names — derived from the manifest's `spinner` axis. */
|
|
43
|
+
export type SpinnerVariant = (typeof dssocaConfig)['spinner']['values'][number];
|
|
28
44
|
/**
|
|
29
45
|
* The manifest. `as const` preserves the value/default literals so the unions
|
|
30
46
|
* below can be derived from it; `satisfies` validates the shape without widening.
|
|
@@ -38,9 +54,30 @@ export declare const dssocaConfig: {
|
|
|
38
54
|
readonly values: readonly ["sm", "md", "lg"];
|
|
39
55
|
readonly default: "md";
|
|
40
56
|
};
|
|
57
|
+
readonly spinner: {
|
|
58
|
+
readonly values: readonly ["boxBounce2", "boxBounce", "squareCorners", "toggle2", "toggle3", "toggle4", "pipe", "line", "growVertical", "growHorizontal"];
|
|
59
|
+
readonly default: "boxBounce2";
|
|
60
|
+
};
|
|
41
61
|
};
|
|
42
62
|
/** Color axis values — derived from the manifest (`'dark' | 'light'`). */
|
|
43
63
|
export type ColorTheme = (typeof dssocaConfig)['theme']['values'][number];
|
|
64
|
+
/**
|
|
65
|
+
* The 19 root palette slots (color rework): the 16 ANSI terminal colors plus
|
|
66
|
+
* `bg`, `fg`, and the one vivid `accent`. Every semantic `--ss-*` token derives
|
|
67
|
+
* from these, so overriding them — via `applyDesignConfig({ palette })` or a
|
|
68
|
+
* CSS block from `paletteToCss` — recolors the whole system. camelCase here;
|
|
69
|
+
* the CSS custom property is the kebab-cased `--ss-` name
|
|
70
|
+
* (`brightBlack` → `--ss-bright-black`).
|
|
71
|
+
*/
|
|
72
|
+
export declare const PALETTE_SLOTS: readonly ["bg", "fg", "accent", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "brightBlack", "brightRed", "brightGreen", "brightYellow", "brightBlue", "brightMagenta", "brightCyan", "brightWhite"];
|
|
73
|
+
export type PaletteSlot = (typeof PALETTE_SLOTS)[number];
|
|
74
|
+
/** One theme's palette — any CSS `<color>` string per slot (hex, oklch(), …). */
|
|
75
|
+
export type ThemePalette = Record<PaletteSlot, string>;
|
|
76
|
+
/** A full custom palette: both themes, e.g. generated by the docs Theme Builder. */
|
|
77
|
+
export interface Palette {
|
|
78
|
+
dark: ThemePalette;
|
|
79
|
+
light: ThemePalette;
|
|
80
|
+
}
|
|
44
81
|
/** Size axis values — derived from the manifest (`'sm' | 'md' | 'lg'`). */
|
|
45
82
|
export type Size = (typeof dssocaConfig)['size']['values'][number];
|
|
46
83
|
/** Names of the components that accept a `size` prop / `componentsSize` entry. */
|