dssoca 0.10.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 +421 -0
- package/dist/components/BoxPlot.svelte.d.ts +36 -0
- package/dist/components/BumpChart.svelte +345 -0
- package/dist/components/BumpChart.svelte.d.ts +32 -0
- 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/Heatmap.svelte +333 -0
- package/dist/components/Heatmap.svelte.d.ts +30 -0
- 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 +395 -0
- package/dist/components/ScatterPlot.svelte.d.ts +55 -0
- 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 +10 -5
- package/dist/index.js +11 -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
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { scaleLinear } from 'd3-scale'
|
|
3
|
+
import { extent } from 'd3-array'
|
|
4
|
+
import { resolveComponentSize, type Size } from '../config.js'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
/** Row labels, top→bottom. */
|
|
8
|
+
rows: string[]
|
|
9
|
+
/** Column labels, left→right. */
|
|
10
|
+
columns: string[]
|
|
11
|
+
/** values[r][c]; `null` renders a blank cell excluded from the colour scale (e.g. the diagonal). */
|
|
12
|
+
values: (number | null)[][]
|
|
13
|
+
/** Value range mapped to colour intensity; defaults to the [min, max] of all non-null values. */
|
|
14
|
+
domain?: [number, number]
|
|
15
|
+
/** Format a cell value for its text + tooltip. */
|
|
16
|
+
valueFormat?: (v: number) => string
|
|
17
|
+
/** Render the value text inside each cell. Default true. */
|
|
18
|
+
showValues?: boolean
|
|
19
|
+
/** X axis caption (drawn under the column headers). */
|
|
20
|
+
xLabel?: string
|
|
21
|
+
/** Y axis caption (drawn rotated beside the row headers). */
|
|
22
|
+
yLabel?: string
|
|
23
|
+
/** Square cell size in px. Default 48. */
|
|
24
|
+
cellSize?: number
|
|
25
|
+
/** Reveal a tooltip on hover/focus of a cell. Default true. */
|
|
26
|
+
tooltip?: boolean
|
|
27
|
+
/** SR summary + accessible name; auto-generated when absent. */
|
|
28
|
+
summary?: string
|
|
29
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
30
|
+
size?: Size
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let {
|
|
34
|
+
rows,
|
|
35
|
+
columns,
|
|
36
|
+
values,
|
|
37
|
+
domain,
|
|
38
|
+
valueFormat,
|
|
39
|
+
showValues = true,
|
|
40
|
+
xLabel,
|
|
41
|
+
yLabel,
|
|
42
|
+
cellSize = 48,
|
|
43
|
+
tooltip = true,
|
|
44
|
+
summary,
|
|
45
|
+
size,
|
|
46
|
+
}: Props = $props()
|
|
47
|
+
|
|
48
|
+
const cleanRows = $derived(rows ?? [])
|
|
49
|
+
const cleanCols = $derived(columns ?? [])
|
|
50
|
+
const isEmpty = $derived(cleanRows.length === 0 || cleanCols.length === 0)
|
|
51
|
+
|
|
52
|
+
const fmt = $derived(valueFormat ?? ((v: number) => String(v)))
|
|
53
|
+
|
|
54
|
+
// Header gutters + optional axis-label room.
|
|
55
|
+
const headLeft = $derived(72 + (yLabel ? 20 : 0))
|
|
56
|
+
const headTop = 28
|
|
57
|
+
const labelBottom = $derived(xLabel ? 24 : 0)
|
|
58
|
+
|
|
59
|
+
const gridW = $derived(cleanCols.length * cellSize)
|
|
60
|
+
const gridH = $derived(cleanRows.length * cellSize)
|
|
61
|
+
const width = $derived(headLeft + gridW)
|
|
62
|
+
const height = $derived(headTop + gridH + labelBottom)
|
|
63
|
+
|
|
64
|
+
function valueAt(r: number, c: number): number | null {
|
|
65
|
+
const v = values?.[r]?.[c]
|
|
66
|
+
return typeof v === 'number' && Number.isFinite(v) ? v : null
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const allValues = $derived.by(() => {
|
|
70
|
+
const out: number[] = []
|
|
71
|
+
for (let r = 0; r < cleanRows.length; r++) {
|
|
72
|
+
for (let c = 0; c < cleanCols.length; c++) {
|
|
73
|
+
const v = valueAt(r, c)
|
|
74
|
+
if (v !== null) out.push(v)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return out
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
const dom = $derived.by<[number, number]>(() => {
|
|
81
|
+
if (domain) return domain
|
|
82
|
+
const e = extent(allValues) as [number, number]
|
|
83
|
+
if (e[0] === undefined) return [0, 1]
|
|
84
|
+
if (e[0] === e[1]) return [e[0], e[1] + 1]
|
|
85
|
+
return e
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
// Opacity on the primary token encodes intensity.
|
|
89
|
+
const opacityScale = $derived(scaleLinear().domain(dom).range([0.12, 1]).clamp(true))
|
|
90
|
+
|
|
91
|
+
const cells = $derived.by(() =>
|
|
92
|
+
cleanRows.flatMap((row, r) =>
|
|
93
|
+
cleanCols.map((col, c) => {
|
|
94
|
+
const v = valueAt(r, c)
|
|
95
|
+
return {
|
|
96
|
+
r,
|
|
97
|
+
c,
|
|
98
|
+
row,
|
|
99
|
+
col,
|
|
100
|
+
x: headLeft + c * cellSize,
|
|
101
|
+
y: headTop + r * cellSize,
|
|
102
|
+
value: v,
|
|
103
|
+
opacity: v === null ? 0 : opacityScale(v),
|
|
104
|
+
}
|
|
105
|
+
}),
|
|
106
|
+
),
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
const autoSummary = $derived.by(() => {
|
|
110
|
+
if (isEmpty) return 'No data'
|
|
111
|
+
return `Heatmap, ${cleanRows.length} rows × ${cleanCols.length} columns.`
|
|
112
|
+
})
|
|
113
|
+
const srText = $derived(summary ?? autoSummary)
|
|
114
|
+
|
|
115
|
+
const resolvedSize = $derived(resolveComponentSize('Chart', size))
|
|
116
|
+
|
|
117
|
+
let active = $state<{ row: string; col: string; value: number; cx: number; cy: number } | null>(
|
|
118
|
+
null,
|
|
119
|
+
)
|
|
120
|
+
function show(row: string, col: string, value: number, cx: number, cy: number) {
|
|
121
|
+
if (tooltip) active = { row, col, value, cx, cy }
|
|
122
|
+
}
|
|
123
|
+
function hide() {
|
|
124
|
+
active = null
|
|
125
|
+
}
|
|
126
|
+
function cellLabel(row: string, col: string, value: number): string {
|
|
127
|
+
return `${row} vs ${col}: ${fmt(value)}`
|
|
128
|
+
}
|
|
129
|
+
</script>
|
|
130
|
+
|
|
131
|
+
<div class="ss-heatmap" data-size-variant={resolvedSize} role="group" aria-label={srText}>
|
|
132
|
+
{#if isEmpty}
|
|
133
|
+
<span class="empty" aria-hidden="true">—</span>
|
|
134
|
+
<span class="sr-only">No data</span>
|
|
135
|
+
{:else}
|
|
136
|
+
<div class="plot">
|
|
137
|
+
<svg
|
|
138
|
+
class="canvas"
|
|
139
|
+
viewBox="0 0 {width} {height}"
|
|
140
|
+
{width}
|
|
141
|
+
{height}
|
|
142
|
+
preserveAspectRatio="xMidYMid meet"
|
|
143
|
+
role="presentation"
|
|
144
|
+
>
|
|
145
|
+
<!-- column headers -->
|
|
146
|
+
{#each cleanCols as col, c}
|
|
147
|
+
<text
|
|
148
|
+
class="header col"
|
|
149
|
+
x={headLeft + c * cellSize + cellSize / 2}
|
|
150
|
+
y={headTop - 8}
|
|
151
|
+
text-anchor="middle">{col}</text
|
|
152
|
+
>
|
|
153
|
+
{/each}
|
|
154
|
+
|
|
155
|
+
<!-- row headers -->
|
|
156
|
+
{#each cleanRows as row, r}
|
|
157
|
+
<text
|
|
158
|
+
class="header row"
|
|
159
|
+
x={headLeft - 8}
|
|
160
|
+
y={headTop + r * cellSize + cellSize / 2}
|
|
161
|
+
dy="0.32em"
|
|
162
|
+
text-anchor="end">{row}</text
|
|
163
|
+
>
|
|
164
|
+
{/each}
|
|
165
|
+
|
|
166
|
+
<!-- cells -->
|
|
167
|
+
{#each cells as cell}
|
|
168
|
+
{#if cell.value === null}
|
|
169
|
+
<rect
|
|
170
|
+
class="cell cell-empty"
|
|
171
|
+
x={cell.x}
|
|
172
|
+
y={cell.y}
|
|
173
|
+
width={cellSize}
|
|
174
|
+
height={cellSize}
|
|
175
|
+
aria-hidden="true"
|
|
176
|
+
/>
|
|
177
|
+
{:else}
|
|
178
|
+
<rect
|
|
179
|
+
class="cell"
|
|
180
|
+
x={cell.x}
|
|
181
|
+
y={cell.y}
|
|
182
|
+
width={cellSize}
|
|
183
|
+
height={cellSize}
|
|
184
|
+
fill="var(--ss-primary)"
|
|
185
|
+
fill-opacity={cell.opacity}
|
|
186
|
+
tabindex="0"
|
|
187
|
+
role="button"
|
|
188
|
+
aria-label={cellLabel(cell.row, cell.col, cell.value)}
|
|
189
|
+
onfocus={() => show(cell.row, cell.col, cell.value!, cell.x + cellSize / 2, cell.y)}
|
|
190
|
+
onblur={hide}
|
|
191
|
+
onmouseenter={() =>
|
|
192
|
+
show(cell.row, cell.col, cell.value!, cell.x + cellSize / 2, cell.y)}
|
|
193
|
+
onmouseleave={hide}
|
|
194
|
+
/>
|
|
195
|
+
{#if showValues}
|
|
196
|
+
<text
|
|
197
|
+
class="cell-text"
|
|
198
|
+
x={cell.x + cellSize / 2}
|
|
199
|
+
y={cell.y + cellSize / 2}
|
|
200
|
+
dy="0.32em"
|
|
201
|
+
text-anchor="middle">{fmt(cell.value)}</text
|
|
202
|
+
>
|
|
203
|
+
{/if}
|
|
204
|
+
{/if}
|
|
205
|
+
{/each}
|
|
206
|
+
|
|
207
|
+
<!-- axis captions -->
|
|
208
|
+
{#if xLabel}
|
|
209
|
+
<text class="axis-label x" x={headLeft + gridW / 2} y={height - 6} text-anchor="middle"
|
|
210
|
+
>{xLabel}</text
|
|
211
|
+
>
|
|
212
|
+
{/if}
|
|
213
|
+
{#if yLabel}
|
|
214
|
+
<text
|
|
215
|
+
class="axis-label y"
|
|
216
|
+
transform="translate(12,{headTop + gridH / 2}) rotate(-90)"
|
|
217
|
+
text-anchor="middle">{yLabel}</text
|
|
218
|
+
>
|
|
219
|
+
{/if}
|
|
220
|
+
</svg>
|
|
221
|
+
|
|
222
|
+
{#if tooltip && active}
|
|
223
|
+
<div
|
|
224
|
+
class="tooltip"
|
|
225
|
+
role="status"
|
|
226
|
+
style="left:{(active.cx / width) * 100}%;top:{(active.cy / height) * 100}%"
|
|
227
|
+
>
|
|
228
|
+
<span class="t-label">{active.row} · {active.col}</span>
|
|
229
|
+
<span class="t-val">{fmt(active.value)}</span>
|
|
230
|
+
</div>
|
|
231
|
+
{/if}
|
|
232
|
+
</div>
|
|
233
|
+
{/if}
|
|
234
|
+
</div>
|
|
235
|
+
|
|
236
|
+
<style>.ss-heatmap {
|
|
237
|
+
display: inline-flex;
|
|
238
|
+
flex-direction: column;
|
|
239
|
+
gap: var(--ss-gap-sm);
|
|
240
|
+
font-family: var(--ss-font-body);
|
|
241
|
+
color: var(--ss-fg);
|
|
242
|
+
max-width: 100%;
|
|
243
|
+
}
|
|
244
|
+
.ss-heatmap .plot {
|
|
245
|
+
position: relative;
|
|
246
|
+
width: 100%;
|
|
247
|
+
}
|
|
248
|
+
.ss-heatmap .canvas {
|
|
249
|
+
display: block;
|
|
250
|
+
max-width: 100%;
|
|
251
|
+
height: auto;
|
|
252
|
+
overflow: visible;
|
|
253
|
+
}
|
|
254
|
+
.ss-heatmap .empty {
|
|
255
|
+
align-self: center;
|
|
256
|
+
margin: auto;
|
|
257
|
+
padding: var(--ss-gap-sm);
|
|
258
|
+
color: var(--ss-fg-muted);
|
|
259
|
+
font-family: var(--ss-font-mono);
|
|
260
|
+
line-height: 1;
|
|
261
|
+
min-height: var(--ss-chart-h, 240px);
|
|
262
|
+
display: flex;
|
|
263
|
+
align-items: center;
|
|
264
|
+
}
|
|
265
|
+
.ss-heatmap .sr-only {
|
|
266
|
+
position: absolute;
|
|
267
|
+
width: 1px;
|
|
268
|
+
height: 1px;
|
|
269
|
+
padding: 0;
|
|
270
|
+
margin: -1px;
|
|
271
|
+
overflow: hidden;
|
|
272
|
+
clip: rect(0, 0, 0, 0);
|
|
273
|
+
white-space: nowrap;
|
|
274
|
+
border: 0;
|
|
275
|
+
}
|
|
276
|
+
.ss-heatmap .header {
|
|
277
|
+
font-family: var(--ss-font-mono);
|
|
278
|
+
font-size: var(--ss-ui-xs);
|
|
279
|
+
fill: var(--ss-fg-muted);
|
|
280
|
+
}
|
|
281
|
+
.ss-heatmap .axis-label {
|
|
282
|
+
font-family: var(--ss-font-mono);
|
|
283
|
+
font-size: var(--ss-ui-xs);
|
|
284
|
+
fill: var(--ss-fg-muted);
|
|
285
|
+
}
|
|
286
|
+
.ss-heatmap .cell {
|
|
287
|
+
stroke: var(--ss-line);
|
|
288
|
+
stroke-width: 1;
|
|
289
|
+
cursor: pointer;
|
|
290
|
+
shape-rendering: crispEdges;
|
|
291
|
+
transition: fill-opacity var(--ss-dur-fast) var(--ss-ease);
|
|
292
|
+
}
|
|
293
|
+
.ss-heatmap .cell:hover {
|
|
294
|
+
fill-opacity: 1;
|
|
295
|
+
}
|
|
296
|
+
.ss-heatmap .cell:focus-visible {
|
|
297
|
+
outline: none;
|
|
298
|
+
stroke: var(--ss-fg);
|
|
299
|
+
stroke-width: 2;
|
|
300
|
+
}
|
|
301
|
+
.ss-heatmap .cell-empty {
|
|
302
|
+
fill: none;
|
|
303
|
+
cursor: default;
|
|
304
|
+
}
|
|
305
|
+
.ss-heatmap .cell-text {
|
|
306
|
+
font-family: var(--ss-font-mono);
|
|
307
|
+
font-size: var(--ss-ui-xs);
|
|
308
|
+
fill: var(--ss-fg);
|
|
309
|
+
pointer-events: none;
|
|
310
|
+
}
|
|
311
|
+
.ss-heatmap .tooltip {
|
|
312
|
+
position: absolute;
|
|
313
|
+
transform: translate(-50%, calc(-100% - 8px));
|
|
314
|
+
pointer-events: none;
|
|
315
|
+
background: var(--ss-bg-elev);
|
|
316
|
+
border: 1px solid var(--ss-line-strong);
|
|
317
|
+
padding: var(--ss-gap-sm);
|
|
318
|
+
font-size: var(--ss-ui-xs);
|
|
319
|
+
line-height: 1.3;
|
|
320
|
+
white-space: nowrap;
|
|
321
|
+
display: flex;
|
|
322
|
+
flex-direction: column;
|
|
323
|
+
gap: 2px;
|
|
324
|
+
z-index: 2;
|
|
325
|
+
}
|
|
326
|
+
.ss-heatmap .tooltip .t-label {
|
|
327
|
+
font-family: var(--ss-font-mono);
|
|
328
|
+
color: var(--ss-fg);
|
|
329
|
+
}
|
|
330
|
+
.ss-heatmap .tooltip .t-val {
|
|
331
|
+
font-family: var(--ss-font-mono);
|
|
332
|
+
color: var(--ss-fg-muted);
|
|
333
|
+
}</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Size } from '../config.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Row labels, top→bottom. */
|
|
4
|
+
rows: string[];
|
|
5
|
+
/** Column labels, left→right. */
|
|
6
|
+
columns: string[];
|
|
7
|
+
/** values[r][c]; `null` renders a blank cell excluded from the colour scale (e.g. the diagonal). */
|
|
8
|
+
values: (number | null)[][];
|
|
9
|
+
/** Value range mapped to colour intensity; defaults to the [min, max] of all non-null values. */
|
|
10
|
+
domain?: [number, number];
|
|
11
|
+
/** Format a cell value for its text + tooltip. */
|
|
12
|
+
valueFormat?: (v: number) => string;
|
|
13
|
+
/** Render the value text inside each cell. Default true. */
|
|
14
|
+
showValues?: boolean;
|
|
15
|
+
/** X axis caption (drawn under the column headers). */
|
|
16
|
+
xLabel?: string;
|
|
17
|
+
/** Y axis caption (drawn rotated beside the row headers). */
|
|
18
|
+
yLabel?: string;
|
|
19
|
+
/** Square cell size in px. Default 48. */
|
|
20
|
+
cellSize?: number;
|
|
21
|
+
/** Reveal a tooltip on hover/focus of a cell. Default true. */
|
|
22
|
+
tooltip?: boolean;
|
|
23
|
+
/** SR summary + accessible name; auto-generated when absent. */
|
|
24
|
+
summary?: string;
|
|
25
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
26
|
+
size?: Size;
|
|
27
|
+
}
|
|
28
|
+
declare const Heatmap: import("svelte").Component<Props, {}, "">;
|
|
29
|
+
type Heatmap = ReturnType<typeof Heatmap>;
|
|
30
|
+
export default Heatmap;
|
|
@@ -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);
|