basalt-ui 2.16.0 → 2.18.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/CHANGELOG.md +165 -124
- package/MIGRATING.md +133 -15
- package/agent/agents/basalt-design-reviewer.md +2 -2
- package/agent/skills/basalt-design/SKILL.md +3 -3
- package/configs/oxlint-plugin.js +2 -2
- package/dist/charts/Donut.d.ts.map +1 -1
- package/dist/charts/Donut.js +2 -2
- package/dist/charts/DualPanel.js +2 -2
- package/dist/charts/Heatmap.d.ts.map +1 -1
- package/dist/charts/Heatmap.js +2 -2
- package/dist/charts/MirroredBars.js +2 -2
- package/dist/charts/Sparkline.d.ts +4 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +3 -3
- package/dist/charts/compile.d.ts +8 -3
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +19 -9
- package/dist/charts/cursor.d.ts +14 -1
- package/dist/charts/cursor.d.ts.map +1 -1
- package/dist/charts/cursor.js +29 -3
- package/dist/charts/date-tick-format.d.ts +17 -0
- package/dist/charts/date-tick-format.d.ts.map +1 -0
- package/dist/charts/date-tick-format.js +81 -0
- package/dist/charts/panel.d.ts +2 -1
- package/dist/charts/panel.d.ts.map +1 -1
- package/dist/charts/panel.js +3 -2
- package/dist/charts/types.d.ts +5 -1
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/help.d.ts +1 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +8 -2
- package/dist/cli/shot/capture.d.ts +28 -1
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +96 -13
- package/dist/cli/shot/index.d.ts +10 -1
- package/dist/cli/shot/index.d.ts.map +1 -1
- package/dist/cli/shot/index.js +40 -5
- package/dist/cli/shot/playwright.d.ts +4 -0
- package/dist/cli/shot/playwright.d.ts.map +1 -1
- package/dist/cli/shot/real-data.d.ts +35 -0
- package/dist/cli/shot/real-data.d.ts.map +1 -0
- package/dist/cli/shot/real-data.js +120 -0
- package/dist/cli/shot/serve.d.ts +2 -2
- package/dist/cli/shot/serve.d.ts.map +1 -1
- package/dist/cli/shot/serve.js +16 -2
- package/dist/dashboard/bar-list.d.ts +29 -0
- package/dist/dashboard/bar-list.d.ts.map +1 -0
- package/dist/dashboard/bar-list.js +52 -0
- package/dist/dashboard/bar-list.module.css +73 -0
- package/dist/dashboard/bar-list.module.css.d.ts +16 -0
- package/dist/dashboard/delta-badge.d.ts +2 -2
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +12 -14
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +4 -0
- package/dist/dashboard/meter-model.d.ts +78 -0
- package/dist/dashboard/meter-model.d.ts.map +1 -0
- package/dist/dashboard/meter-model.js +91 -0
- package/dist/dashboard/meter-parts.d.ts +42 -0
- package/dist/dashboard/meter-parts.d.ts.map +1 -0
- package/dist/dashboard/meter-parts.js +163 -0
- package/dist/dashboard/meter.d.ts +112 -0
- package/dist/dashboard/meter.d.ts.map +1 -0
- package/dist/dashboard/meter.js +43 -0
- package/dist/dashboard/meter.module.css +150 -0
- package/dist/dashboard/meter.module.css.d.ts +28 -0
- package/dist/dashboard/query-state.d.ts +35 -0
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +12 -1
- package/dist/dashboard/scale.d.ts +9 -0
- package/dist/dashboard/scale.d.ts.map +1 -0
- package/dist/dashboard/scale.js +10 -0
- package/dist/dashboard/stat-card-parts.d.ts +40 -0
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -0
- package/dist/dashboard/stat-card-parts.js +55 -0
- package/dist/dashboard/stat-card.d.ts +46 -34
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +148 -79
- package/dist/dashboard/stat-card.module.css +220 -7
- package/dist/dashboard/stat-card.module.css.d.ts +20 -0
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +73 -9
- package/dist/dashboard/widget-header.module.css +25 -17
- package/dist/guard/index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/theme/chrome-vars.d.ts +82 -0
- package/dist/theme/chrome-vars.d.ts.map +1 -0
- package/dist/theme/chrome-vars.js +36 -0
- package/dist/theme/controls.module.css +20 -1
- package/dist/theme/controls.module.css.d.ts +1 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +30 -33
- package/dist/tokens/derive.d.ts +11 -1
- package/dist/tokens/derive.d.ts.map +1 -1
- package/dist/tokens/derive.js +9 -24
- package/dist/tokens/status-text.d.ts +26 -0
- package/dist/tokens/status-text.d.ts.map +1 -0
- package/dist/tokens/status-text.js +68 -0
- package/llms.txt +36 -4
- package/package.json +1 -1
- package/src/charts/Donut.tsx +2 -2
- package/src/charts/DualPanel.tsx +2 -2
- package/src/charts/Heatmap.tsx +2 -2
- package/src/charts/MirroredBars.tsx +2 -2
- package/src/charts/Sparkline.tsx +7 -5
- package/src/charts/compile.ts +31 -11
- package/src/charts/cursor.ts +48 -3
- package/src/charts/date-tick-format.ts +132 -0
- package/src/charts/panel.tsx +5 -3
- package/src/charts/types.ts +5 -1
- package/src/cli/help.ts +22 -2
- package/src/cli/shot/capture.ts +133 -12
- package/src/cli/shot/index.ts +50 -4
- package/src/cli/shot/playwright.ts +1 -1
- package/src/cli/shot/real-data.ts +165 -0
- package/src/cli/shot/serve.ts +28 -3
- package/src/dashboard/bar-list.module.css +73 -0
- package/src/dashboard/bar-list.module.css.d.ts +16 -0
- package/src/dashboard/bar-list.tsx +112 -0
- package/src/dashboard/delta-badge.tsx +24 -18
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +161 -0
- package/src/dashboard/meter-parts.tsx +223 -0
- package/src/dashboard/meter.module.css +150 -0
- package/src/dashboard/meter.module.css.d.ts +28 -0
- package/src/dashboard/meter.tsx +162 -0
- package/src/dashboard/query-state.tsx +38 -0
- package/src/dashboard/scale.ts +13 -0
- package/src/dashboard/stat-card-parts.tsx +108 -0
- package/src/dashboard/stat-card.module.css +220 -7
- package/src/dashboard/stat-card.module.css.d.ts +20 -0
- package/src/dashboard/stat-card.tsx +282 -174
- package/src/dashboard/widget-header.module.css +25 -17
- package/src/dashboard/widget-header.tsx +103 -7
- package/src/guard/index.ts +2 -2
- package/src/index.ts +4 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +128 -40
- package/src/theme/chrome-vars.ts +111 -0
- package/src/theme/controls.module.css +20 -1
- package/src/theme/controls.module.css.d.ts +1 -0
- package/src/theme/index.ts +39 -101
- package/src/tokens/derive.ts +19 -26
- package/src/tokens/status-text.ts +85 -0
|
@@ -267,7 +267,9 @@
|
|
|
267
267
|
color: var(--vx-muted);
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
/* Folded-subtitle pieces: hidden until a `basalt-card` narrower than 480px shows them (below).
|
|
270
|
+
/* Folded-subtitle pieces: hidden until a `basalt-card` narrower than 480px shows them (below). The
|
|
271
|
+
* bubble is a top-layer popover but stays in the card's DOM subtree, so these ancestor-based rules
|
|
272
|
+
* (container query, short-card flag) still reach `.foldNote` inside it. */
|
|
271
273
|
.foldGlyph,
|
|
272
274
|
.foldNote {
|
|
273
275
|
display: none;
|
|
@@ -275,19 +277,25 @@
|
|
|
275
277
|
|
|
276
278
|
/*
|
|
277
279
|
* The tooltip bubble reads like every other floating surface — panel bg + `shadow-card` + card
|
|
278
|
-
* radius (docs/DESIGN-SPEC.md §5). It opens DOWNWARD
|
|
279
|
-
*
|
|
280
|
-
*
|
|
280
|
+
* radius (docs/DESIGN-SPEC.md §5). It opens DOWNWARD and flips up at the viewport edge.
|
|
281
|
+
* `pointer-events: none` so it can never swallow the pointer on its way back to the trigger's
|
|
282
|
+
* `mouseleave`. Mantine-free by design (this whole folder is), so it is a plain
|
|
281
283
|
* state-driven bubble rather than a Mantine Tooltip — which is also what makes it composable from
|
|
282
284
|
* inside the `charts/` boundary.
|
|
283
285
|
*/
|
|
284
286
|
.infoBubble {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
287
|
+
/* A `popover="manual"` element in the top layer, so no card's `overflow: hidden` or
|
|
288
|
+
* `container-type` clips it; placed from the trigger's rect (`useBubblePosition`), `top`/`left`
|
|
289
|
+
* arrive inline. The UA popover styles (centred, bordered, padded, Canvas background) are reset. */
|
|
290
|
+
position: fixed;
|
|
291
|
+
inset: auto;
|
|
292
|
+
margin: 0;
|
|
293
|
+
border: 0;
|
|
294
|
+
overflow: visible;
|
|
295
|
+
z-index: var(--mantine-z-index-popover, 300);
|
|
289
296
|
width: max-content;
|
|
290
|
-
|
|
297
|
+
/* 100% of the viewport (fixed): 2 × BUBBLE_EDGE in widget-header.tsx. */
|
|
298
|
+
max-width: min(260px, calc(100% - 16px));
|
|
291
299
|
padding: var(--vx-space-stack-sm) var(--vx-space-row-inset-x);
|
|
292
300
|
border-radius: var(--vx-radius-card);
|
|
293
301
|
background-color: var(--vx-surface-panel);
|
|
@@ -306,24 +314,24 @@
|
|
|
306
314
|
display: inline-flex;
|
|
307
315
|
flex: none;
|
|
308
316
|
white-space: nowrap;
|
|
309
|
-
align-items:
|
|
317
|
+
align-items: baseline;
|
|
310
318
|
gap: 3px;
|
|
311
|
-
border-radius: var(--vx-radius-ctrl);
|
|
312
|
-
padding: var(--vx-space-badge-inset-y) var(--vx-space-badge-inset-x);
|
|
313
319
|
font-family: var(--basalt-font-mono);
|
|
314
|
-
font-size: var(--vx-text-
|
|
315
|
-
font-weight:
|
|
320
|
+
font-size: var(--vx-text-sm);
|
|
321
|
+
font-weight: 500;
|
|
316
322
|
line-height: 1;
|
|
317
323
|
}
|
|
318
324
|
|
|
325
|
+
/* The glyph is direction, not a figure: the `micro` rung, so it never lands between two sizes. */
|
|
319
326
|
.deltaGlyph {
|
|
320
|
-
font-size:
|
|
327
|
+
font-size: var(--vx-text-micro);
|
|
321
328
|
}
|
|
322
329
|
|
|
323
330
|
.deltaPeriod {
|
|
324
331
|
margin-inline-start: 4px;
|
|
325
|
-
font-
|
|
326
|
-
|
|
332
|
+
font-size: var(--vx-text-micro);
|
|
333
|
+
font-weight: 400;
|
|
334
|
+
color: var(--vx-muted);
|
|
327
335
|
}
|
|
328
336
|
|
|
329
337
|
/* Card narrower than 480px: the subtitle folds into the info glyph (`InfoGlyph`'s `note`, or
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
* />
|
|
31
31
|
*/
|
|
32
32
|
import { useEffect, useId, useRef, useState } from 'react'
|
|
33
|
-
import type { ReactNode } from 'react'
|
|
33
|
+
import type { ReactNode, RefObject } from 'react'
|
|
34
|
+
import { useIsomorphicLayoutEffect } from '../common/isomorphic-layout-effect'
|
|
34
35
|
import { cx } from '../common/props'
|
|
35
36
|
import type { BasaltProps, SlotStylesProps } from '../common/props'
|
|
36
37
|
import { IconSlot } from '../theme/icon-slot'
|
|
@@ -162,6 +163,75 @@ export type WidgetHeaderDeltaProps = Pick<
|
|
|
162
163
|
'delta' | 'deltaPeriod' | 'deltaPolarity' | 'deltaFormat' | 'deltaGlyph'
|
|
163
164
|
>
|
|
164
165
|
|
|
166
|
+
/** Gap between the glyph and its bubble, and the least air the bubble keeps from a viewport edge. */
|
|
167
|
+
const BUBBLE_GAP = 7
|
|
168
|
+
/** Keep in step with `.infoBubble`'s `max-width` (`calc(100% - 2 × BUBBLE_EDGE)`, in CSS). */
|
|
169
|
+
const BUBBLE_EDGE = 8
|
|
170
|
+
|
|
171
|
+
type BubblePos = { top: number; left: number }
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Places the bubble in the VIEWPORT: below the glyph, flipped above when it would overflow the
|
|
175
|
+
* bottom edge, shifted sideways to stay inside the left and right edges. Re-places on scroll, resize
|
|
176
|
+
* and when the bubble's own box changes while open. The bubble is a top-layer popover and
|
|
177
|
+
* `position: fixed`, so a card's `overflow: hidden` (every basalt card has one) can never clip it —
|
|
178
|
+
* the W32 round 0-3 defect at 390. `clear` forgets the position on close, so a reopen starts hidden.
|
|
179
|
+
*/
|
|
180
|
+
function useBubblePosition(
|
|
181
|
+
open: boolean,
|
|
182
|
+
triggerRef: RefObject<HTMLButtonElement | null>,
|
|
183
|
+
bubbleRef: RefObject<HTMLSpanElement | null>,
|
|
184
|
+
): { pos: BubblePos | null; setPos: (pos: BubblePos | null) => void } {
|
|
185
|
+
const [pos, setPos] = useState<BubblePos | null>(null)
|
|
186
|
+
|
|
187
|
+
useIsomorphicLayoutEffect(() => {
|
|
188
|
+
if (!open) return
|
|
189
|
+
// Into the top layer before the first measure. A DOM without the Popover API (happy-dom, an old
|
|
190
|
+
// engine) ignores the attribute and the element stays visible in place, `position: fixed`, which
|
|
191
|
+
// is the same box the placement maths below positions.
|
|
192
|
+
const bubbleEl = bubbleRef.current
|
|
193
|
+
if (bubbleEl !== null && typeof bubbleEl.showPopover === 'function') bubbleEl.showPopover()
|
|
194
|
+
const place = () => {
|
|
195
|
+
const trigger = triggerRef.current
|
|
196
|
+
const bubble = bubbleRef.current
|
|
197
|
+
if (trigger === null || bubble === null) return
|
|
198
|
+
const t = trigger.getBoundingClientRect()
|
|
199
|
+
const b = bubble.getBoundingClientRect()
|
|
200
|
+
// The documentElement's client box is the viewport minus classic scrollbars.
|
|
201
|
+
const viewW = document.documentElement.clientWidth
|
|
202
|
+
const viewH = document.documentElement.clientHeight
|
|
203
|
+
const below = t.bottom + BUBBLE_GAP
|
|
204
|
+
const above = t.top - BUBBLE_GAP - b.height
|
|
205
|
+
const top = below + b.height > viewH - BUBBLE_EDGE && above >= BUBBLE_EDGE ? above : below
|
|
206
|
+
const left = Math.max(BUBBLE_EDGE, Math.min(t.left, viewW - BUBBLE_EDGE - b.width))
|
|
207
|
+
setPos((prev) => (prev?.top === top && prev.left === left ? prev : { top, left }))
|
|
208
|
+
}
|
|
209
|
+
place()
|
|
210
|
+
window.addEventListener('scroll', place, true)
|
|
211
|
+
window.addEventListener('resize', place)
|
|
212
|
+
// The bubble's box changes after open (a late font, the folded note appearing): re-place then too.
|
|
213
|
+
const observer =
|
|
214
|
+
typeof ResizeObserver === 'undefined' || bubbleRef.current === null
|
|
215
|
+
? undefined
|
|
216
|
+
: new ResizeObserver(place)
|
|
217
|
+
if (observer !== undefined && bubbleRef.current !== null) observer.observe(bubbleRef.current)
|
|
218
|
+
return () => {
|
|
219
|
+
window.removeEventListener('scroll', place, true)
|
|
220
|
+
window.removeEventListener('resize', place)
|
|
221
|
+
observer?.disconnect()
|
|
222
|
+
if (
|
|
223
|
+
bubbleEl !== null &&
|
|
224
|
+
typeof bubbleEl.hidePopover === 'function' &&
|
|
225
|
+
bubbleEl.matches(':popover-open')
|
|
226
|
+
) {
|
|
227
|
+
bubbleEl.hidePopover()
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}, [open, triggerRef, bubbleRef])
|
|
231
|
+
|
|
232
|
+
return { pos, setPos }
|
|
233
|
+
}
|
|
234
|
+
|
|
165
235
|
/**
|
|
166
236
|
* The info affordance. A `title` attribute alone was never enough — it renders on hover only, so a
|
|
167
237
|
* keyboard user focusing the glyph saw nothing at all. This is the bubble `ChartCard` used to own
|
|
@@ -193,16 +263,26 @@ export function InfoGlyph({
|
|
|
193
263
|
const [open, setOpen] = useState(false)
|
|
194
264
|
const tipId = useId()
|
|
195
265
|
const triggerRef = useRef<HTMLButtonElement>(null)
|
|
266
|
+
const bubbleRef = useRef<HTMLSpanElement>(null)
|
|
267
|
+
const { pos, setPos } = useBubblePosition(open, triggerRef, bubbleRef)
|
|
268
|
+
const close = () => {
|
|
269
|
+
setOpen(false)
|
|
270
|
+
setPos(null)
|
|
271
|
+
}
|
|
196
272
|
|
|
197
273
|
useEffect(() => {
|
|
198
274
|
if (!open) return
|
|
199
275
|
const handlePointerDown = (event: PointerEvent) => {
|
|
200
|
-
|
|
276
|
+
const target = event.target
|
|
277
|
+
if (!(target instanceof Node)) return
|
|
278
|
+
// The bubble is the trigger's sibling, not inside it, so it needs its own exemption.
|
|
279
|
+
if (triggerRef.current?.contains(target) || bubbleRef.current?.contains(target)) return
|
|
201
280
|
setOpen(false)
|
|
281
|
+
setPos(null)
|
|
202
282
|
}
|
|
203
283
|
document.addEventListener('pointerdown', handlePointerDown)
|
|
204
284
|
return () => document.removeEventListener('pointerdown', handlePointerDown)
|
|
205
|
-
}, [open])
|
|
285
|
+
}, [open, setPos])
|
|
206
286
|
|
|
207
287
|
return (
|
|
208
288
|
<span className={cx(classes.info, className)}>
|
|
@@ -217,12 +297,12 @@ export function InfoGlyph({
|
|
|
217
297
|
aria-describedby={open ? tipId : undefined}
|
|
218
298
|
data-open={open}
|
|
219
299
|
onMouseEnter={() => setOpen(true)}
|
|
220
|
-
onMouseLeave={
|
|
300
|
+
onMouseLeave={close}
|
|
221
301
|
onFocus={() => setOpen(true)}
|
|
222
|
-
onBlur={
|
|
302
|
+
onBlur={close}
|
|
223
303
|
onClick={() => setOpen(true)}
|
|
224
304
|
onKeyDown={(event) => {
|
|
225
|
-
if (event.key === 'Escape')
|
|
305
|
+
if (event.key === 'Escape') close()
|
|
226
306
|
}}
|
|
227
307
|
>
|
|
228
308
|
<svg width={11} height={11} viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
|
@@ -230,7 +310,23 @@ export function InfoGlyph({
|
|
|
230
310
|
</svg>
|
|
231
311
|
</button>
|
|
232
312
|
{open && (
|
|
233
|
-
|
|
313
|
+
// Rendered IN PLACE as a manual popover, shown into the top layer by `useBubblePosition`: the top
|
|
314
|
+
// layer escapes every ancestor's `overflow: hidden` and `container-type` (a card's), so the
|
|
315
|
+
// bubble needs no portal — `react-dom` is outside `./charts`' allowed import set
|
|
316
|
+
// (`scripts/check-dist-layering.mjs`, V2-SPEC § 9.8). Hidden until the first measure lands: a
|
|
317
|
+
// bubble painted at 0,0 for one frame is a flash in the corner.
|
|
318
|
+
<span
|
|
319
|
+
ref={bubbleRef}
|
|
320
|
+
id={tipId}
|
|
321
|
+
role="tooltip"
|
|
322
|
+
popover="manual"
|
|
323
|
+
className={classes.infoBubble}
|
|
324
|
+
style={
|
|
325
|
+
pos === null
|
|
326
|
+
? { top: 0, left: 0, visibility: 'hidden' }
|
|
327
|
+
: { top: pos.top, left: pos.left }
|
|
328
|
+
}
|
|
329
|
+
>
|
|
234
330
|
{text}
|
|
235
331
|
{note !== undefined && <span className={classes.foldNote}>{note}</span>}
|
|
236
332
|
</span>
|
package/src/guard/index.ts
CHANGED
|
@@ -903,12 +903,12 @@ export type GraceEntry = { since: string; promote: string; why: string }
|
|
|
903
903
|
export const GRACE_PERIOD_KINDS: Partial<Record<GuardKind, GraceEntry>> = {
|
|
904
904
|
'raw-spacing': {
|
|
905
905
|
since: '2.16.0',
|
|
906
|
-
promote: '2.
|
|
906
|
+
promote: '2.24.0',
|
|
907
907
|
why: 'The spacing scale moved to 8/12/16/20/24 in 2.16.0: a prop value equal to a NEW step (p={16}) is newly a finding.',
|
|
908
908
|
},
|
|
909
909
|
'inline-spacing': {
|
|
910
910
|
since: '2.16.0',
|
|
911
|
-
promote: '2.
|
|
911
|
+
promote: '2.24.0',
|
|
912
912
|
why: 'The scale moved to 8/12/16/20/24 and the CSS micro ceiling dropped 10 → 7 in 2.16.0: a literal 8px/10px in CSS is newly a finding.',
|
|
913
913
|
},
|
|
914
914
|
}
|
package/src/index.ts
CHANGED
|
@@ -193,21 +193,34 @@ exports[`createBasaltTheme() shape and resolver output default 1`] = `
|
|
|
193
193
|
},
|
|
194
194
|
"vars": {
|
|
195
195
|
"fn":
|
|
196
|
-
"(_theme, props) =>
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
"(_theme, props) => {
|
|
197
|
+
const ink = subtleInkVars(props);
|
|
198
|
+
return {
|
|
199
|
+
root: {
|
|
200
|
+
"--ai-size": props.size === "md" ? "calc(var(--vx-space-control-height) * var(--mantine-scale))" : void 0,
|
|
201
|
+
"--ai-color": ink.color,
|
|
202
|
+
"--ai-hover": ink.hover
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}"
|
|
201
206
|
,
|
|
202
207
|
"outputs": [
|
|
203
208
|
{
|
|
204
|
-
"probes":
|
|
209
|
+
"probes": 1976,
|
|
205
210
|
"result": "{"root":{}}",
|
|
206
211
|
},
|
|
207
212
|
{
|
|
208
|
-
"probes":
|
|
213
|
+
"probes": 42,
|
|
214
|
+
"result": "{"root":{"--ai-color":"var(--vx-ink)","--ai-hover":"color-mix(in srgb, var(--vx-ink) 6%, transparent)"}}",
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"probes": 284,
|
|
209
218
|
"result": "{"root":{"--ai-size":"calc(var(--vx-space-control-height) * var(--mantine-scale))"}}",
|
|
210
219
|
},
|
|
220
|
+
{
|
|
221
|
+
"probes": 6,
|
|
222
|
+
"result": "{"root":{"--ai-size":"calc(var(--vx-space-control-height) * var(--mantine-scale))","--ai-color":"var(--vx-ink)","--ai-hover":"color-mix(in srgb, var(--vx-ink) 6%, transparent)"}}",
|
|
223
|
+
},
|
|
211
224
|
],
|
|
212
225
|
},
|
|
213
226
|
},
|
|
@@ -232,8 +245,13 @@ exports[`createBasaltTheme() shape and resolver output default 1`] = `
|
|
|
232
245
|
},
|
|
233
246
|
},
|
|
234
247
|
"Badge": {
|
|
248
|
+
"classNames": {
|
|
249
|
+
"section": undefined,
|
|
250
|
+
},
|
|
235
251
|
"defaultProps": {
|
|
236
|
-
"
|
|
252
|
+
"color": "gray",
|
|
253
|
+
"radius": 5,
|
|
254
|
+
"variant": "light",
|
|
237
255
|
},
|
|
238
256
|
},
|
|
239
257
|
"Breadcrumbs": {
|
|
@@ -252,21 +270,34 @@ exports[`createBasaltTheme() shape and resolver output default 1`] = `
|
|
|
252
270
|
},
|
|
253
271
|
"vars": {
|
|
254
272
|
"fn":
|
|
255
|
-
"(_theme, props) =>
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
273
|
+
"(_theme, props) => {
|
|
274
|
+
const ink = subtleInkVars(props);
|
|
275
|
+
return {
|
|
276
|
+
root: {
|
|
277
|
+
"--button-height": props.size === "md" ? "calc(var(--vx-space-control-height) * var(--mantine-scale))" : void 0,
|
|
278
|
+
"--button-color": ink.color,
|
|
279
|
+
"--button-hover": ink.hover
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
}"
|
|
260
283
|
,
|
|
261
284
|
"outputs": [
|
|
262
285
|
{
|
|
263
|
-
"probes":
|
|
286
|
+
"probes": 1976,
|
|
264
287
|
"result": "{"root":{}}",
|
|
265
288
|
},
|
|
266
289
|
{
|
|
267
|
-
"probes":
|
|
290
|
+
"probes": 42,
|
|
291
|
+
"result": "{"root":{"--button-color":"var(--vx-ink)","--button-hover":"color-mix(in srgb, var(--vx-ink) 6%, transparent)"}}",
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"probes": 284,
|
|
268
295
|
"result": "{"root":{"--button-height":"calc(var(--vx-space-control-height) * var(--mantine-scale))"}}",
|
|
269
296
|
},
|
|
297
|
+
{
|
|
298
|
+
"probes": 6,
|
|
299
|
+
"result": "{"root":{"--button-height":"calc(var(--vx-space-control-height) * var(--mantine-scale))","--button-color":"var(--vx-ink)","--button-hover":"color-mix(in srgb, var(--vx-ink) 6%, transparent)"}}",
|
|
300
|
+
},
|
|
270
301
|
],
|
|
271
302
|
},
|
|
272
303
|
},
|
|
@@ -779,10 +810,25 @@ exports[`createBasaltTheme() shape and resolver output default 1`] = `
|
|
|
779
810
|
"root": undefined,
|
|
780
811
|
},
|
|
781
812
|
"vars": {
|
|
782
|
-
"fn":
|
|
813
|
+
"fn":
|
|
814
|
+
"function tabsVars(theme, props) {
|
|
815
|
+
const underline = !hasExplicitColor(props.color) && (props.variant ?? "default") === "default";
|
|
816
|
+
return {
|
|
817
|
+
root: {
|
|
818
|
+
"--tabs-text-color": onColorFor(theme, props),
|
|
819
|
+
"--tabs-color": underline ? "var(--vx-ink)" : void 0,
|
|
820
|
+
"--tabs-radius": void 0
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
}"
|
|
824
|
+
,
|
|
783
825
|
"outputs": [
|
|
784
826
|
{
|
|
785
|
-
"probes":
|
|
827
|
+
"probes": 100,
|
|
828
|
+
"result": "{"root":{"--tabs-text-color":"var(--vx-on-blue)","--tabs-color":"var(--vx-ink)"}}",
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
"probes": 672,
|
|
786
832
|
"result": "{"root":{"--tabs-text-color":"var(--vx-on-blue)"}}",
|
|
787
833
|
},
|
|
788
834
|
{
|
|
@@ -927,8 +973,6 @@ exports[`createBasaltTheme() shape and resolver output default 1`] = `
|
|
|
927
973
|
return resolved;
|
|
928
974
|
if (input.variant === "filled")
|
|
929
975
|
return input.autoContrast ?? input.theme.autoContrast ? { ...resolved, color: on } : resolved;
|
|
930
|
-
if (input.variant === "subtle")
|
|
931
|
-
return input.color === void 0 || input.color === input.theme.primaryColor ? { ...resolved, hover: "color-mix(in srgb, var(--vx-ink) 6%, transparent)" } : resolved;
|
|
932
976
|
if (input.variant === "outline")
|
|
933
977
|
return { ...resolved, color: \`color-mix(in srgb, \${resolved.color} 70%, var(--vx-ink))\` };
|
|
934
978
|
if (input.variant !== "light")
|
|
@@ -1030,7 +1074,7 @@ exports[`createBasaltTheme() shape and resolver output default 1`] = `
|
|
|
1030
1074
|
},
|
|
1031
1075
|
{
|
|
1032
1076
|
"probes": 2,
|
|
1033
|
-
"result": "{"background":"transparent","hover":"
|
|
1077
|
+
"result": "{"background":"transparent","hover":"var(--mantine-color-blue-light-hover)","color":"var(--mantine-color-blue-light-color)","border":"calc(0.0625rem * var(--mantine-scale)) solid transparent"}",
|
|
1034
1078
|
},
|
|
1035
1079
|
{
|
|
1036
1080
|
"probes": 2,
|
|
@@ -1291,21 +1335,34 @@ exports[`createBasaltTheme() shape and resolver output all knobs 1`] = `
|
|
|
1291
1335
|
},
|
|
1292
1336
|
"vars": {
|
|
1293
1337
|
"fn":
|
|
1294
|
-
"(_theme, props) =>
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1338
|
+
"(_theme, props) => {
|
|
1339
|
+
const ink = subtleInkVars(props);
|
|
1340
|
+
return {
|
|
1341
|
+
root: {
|
|
1342
|
+
"--ai-size": props.size === "md" ? "calc(var(--vx-space-control-height) * var(--mantine-scale))" : void 0,
|
|
1343
|
+
"--ai-color": ink.color,
|
|
1344
|
+
"--ai-hover": ink.hover
|
|
1345
|
+
}
|
|
1346
|
+
};
|
|
1347
|
+
}"
|
|
1299
1348
|
,
|
|
1300
1349
|
"outputs": [
|
|
1301
1350
|
{
|
|
1302
|
-
"probes":
|
|
1351
|
+
"probes": 1976,
|
|
1303
1352
|
"result": "{"root":{}}",
|
|
1304
1353
|
},
|
|
1305
1354
|
{
|
|
1306
|
-
"probes":
|
|
1355
|
+
"probes": 42,
|
|
1356
|
+
"result": "{"root":{"--ai-color":"var(--vx-ink)","--ai-hover":"color-mix(in srgb, var(--vx-ink) 6%, transparent)"}}",
|
|
1357
|
+
},
|
|
1358
|
+
{
|
|
1359
|
+
"probes": 284,
|
|
1307
1360
|
"result": "{"root":{"--ai-size":"calc(var(--vx-space-control-height) * var(--mantine-scale))"}}",
|
|
1308
1361
|
},
|
|
1362
|
+
{
|
|
1363
|
+
"probes": 6,
|
|
1364
|
+
"result": "{"root":{"--ai-size":"calc(var(--vx-space-control-height) * var(--mantine-scale))","--ai-color":"var(--vx-ink)","--ai-hover":"color-mix(in srgb, var(--vx-ink) 6%, transparent)"}}",
|
|
1365
|
+
},
|
|
1309
1366
|
],
|
|
1310
1367
|
},
|
|
1311
1368
|
},
|
|
@@ -1330,8 +1387,13 @@ exports[`createBasaltTheme() shape and resolver output all knobs 1`] = `
|
|
|
1330
1387
|
},
|
|
1331
1388
|
},
|
|
1332
1389
|
"Badge": {
|
|
1390
|
+
"classNames": {
|
|
1391
|
+
"section": undefined,
|
|
1392
|
+
},
|
|
1333
1393
|
"defaultProps": {
|
|
1334
|
-
"
|
|
1394
|
+
"color": "gray",
|
|
1395
|
+
"radius": 8,
|
|
1396
|
+
"variant": "light",
|
|
1335
1397
|
},
|
|
1336
1398
|
},
|
|
1337
1399
|
"Breadcrumbs": {
|
|
@@ -1350,21 +1412,34 @@ exports[`createBasaltTheme() shape and resolver output all knobs 1`] = `
|
|
|
1350
1412
|
},
|
|
1351
1413
|
"vars": {
|
|
1352
1414
|
"fn":
|
|
1353
|
-
"(_theme, props) =>
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1415
|
+
"(_theme, props) => {
|
|
1416
|
+
const ink = subtleInkVars(props);
|
|
1417
|
+
return {
|
|
1418
|
+
root: {
|
|
1419
|
+
"--button-height": props.size === "md" ? "calc(var(--vx-space-control-height) * var(--mantine-scale))" : void 0,
|
|
1420
|
+
"--button-color": ink.color,
|
|
1421
|
+
"--button-hover": ink.hover
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
}"
|
|
1358
1425
|
,
|
|
1359
1426
|
"outputs": [
|
|
1360
1427
|
{
|
|
1361
|
-
"probes":
|
|
1428
|
+
"probes": 1976,
|
|
1362
1429
|
"result": "{"root":{}}",
|
|
1363
1430
|
},
|
|
1364
1431
|
{
|
|
1365
|
-
"probes":
|
|
1432
|
+
"probes": 42,
|
|
1433
|
+
"result": "{"root":{"--button-color":"var(--vx-ink)","--button-hover":"color-mix(in srgb, var(--vx-ink) 6%, transparent)"}}",
|
|
1434
|
+
},
|
|
1435
|
+
{
|
|
1436
|
+
"probes": 284,
|
|
1366
1437
|
"result": "{"root":{"--button-height":"calc(var(--vx-space-control-height) * var(--mantine-scale))"}}",
|
|
1367
1438
|
},
|
|
1439
|
+
{
|
|
1440
|
+
"probes": 6,
|
|
1441
|
+
"result": "{"root":{"--button-height":"calc(var(--vx-space-control-height) * var(--mantine-scale))","--button-color":"var(--vx-ink)","--button-hover":"color-mix(in srgb, var(--vx-ink) 6%, transparent)"}}",
|
|
1442
|
+
},
|
|
1368
1443
|
],
|
|
1369
1444
|
},
|
|
1370
1445
|
},
|
|
@@ -1877,10 +1952,25 @@ exports[`createBasaltTheme() shape and resolver output all knobs 1`] = `
|
|
|
1877
1952
|
"root": undefined,
|
|
1878
1953
|
},
|
|
1879
1954
|
"vars": {
|
|
1880
|
-
"fn":
|
|
1955
|
+
"fn":
|
|
1956
|
+
"function tabsVars(theme, props) {
|
|
1957
|
+
const underline = !hasExplicitColor(props.color) && (props.variant ?? "default") === "default";
|
|
1958
|
+
return {
|
|
1959
|
+
root: {
|
|
1960
|
+
"--tabs-text-color": onColorFor(theme, props),
|
|
1961
|
+
"--tabs-color": underline ? "var(--vx-ink)" : void 0,
|
|
1962
|
+
"--tabs-radius": void 0
|
|
1963
|
+
}
|
|
1964
|
+
};
|
|
1965
|
+
}"
|
|
1966
|
+
,
|
|
1881
1967
|
"outputs": [
|
|
1882
1968
|
{
|
|
1883
|
-
"probes":
|
|
1969
|
+
"probes": 100,
|
|
1970
|
+
"result": "{"root":{"--tabs-text-color":"var(--vx-on-blue)","--tabs-color":"var(--vx-ink)"}}",
|
|
1971
|
+
},
|
|
1972
|
+
{
|
|
1973
|
+
"probes": 672,
|
|
1884
1974
|
"result": "{"root":{"--tabs-text-color":"var(--vx-on-blue)"}}",
|
|
1885
1975
|
},
|
|
1886
1976
|
{
|
|
@@ -2196,8 +2286,6 @@ exports[`createBasaltTheme() shape and resolver output all knobs 1`] = `
|
|
|
2196
2286
|
return resolved;
|
|
2197
2287
|
if (input.variant === "filled")
|
|
2198
2288
|
return input.autoContrast ?? input.theme.autoContrast ? { ...resolved, color: on } : resolved;
|
|
2199
|
-
if (input.variant === "subtle")
|
|
2200
|
-
return input.color === void 0 || input.color === input.theme.primaryColor ? { ...resolved, hover: "color-mix(in srgb, var(--vx-ink) 6%, transparent)" } : resolved;
|
|
2201
2289
|
if (input.variant === "outline")
|
|
2202
2290
|
return { ...resolved, color: \`color-mix(in srgb, \${resolved.color} 70%, var(--vx-ink))\` };
|
|
2203
2291
|
if (input.variant !== "light")
|
|
@@ -2299,7 +2387,7 @@ exports[`createBasaltTheme() shape and resolver output all knobs 1`] = `
|
|
|
2299
2387
|
},
|
|
2300
2388
|
{
|
|
2301
2389
|
"probes": 2,
|
|
2302
|
-
"result": "{"background":"transparent","hover":"
|
|
2390
|
+
"result": "{"background":"transparent","hover":"var(--mantine-color-blue-light-hover)","color":"var(--mantine-color-blue-light-color)","border":"calc(0.0625rem * var(--mantine-scale)) solid transparent"}",
|
|
2303
2391
|
},
|
|
2304
2392
|
{
|
|
2305
2393
|
"probes": 2,
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component `vars` that carry the Wave 33 chrome (`docs/waves/design-parity/SPEC.md` § 6.12) and the
|
|
3
|
+
* ON-COLOR re-point they sit beside. Pure functions of theme + props, kept out of `theme/index.ts`
|
|
4
|
+
* so the tests can call them directly.
|
|
5
|
+
*/
|
|
6
|
+
import type { MantineTheme } from '@mantine/core'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ON-COLOR: the foreground for a filled surface, decided in CSS. THE fix for Mantine's
|
|
10
|
+
* scheme-blind, contrast-blind `autoContrast`.
|
|
11
|
+
*
|
|
12
|
+
* Mantine picks the filled-variant text color ONCE, in JS, via `parseThemeColor({ color, theme })`
|
|
13
|
+
* — with NO `colorScheme` argument, so it resolves against the LIGHT `primaryShade` and bakes a
|
|
14
|
+
* static `color: var(--mantine-color-white)` into the element, while the BACKGROUND it pairs that
|
|
15
|
+
* with (`--mantine-color-{c}-filled`) stays a scheme-reactive CSS var. It gets away with it
|
|
16
|
+
* upstream only because Mantine's default `primaryShade` is `{ light: 6, dark: 8 }` — DARKER on
|
|
17
|
+
* dark, so white happens to stay right. It is luck, not logic: point `primaryShade.dark` at a
|
|
18
|
+
* lighter shade (as Basalt originally did) and every filled control in dark mode turns white-on-
|
|
19
|
+
* light. And even in one scheme the pick is wrong, because `isLightColor` is a BT.601 BRIGHTNESS
|
|
20
|
+
* test that does not track WCAG contrast — it handed white to lime `#97ba2e` at 2.24:1.
|
|
21
|
+
*
|
|
22
|
+
* Basalt removes the JS decision entirely. A fill is now scheme-INDEPENDENT and sits in a
|
|
23
|
+
* luminance band chosen so a WHITE label always clears AA (see `FILL` / `ACCENT` in
|
|
24
|
+
* tokens/palette.ts), so the on-color is a token, not a computation. `--vx-on-{color}` is emitted
|
|
25
|
+
* per color and resolves in pure CSS at paint time — the same discipline the rest of the `--vx-*`
|
|
26
|
+
* system follows. It is still MEASURED here (`legibleOn`) rather than hardcoded to white, so a
|
|
27
|
+
* consumer that retunes a family outside the band still gets the legible foreground.
|
|
28
|
+
*
|
|
29
|
+
* The palette already KNEW the answer: `ACCENT.onAccent` ("text on an accent fill") existed, and
|
|
30
|
+
* `Composer`'s send button hand-wired `color: var(--vx-on-accent)` — which was the ONLY reason that
|
|
31
|
+
* one control stayed legible while every generic Mantine control did not. The token was right;
|
|
32
|
+
* nothing bound the chrome to it. It is bound now (see `accentBridge` / `familyBridge`), and the
|
|
33
|
+
* Composer no longer needs the override.
|
|
34
|
+
*
|
|
35
|
+
* Fix: never let a foreground be decided in JS. `--vx-on-{color}` is emitted per color under BOTH
|
|
36
|
+
* scheme blocks of `cssVariablesResolver` (each resolved against the shade that scheme actually
|
|
37
|
+
* paints), so the foreground resolves in pure CSS at paint time — the same discipline the rest of
|
|
38
|
+
* the `--vx-*` system already follows. `basaltVariantColorResolver` re-points every filled variant
|
|
39
|
+
* at it, and the components that bypass the variant resolver (Checkbox / Radio / Tabs / Pagination /
|
|
40
|
+
* Stepper / Indicator / Timeline all call Mantine's `getContrastColor` directly) are re-pointed at
|
|
41
|
+
* it too, in `components` below. Regression-locked by `contrast.test.ts`.
|
|
42
|
+
*/
|
|
43
|
+
export function onColor(theme: MantineTheme, color: string | undefined): string | undefined {
|
|
44
|
+
const name = color ?? theme.primaryColor
|
|
45
|
+
if (!Object.prototype.hasOwnProperty.call(theme.colors, name)) return undefined // hex / `blue.5`
|
|
46
|
+
return `var(--vx-on-${name})`
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The on-color for a component that bypasses the variant resolver and calls Mantine's
|
|
51
|
+
* `getContrastColor` directly. `undefined` (autoContrast off, or a hex / indexed color) leaves
|
|
52
|
+
* Mantine's own value in place — `mergeVars` strips undefined before merging.
|
|
53
|
+
*/
|
|
54
|
+
export function onColorFor(
|
|
55
|
+
theme: MantineTheme,
|
|
56
|
+
props: { color?: string | undefined; autoContrast?: boolean | undefined },
|
|
57
|
+
): string | undefined {
|
|
58
|
+
const autoContrast = props.autoContrast ?? theme.autoContrast
|
|
59
|
+
return autoContrast ? onColor(theme, props.color) : undefined
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The chrome opt-out: a call site that names a colour (even the primary one) keeps its hue. */
|
|
63
|
+
export function hasExplicitColor(color: string | undefined): boolean {
|
|
64
|
+
return color !== undefined
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A `subtle` Button / ActionIcon that names no colour takes neutral ink for its label and an
|
|
69
|
+
* ink-6% hover (`docs/DESIGN-SPEC.md` §5 ghost idiom). An explicit `color=` — the primary one
|
|
70
|
+
* included — keeps Mantine's tinted label and hover: `color="red"` on a destructive text action
|
|
71
|
+
* carries its hue as the whole signal. Mantine hands the variant resolver `color || primaryColor`,
|
|
72
|
+
* so only the component props can tell "unnamed" from "primary" — hence vars, not the resolver.
|
|
73
|
+
*/
|
|
74
|
+
export function subtleInkVars(props: {
|
|
75
|
+
color?: string | undefined
|
|
76
|
+
variant?: string | undefined
|
|
77
|
+
}): {
|
|
78
|
+
color: string | undefined
|
|
79
|
+
hover: string | undefined
|
|
80
|
+
} {
|
|
81
|
+
const ink = props.variant === 'subtle' && !hasExplicitColor(props.color)
|
|
82
|
+
return {
|
|
83
|
+
color: ink ? 'var(--vx-ink)' : undefined,
|
|
84
|
+
hover: ink ? 'color-mix(in srgb, var(--vx-ink) 6%, transparent)' : undefined,
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Tabs vars: the on-color re-point plus the active underline in ink (SPEC § 6.12). Only the
|
|
90
|
+
* underline `default` variant takes ink (`pills` fills with the colour); an explicit `color=` opts
|
|
91
|
+
* out. The return type lists `--tabs-text-color` and `--tabs-radius` because Mantine's
|
|
92
|
+
* `TabsCssVariables` type declares only `--tabs-color` / `--tabs-radius` while Tabs' OWN
|
|
93
|
+
* varsResolver writes `--tabs-text-color` (an upstream type gap).
|
|
94
|
+
*/
|
|
95
|
+
export function tabsVars(
|
|
96
|
+
theme: MantineTheme,
|
|
97
|
+
props: {
|
|
98
|
+
color?: string | undefined
|
|
99
|
+
variant?: string | undefined
|
|
100
|
+
autoContrast?: boolean | undefined
|
|
101
|
+
},
|
|
102
|
+
): { root: Record<'--tabs-color' | '--tabs-radius' | '--tabs-text-color', string | undefined> } {
|
|
103
|
+
const underline = !hasExplicitColor(props.color) && (props.variant ?? 'default') === 'default'
|
|
104
|
+
return {
|
|
105
|
+
root: {
|
|
106
|
+
'--tabs-text-color': onColorFor(theme, props),
|
|
107
|
+
'--tabs-color': underline ? 'var(--vx-ink)' : undefined,
|
|
108
|
+
'--tabs-radius': undefined,
|
|
109
|
+
},
|
|
110
|
+
}
|
|
111
|
+
}
|