basalt-ui 2.17.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.
Files changed (69) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/MIGRATING.md +44 -12
  3. package/agent/skills/basalt-design/SKILL.md +1 -1
  4. package/dist/cli/help.d.ts +1 -0
  5. package/dist/cli/help.d.ts.map +1 -1
  6. package/dist/cli/help.js +8 -2
  7. package/dist/cli/shot/capture.d.ts +12 -1
  8. package/dist/cli/shot/capture.d.ts.map +1 -1
  9. package/dist/cli/shot/capture.js +72 -10
  10. package/dist/cli/shot/index.d.ts +10 -1
  11. package/dist/cli/shot/index.d.ts.map +1 -1
  12. package/dist/cli/shot/index.js +40 -5
  13. package/dist/cli/shot/real-data.d.ts +35 -0
  14. package/dist/cli/shot/real-data.d.ts.map +1 -0
  15. package/dist/cli/shot/real-data.js +120 -0
  16. package/dist/cli/shot/serve.d.ts +2 -2
  17. package/dist/cli/shot/serve.d.ts.map +1 -1
  18. package/dist/cli/shot/serve.js +16 -2
  19. package/dist/dashboard/bar-list.d.ts +29 -0
  20. package/dist/dashboard/bar-list.d.ts.map +1 -0
  21. package/dist/dashboard/bar-list.js +52 -0
  22. package/dist/dashboard/bar-list.module.css +73 -0
  23. package/dist/dashboard/bar-list.module.css.d.ts +16 -0
  24. package/dist/dashboard/index.d.ts +2 -0
  25. package/dist/dashboard/index.d.ts.map +1 -1
  26. package/dist/dashboard/index.js +4 -0
  27. package/dist/dashboard/meter-model.d.ts +78 -0
  28. package/dist/dashboard/meter-model.d.ts.map +1 -0
  29. package/dist/dashboard/meter-model.js +91 -0
  30. package/dist/dashboard/meter-parts.d.ts +42 -0
  31. package/dist/dashboard/meter-parts.d.ts.map +1 -0
  32. package/dist/dashboard/meter-parts.js +163 -0
  33. package/dist/dashboard/meter.d.ts +112 -0
  34. package/dist/dashboard/meter.d.ts.map +1 -0
  35. package/dist/dashboard/meter.js +43 -0
  36. package/dist/dashboard/meter.module.css +150 -0
  37. package/dist/dashboard/meter.module.css.d.ts +28 -0
  38. package/dist/dashboard/scale.d.ts +9 -0
  39. package/dist/dashboard/scale.d.ts.map +1 -0
  40. package/dist/dashboard/scale.js +10 -0
  41. package/dist/index.d.ts +1 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +5 -1
  44. package/dist/tokens/derive.d.ts +11 -1
  45. package/dist/tokens/derive.d.ts.map +1 -1
  46. package/dist/tokens/derive.js +9 -24
  47. package/dist/tokens/status-text.d.ts +26 -0
  48. package/dist/tokens/status-text.d.ts.map +1 -0
  49. package/dist/tokens/status-text.js +68 -0
  50. package/llms.txt +32 -3
  51. package/package.json +1 -1
  52. package/src/cli/help.ts +22 -2
  53. package/src/cli/shot/capture.ts +98 -9
  54. package/src/cli/shot/index.ts +50 -4
  55. package/src/cli/shot/real-data.ts +165 -0
  56. package/src/cli/shot/serve.ts +28 -3
  57. package/src/dashboard/bar-list.module.css +73 -0
  58. package/src/dashboard/bar-list.module.css.d.ts +16 -0
  59. package/src/dashboard/bar-list.tsx +112 -0
  60. package/src/dashboard/index.ts +2 -0
  61. package/src/dashboard/meter-model.ts +161 -0
  62. package/src/dashboard/meter-parts.tsx +223 -0
  63. package/src/dashboard/meter.module.css +150 -0
  64. package/src/dashboard/meter.module.css.d.ts +28 -0
  65. package/src/dashboard/meter.tsx +162 -0
  66. package/src/dashboard/scale.ts +13 -0
  67. package/src/index.ts +4 -0
  68. package/src/tokens/derive.ts +19 -31
  69. package/src/tokens/status-text.ts +85 -0
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Status text solver — the `--vx-status-good|warn|bad` solids are painted as TEXT (`DeltaBadge`,
3
+ * a toned breakdown row), so each must clear WCAG AA on every text surface of the palette it ships
4
+ * in. The calibrated stops below are kept unchanged when they already clear every surface (the
5
+ * default config); otherwise each walks along its lightness axis only — light darkens, dark
6
+ * lightens, hue preserved (chroma may clip at the gamut edge) — to the first tone that does.
7
+ */
8
+ import type { ColorPair } from './core'
9
+ import type { StatusKey, SurfaceKey } from './derive'
10
+ import { contrastRatio, hctToHex } from './hct'
11
+
12
+ type Side = 'light' | 'dark'
13
+ type Stop = { readonly tone: number; readonly chroma: number }
14
+
15
+ export const STATUS_HUE: Readonly<Record<StatusKey, number>> = {
16
+ good: 151.975,
17
+ warn: 76.64,
18
+ bad: 29.905,
19
+ }
20
+
21
+ export const STATUS_STOP: Readonly<Record<StatusKey, Readonly<Record<Side, Stop>>>> = {
22
+ good: { light: { tone: 45.75, chroma: 37.75 }, dark: { tone: 70.23, chroma: 53.23 } },
23
+ warn: { light: { tone: 46, chroma: 61.12 }, dark: { tone: 72.34, chroma: 62.55 } },
24
+ bad: { light: { tone: 43.86, chroma: 54.46 }, dark: { tone: 66.5, chroma: 53.79 } },
25
+ }
26
+
27
+ /** The surfaces status text is painted on — exhaustive, so a new `SurfaceKey` must pick a side. */
28
+ export const STATUS_TEXT_SURFACES: Readonly<Record<SurfaceKey, boolean>> = {
29
+ bg: true,
30
+ panel: true,
31
+ panelHover: true,
32
+ elevated: true,
33
+ subtle: true,
34
+ field: true,
35
+ border: false,
36
+ hairline: false,
37
+ }
38
+
39
+ export const STATUS_TEXT_CONTRAST_MIN = 4.5
40
+ export const STATUS_TONE_STEP = 0.25
41
+
42
+ const TEXT_SURFACE_KEYS = (Object.keys(STATUS_TEXT_SURFACES) as SurfaceKey[]).filter(
43
+ (key) => STATUS_TEXT_SURFACES[key],
44
+ )
45
+ const STATUS_KEYS = Object.keys(STATUS_HUE) as StatusKey[]
46
+
47
+ /** The hex at the `step`-th tone from `stop` along the side's lightness axis (0 = the stop). */
48
+ export function statusHexAtStep(key: StatusKey, side: Side, step: number): string {
49
+ const stop = STATUS_STOP[key][side]
50
+ const direction = side === 'light' ? -1 : 1
51
+ return hctToHex({
52
+ hue: STATUS_HUE[key],
53
+ chroma: stop.chroma,
54
+ tone: stop.tone + direction * step * STATUS_TONE_STEP,
55
+ })
56
+ }
57
+
58
+ function clearsEverySurface(hex: string, side: Side, surfaces: Record<SurfaceKey, ColorPair>) {
59
+ return TEXT_SURFACE_KEYS.every(
60
+ (key) => contrastRatio(hex, surfaces[key][side]) >= STATUS_TEXT_CONTRAST_MIN,
61
+ )
62
+ }
63
+
64
+ function solve(key: StatusKey, side: Side, surfaces: Record<SurfaceKey, ColorPair>): string {
65
+ const { tone } = STATUS_STOP[key][side]
66
+ const maxSteps = Math.floor((side === 'light' ? tone : 100 - tone) / STATUS_TONE_STEP)
67
+ for (let step = 0; step <= maxSteps; step++) {
68
+ const hex = statusHexAtStep(key, side, step)
69
+ if (clearsEverySurface(hex, side, surfaces)) return hex
70
+ }
71
+ throw new Error(
72
+ `status text: no ${side} ${key} tone reaches ${STATUS_TEXT_CONTRAST_MIN}:1 on every surface`,
73
+ )
74
+ }
75
+
76
+ /** The three status solids for a derived palette's surfaces. */
77
+ export function deriveStatusHexes(
78
+ surfaces: Record<SurfaceKey, ColorPair>,
79
+ ): Record<StatusKey, ColorPair> {
80
+ const status = {} as Record<StatusKey, ColorPair>
81
+ for (const key of STATUS_KEYS) {
82
+ status[key] = { light: solve(key, 'light', surfaces), dark: solve(key, 'dark', surfaces) }
83
+ }
84
+ return status
85
+ }