basalt-ui 1.1.1 → 1.2.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/AGENTS.md +2 -2
- package/CHANGELOG.md +30 -0
- package/README.md +47 -5
- package/agent/rules/basalt-app.md +126 -0
- package/agent/rules/basalt-content.md +3 -1
- package/agent/skills/basalt-app/SKILL.md +28 -7
- package/dist/agent/part-list.d.ts.map +1 -1
- package/dist/agent/part-list.js +17 -7
- package/dist/agent/stick-to-bottom.js +2 -2
- package/dist/agent-chat/thread-detail-panel.d.ts.map +1 -1
- package/dist/agent-chat/thread-detail-panel.js +37 -33
- package/dist/agent-chat/thread-message.d.ts.map +1 -1
- package/dist/agent-chat/thread-message.js +8 -5
- package/dist/agent-chat/thread-outcome-card.js +3 -3
- package/dist/agent-chat/thread-workspace.js +1 -1
- package/dist/charts/primitives/ChartLegend.js +2 -0
- package/dist/charts/primitives/ChartTooltip.js +2 -1
- package/dist/cli/index.d.ts +15 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +29 -7
- package/dist/connectivity/connectivity-indicator.d.ts.map +1 -1
- package/dist/connectivity/connectivity-indicator.js +3 -3
- package/dist/content/article-card.module.css +7 -5
- package/dist/content/article-layout.module.css +16 -12
- package/dist/content/callout.module.css +4 -4
- package/dist/content/code-block.module.css +8 -7
- package/dist/content/guide.module.css +3 -3
- package/dist/content/mermaid.module.css +2 -2
- package/dist/content/prose.module.css +59 -29
- package/dist/content/reading-progress.module.css +2 -0
- package/dist/content/toc.module.css +6 -3
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +10 -2
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/empty-state.js +3 -16
- package/dist/dashboard/settings-section.js +2 -2
- package/dist/dashboard/settings-section.module.css +2 -2
- package/dist/dashboard/stat-card.js +2 -1
- package/dist/data/virtual-list.d.ts.map +1 -1
- package/dist/data/virtual-list.js +12 -2
- package/dist/forms/FormErrorSummary.js +2 -2
- package/dist/guard/index.d.ts +20 -4
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +250 -37
- package/dist/guard/types.d.ts +24 -3
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/provider/index.d.ts +30 -1
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +32 -7
- package/dist/provider/lab-theme.d.ts +39 -0
- package/dist/provider/lab-theme.d.ts.map +1 -0
- package/dist/provider/lab-theme.js +52 -0
- package/dist/shell/app-header.module.css +2 -2
- package/dist/shell/app-mobile-nav.module.css +1 -1
- package/dist/shell/app-sidebar-account.d.ts.map +1 -1
- package/dist/shell/app-sidebar-account.js +4 -2
- package/dist/shell/app-sidebar.d.ts.map +1 -1
- package/dist/shell/app-sidebar.js +4 -2
- package/dist/shell/app-sidebar.module.css +36 -26
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +11 -4
- package/dist/shell/sidebar-search.module.css +16 -4
- package/dist/styles.css +1 -1
- package/dist/surfaces.d.ts +15 -11
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +4 -3
- package/dist/theme/controls.module.css +1 -1
- package/dist/theme/floating.module.css +1 -1
- package/dist/theme/index.d.ts +116 -11
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +703 -566
- package/dist/theme/nav-link.module.css +1 -1
- package/dist/theme/use-basalt-spacing.d.ts +3 -0
- package/dist/theme/use-basalt-spacing.d.ts.map +1 -0
- package/dist/theme/use-basalt-spacing.js +8 -0
- package/dist/theme-lab/derive-controls.d.ts +13 -0
- package/dist/theme-lab/derive-controls.d.ts.map +1 -0
- package/dist/theme-lab/derive-controls.js +137 -0
- package/dist/theme-lab/derive-state.d.ts +55 -0
- package/dist/theme-lab/derive-state.d.ts.map +1 -0
- package/dist/theme-lab/derive-state.js +81 -0
- package/dist/theme-lab/index.d.ts +12 -2
- package/dist/theme-lab/index.d.ts.map +1 -1
- package/dist/theme-lab/index.js +13 -62
- package/dist/theme-toggle/index.d.ts.map +1 -1
- package/dist/theme-toggle/index.js +3 -2
- package/dist/tokens/derive.d.ts +89 -0
- package/dist/tokens/derive.d.ts.map +1 -0
- package/dist/tokens/derive.js +250 -0
- package/dist/tokens/hct.d.ts +34 -0
- package/dist/tokens/hct.d.ts.map +1 -0
- package/dist/tokens/hct.js +159 -0
- package/dist/tokens/index.d.ts +71 -7
- package/dist/tokens/index.d.ts.map +1 -1
- package/dist/tokens/index.js +284 -46
- package/dist/tokens/palette.d.ts +984 -167
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +617 -119
- package/dist/vite-color-mix.d.ts +30 -0
- package/dist/vite-color-mix.d.ts.map +1 -0
- package/dist/vite-color-mix.js +80 -0
- package/dist/vite.d.ts +82 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +312 -0
- package/llms.txt +5 -4
- package/package.json +24 -9
- package/src/agent/part-list.tsx +13 -7
- package/src/agent/stick-to-bottom.tsx +2 -2
- package/src/agent-chat/thread-detail-panel.tsx +13 -10
- package/src/agent-chat/thread-message.tsx +8 -5
- package/src/agent-chat/thread-outcome-card.tsx +2 -2
- package/src/agent-chat/thread-workspace.tsx +2 -2
- package/src/charts/primitives/ChartLegend.tsx +2 -2
- package/src/charts/primitives/ChartTooltip.tsx +2 -2
- package/src/cli/check-theme.test.ts +18 -0
- package/src/cli/index.ts +55 -5
- package/src/connectivity/connectivity-indicator.tsx +8 -2
- package/src/content/article-card.module.css +7 -5
- package/src/content/article-layout.module.css +16 -12
- package/src/content/callout.module.css +4 -4
- package/src/content/code-block.module.css +8 -7
- package/src/content/guide.module.css +3 -3
- package/src/content/mermaid.module.css +2 -2
- package/src/content/prose.module.css +59 -29
- package/src/content/prose.module.css.test.ts +55 -0
- package/src/content/reading-progress.module.css +2 -0
- package/src/content/toc.module.css +6 -3
- package/src/dashboard/delta-badge.tsx +10 -4
- package/src/dashboard/empty-state.tsx +3 -16
- package/src/dashboard/settings-section.module.css +2 -2
- package/src/dashboard/settings-section.tsx +2 -2
- package/src/dashboard/stat-card.tsx +2 -2
- package/src/data/virtual-list.tsx +12 -2
- package/src/forms/FormErrorSummary.tsx +1 -1
- package/src/guard/check-source.test.ts +416 -5
- package/src/guard/index.ts +367 -45
- package/src/guard/types.ts +24 -2
- package/src/index.ts +1 -0
- package/src/provider/index.test.tsx +100 -0
- package/src/provider/index.tsx +79 -7
- package/src/provider/lab-theme.test.ts +147 -0
- package/src/provider/lab-theme.ts +166 -0
- package/src/shell/app-header.module.css +2 -2
- package/src/shell/app-mobile-nav.module.css +1 -1
- package/src/shell/app-sidebar-account.tsx +9 -2
- package/src/shell/app-sidebar.module.css +36 -26
- package/src/shell/app-sidebar.tsx +12 -2
- package/src/shell/index.tsx +14 -3
- package/src/shell/sidebar-search.module.css +16 -4
- package/src/styles.css +1 -1
- package/src/surfaces.ts +17 -10
- package/src/theme/contrast.test.ts +19 -3
- package/src/theme/controls.module.css +1 -1
- package/src/theme/density-option.test.ts +96 -0
- package/src/theme/density-relations.test.ts +428 -0
- package/src/theme/derive-theme.test.ts +101 -0
- package/src/theme/floating.module.css +1 -1
- package/src/theme/fonts-option.test.ts +69 -0
- package/src/theme/index.ts +930 -563
- package/src/theme/nav-link.module.css +1 -1
- package/src/theme/radius-option.test.ts +86 -0
- package/src/theme/radius.test.ts +132 -0
- package/src/theme/spacing.test.ts +432 -0
- package/src/theme/use-basalt-spacing.test.tsx +51 -0
- package/src/theme/use-basalt-spacing.ts +38 -0
- package/src/theme-lab/derive-controls.test.ts +94 -0
- package/src/theme-lab/derive-controls.tsx +227 -0
- package/src/theme-lab/derive-state.test.ts +71 -0
- package/src/theme-lab/derive-state.ts +163 -0
- package/src/theme-lab/index.tsx +29 -68
- package/src/theme-lab/theme-lab.test.ts +4 -18
- package/src/theme-toggle/index.tsx +9 -4
- package/src/tokens/build-fonts-css.test.ts +51 -0
- package/src/tokens/build-radius-css.test.ts +25 -0
- package/src/tokens/density.test.ts +274 -0
- package/src/tokens/derive-radius.test.ts +62 -0
- package/src/tokens/derive.test.ts +30 -0
- package/src/tokens/derive.ts +481 -0
- package/src/tokens/hct.ts +231 -0
- package/src/tokens/index.ts +395 -45
- package/src/tokens/palette.test.ts +114 -0
- package/src/tokens/palette.ts +1118 -180
- package/src/vite-color-mix.test.ts +46 -0
- package/src/vite-color-mix.ts +137 -0
- package/src/vite.test.ts +192 -0
- package/src/vite.ts +502 -1
package/src/theme-lab/index.tsx
CHANGED
|
@@ -18,9 +18,12 @@
|
|
|
18
18
|
* into `palette.ts` permanently.
|
|
19
19
|
*
|
|
20
20
|
* Grounded in argo `apps/dashboard/src/lib/theme-lab.ts` + `components/theme-lab-panel.tsx`.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* Identity/color tuning now lives exclusively in `DeriveControls` (one accent seed + bounded
|
|
22
|
+
* knobs) — the `ThemeLabControls` default {@link COLOR_GROUPS} below is a low-level inspector for
|
|
23
|
+
* the few `--vx-*` vars that stay hand-authored (chart-only status hues, chart line/dot chrome,
|
|
24
|
+
* the floating overlay surface), not an identity tuner. Argo's domain series groups (Health /
|
|
25
|
+
* Strength / Walking) are DROPPED — a consumer passes its own series groups via
|
|
26
|
+
* `ThemeLabControls`'s `groups` prop.
|
|
24
27
|
*/
|
|
25
28
|
import {
|
|
26
29
|
ActionIcon,
|
|
@@ -37,11 +40,11 @@ import {
|
|
|
37
40
|
} from '@mantine/core'
|
|
38
41
|
import { useState } from 'react'
|
|
39
42
|
import type { ReactNode } from 'react'
|
|
40
|
-
import { BP
|
|
43
|
+
import { BP } from '../tokens/palette'
|
|
41
44
|
import { VX } from '../tokens'
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
export { DeriveControls } from './derive-controls'
|
|
47
|
+
export type { DeriveControlsProps } from './derive-controls'
|
|
45
48
|
|
|
46
49
|
export type ColorTunable = { var: string; label: string }
|
|
47
50
|
export type ColorGroup = { title: string; items: ColorTunable[] }
|
|
@@ -52,88 +55,46 @@ export const AREA_TOP_VAR = '--vx-area-top'
|
|
|
52
55
|
export const AREA_BOTTOM_VAR = '--vx-area-bottom'
|
|
53
56
|
|
|
54
57
|
/**
|
|
55
|
-
*
|
|
56
|
-
* so `rgba()`/`color-mix()` chrome
|
|
58
|
+
* Structural `--vx-*` vars worth tuning by eye — the ones `tokens/palette.ts` hand-authors and
|
|
59
|
+
* that never move with the derive config (ColorInput is hex-only, so `rgba()`/`color-mix()` chrome
|
|
60
|
+
* vars like `--vx-axis` / `--vx-grid` are intentionally omitted regardless).
|
|
61
|
+
*
|
|
62
|
+
* Identity/color tuning lives exclusively in {@link DeriveControls} (one accent seed + bounded
|
|
63
|
+
* knobs, `tokens/derive.ts`) — every `--vx-*` var GENERATED from that config (the accent family,
|
|
64
|
+
* the 12 categorical fills, the ink ramp, most of the surface stops, the `good`/`warn`/`bad`
|
|
65
|
+
* status/semantic hues) has been pruned from here on purpose: hand-tuning a hex the derive engine
|
|
66
|
+
* regenerates on every render is a dead knob. What remains is a low-level inspector for the
|
|
67
|
+
* genuinely NON-derived structural tokens only.
|
|
57
68
|
*
|
|
58
69
|
* Generic by design: argo's domain series (Health / Strength / Walking) are NOT shipped — a
|
|
59
70
|
* consumer passes its own series groups to {@link ThemeLabControls} via the `groups` prop.
|
|
60
71
|
*/
|
|
61
72
|
export const COLOR_GROUPS: ColorGroup[] = [
|
|
62
73
|
{
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
// onto it (theme/index.ts). `On accent` is the label ON that fill — the theme cannot recompute
|
|
68
|
-
// contrast in CSS, so if you tune `Fill` light, drop `On accent` to a dark ink yourself.
|
|
69
|
-
title: 'Accent',
|
|
70
|
-
items: [
|
|
71
|
-
{ var: '--vx-accent', label: 'Accent (ink)' },
|
|
72
|
-
{ var: '--vx-accentHover', label: 'Accent hover' },
|
|
73
|
-
{ var: '--vx-accentFill', label: 'Fill' },
|
|
74
|
-
{ var: '--vx-accentFillHover', label: 'Fill hover' },
|
|
75
|
-
{ var: '--vx-onAccent', label: 'On accent' },
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
// Every filled surface in the Mantine chrome, single-sourced (theme/index.ts bridges
|
|
80
|
-
// `--mantine-color-{family}-filled` onto these). They all sit in ONE luminance band so a white
|
|
81
|
-
// label always works — retune within it, or you break the label. Hover is derived from the
|
|
82
|
-
// fill, so it follows automatically and is not listed. `blue` lives under Accent → Fill.
|
|
83
|
-
title: 'Fills',
|
|
84
|
-
items: FILL_FAMILIES.map((name) => ({
|
|
85
|
-
var: `--vx-fill-${name}`,
|
|
86
|
-
label: name.charAt(0).toUpperCase() + name.slice(1),
|
|
87
|
-
})),
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
title: 'Ink',
|
|
91
|
-
items: [
|
|
92
|
-
{ var: '--vx-ink', label: 'Ink' },
|
|
93
|
-
{ var: '--vx-ink2', label: 'Ink 2' },
|
|
94
|
-
{ var: '--vx-muted', label: 'Muted' },
|
|
95
|
-
{ var: '--vx-faint', label: 'Faint' },
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
title: 'Semantic',
|
|
100
|
-
items: [
|
|
101
|
-
{ var: '--vx-goodSolid', label: 'Good' },
|
|
102
|
-
{ var: '--vx-warnSolid', label: 'Warn' },
|
|
103
|
-
{ var: '--vx-badSolid', label: 'Bad' },
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
title: 'Status',
|
|
74
|
+
// `excellent` (top-of-scale grade) and `neutral` (mid-scale) keep their own hand-authored BP
|
|
75
|
+
// families (`p(BP.forest)` / `p(BP.gray, 1, 2)`) — unlike `good`/`warn`/`bad`, which are the
|
|
76
|
+
// SAME derived hues as `Semantic` and are not independently tunable here.
|
|
77
|
+
title: 'Status (chart-only)',
|
|
108
78
|
items: [
|
|
109
79
|
{ var: '--vx-status-excellent', label: 'Excellent' },
|
|
110
|
-
{ var: '--vx-status-good', label: 'Good' },
|
|
111
|
-
{ var: '--vx-status-warn', label: 'Warn' },
|
|
112
|
-
{ var: '--vx-status-bad', label: 'Bad' },
|
|
113
80
|
{ var: '--vx-status-neutral', label: 'Neutral' },
|
|
114
81
|
],
|
|
115
82
|
},
|
|
116
83
|
{
|
|
117
|
-
|
|
84
|
+
// Chart line/dot chrome — hand-authored off the zinc `BP.gray`/`BP.white`/`BP.darkGray`
|
|
85
|
+
// families, independent of the derive config.
|
|
86
|
+
title: 'Chart chrome',
|
|
118
87
|
items: [
|
|
119
88
|
{ var: '--vx-line', label: 'Line' },
|
|
120
89
|
{ var: '--vx-line2', label: 'Line 2' },
|
|
121
|
-
{ var: '--vx-neutral', label: 'Neutral' },
|
|
122
90
|
{ var: '--vx-dotStroke', label: 'Dot stroke' },
|
|
123
91
|
],
|
|
124
92
|
},
|
|
125
93
|
{
|
|
94
|
+
// The floating-layer surface (menus, popovers, tooltips, modals, drawers) — the one SURFACE
|
|
95
|
+
// stop the derive engine has no law for, so it stays a hand-picked hex/color-mix().
|
|
126
96
|
title: 'Surface',
|
|
127
|
-
items: [
|
|
128
|
-
{ var: '--vx-surface-bg', label: 'Background' },
|
|
129
|
-
{ var: '--vx-surface-panel', label: 'Panel' },
|
|
130
|
-
{ var: '--vx-surface-panelHover', label: 'Panel hover' },
|
|
131
|
-
{ var: '--vx-surface-elevated', label: 'Elevated' },
|
|
132
|
-
{ var: '--vx-surface-subtle', label: 'Subtle' },
|
|
133
|
-
{ var: '--vx-surface-overlay', label: 'Overlay' },
|
|
134
|
-
{ var: '--vx-surface-field', label: 'Field' },
|
|
135
|
-
{ var: '--vx-surface-border', label: 'Border' },
|
|
136
|
-
],
|
|
97
|
+
items: [{ var: '--vx-surface-overlay', label: 'Overlay' }],
|
|
137
98
|
},
|
|
138
99
|
]
|
|
139
100
|
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
* drift silently into tuning dead variables, or into tuning live ones that no component consumes.
|
|
7
7
|
* Both failure modes look identical to the user: "the theme lab does nothing".
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* `COLOR_GROUPS` is now a structural-token inspector ONLY (identity/color tuning moved to
|
|
10
|
+
* `DeriveControls`) — this test ties the remaining vars to `buildPaletteCss`'s actual output, so a
|
|
11
|
+
* var in `COLOR_GROUPS` that is secretly DERIVED (and would drift the moment the derive config
|
|
12
|
+
* changes) never sneaks back in undetected.
|
|
11
13
|
*/
|
|
12
14
|
import { describe, expect, test } from 'bun:test'
|
|
13
15
|
import { buildPaletteCss } from '../tokens'
|
|
@@ -26,22 +28,6 @@ describe('every tunable var is really emitted by the palette', () => {
|
|
|
26
28
|
}
|
|
27
29
|
})
|
|
28
30
|
|
|
29
|
-
describe('the tunables cover the accent — the token most worth tuning', () => {
|
|
30
|
-
// The lab shipped WITHOUT any accent knob at all (Semantic / Status / Neutral / Surface only),
|
|
31
|
-
// which is why tuning it never touched the brand color.
|
|
32
|
-
for (const name of [
|
|
33
|
-
'--vx-accent',
|
|
34
|
-
'--vx-accentHover',
|
|
35
|
-
'--vx-accentFill',
|
|
36
|
-
'--vx-accentFillHover',
|
|
37
|
-
'--vx-onAccent',
|
|
38
|
-
]) {
|
|
39
|
-
test(name, () => {
|
|
40
|
-
expect(TUNABLES).toContain(name)
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
|
|
45
31
|
describe('tunables are OPAQUE — ColorInput (format="hex") has no alpha channel', () => {
|
|
46
32
|
// A translucent token (`--vx-divider`, `--vx-grid`, `--vx-good`: `color-mix(… , transparent)`)
|
|
47
33
|
// would be silently flattened to a solid color on first edit. Opaque `color-mix()`es are fine —
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import {
|
|
16
16
|
ActionIcon,
|
|
17
|
+
Center,
|
|
17
18
|
Popover,
|
|
18
19
|
SegmentedControl,
|
|
19
20
|
useComputedColorScheme,
|
|
@@ -72,14 +73,18 @@ function MoonGlyph() {
|
|
|
72
73
|
/** The animated sun/moon glyph — crossfades + rotates between the two on scheme change. */
|
|
73
74
|
function SchemeGlyph({ dark, reduceMotion }: { dark: boolean; reduceMotion: boolean }) {
|
|
74
75
|
if (reduceMotion) {
|
|
75
|
-
return
|
|
76
|
+
return (
|
|
77
|
+
<Center component="span" inline>
|
|
78
|
+
{dark ? <MoonGlyph /> : <SunGlyph />}
|
|
79
|
+
</Center>
|
|
80
|
+
)
|
|
76
81
|
}
|
|
77
82
|
return (
|
|
78
83
|
<AnimatePresence mode="wait" initial={false}>
|
|
79
84
|
{dark ? (
|
|
80
85
|
<motion.span
|
|
81
86
|
key="moon"
|
|
82
|
-
style={{ display: 'inline-flex' }}
|
|
87
|
+
style={{ display: 'inline-flex' }} // theme-allow: framer-motion element — inline-flex glyph wrapper, not a Mantine node
|
|
83
88
|
initial={{ opacity: 0, scale: 0.6, rotate: 30 }}
|
|
84
89
|
animate={{ opacity: 1, scale: 1, rotate: 0 }}
|
|
85
90
|
exit={{ opacity: 0, scale: 0.6, rotate: -30 }}
|
|
@@ -90,7 +95,7 @@ function SchemeGlyph({ dark, reduceMotion }: { dark: boolean; reduceMotion: bool
|
|
|
90
95
|
) : (
|
|
91
96
|
<motion.span
|
|
92
97
|
key="sun"
|
|
93
|
-
style={{ display: 'inline-flex' }}
|
|
98
|
+
style={{ display: 'inline-flex' }} // theme-allow: framer-motion element — inline-flex glyph wrapper, not a Mantine node
|
|
94
99
|
initial={{ opacity: 0, scale: 0.6, rotate: -30 }}
|
|
95
100
|
animate={{ opacity: 1, scale: 1, rotate: 0 }}
|
|
96
101
|
exit={{ opacity: 0, scale: 0.6, rotate: 30 }}
|
|
@@ -146,7 +151,7 @@ export function ThemeToggle({ openDelay = 150, closeDelay = 200 }: ThemeTogglePr
|
|
|
146
151
|
<ActionIcon
|
|
147
152
|
variant="subtle"
|
|
148
153
|
color="gray"
|
|
149
|
-
|
|
154
|
+
style={{ borderRadius: 'var(--vx-radius-ctrl)' }}
|
|
150
155
|
aria-label={`Theme: ${LABEL[colorScheme]}. Click to cycle, hover to pick directly.`}
|
|
151
156
|
onClick={() => setColorScheme(nextScheme(colorScheme))}
|
|
152
157
|
onMouseEnter={scheduleOpen}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `buildFontsCss` — the pure CSS-building half of the `{ fonts }` option (see
|
|
3
|
+
* `../theme/fonts-option.test.ts` for the `theme.other.basaltFonts` round-trip this consumes).
|
|
4
|
+
* `BasaltBridge` calls this directly to append `--basalt-font-*` declarations to the same injected
|
|
5
|
+
* `<style>` as the palette CSS; no DOM/render harness is configured in this package, so the pure
|
|
6
|
+
* function is the testable seam.
|
|
7
|
+
*/
|
|
8
|
+
import { describe, expect, test } from 'bun:test'
|
|
9
|
+
import { buildFontsCss } from './index'
|
|
10
|
+
|
|
11
|
+
describe('buildFontsCss', () => {
|
|
12
|
+
test('returns empty string when fonts is undefined', () => {
|
|
13
|
+
expect(buildFontsCss(undefined)).toBe('')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test('returns empty string when fonts is an empty object', () => {
|
|
17
|
+
expect(buildFontsCss({})).toBe('')
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
test('emits a --basalt-font-sans declaration for a provided sans value', () => {
|
|
21
|
+
const css = buildFontsCss({ sans: 'Inter, sans-serif' })
|
|
22
|
+
expect(css).toContain('--basalt-font-sans: Inter, sans-serif;')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test('emits declarations only for the provided keys, omitting the rest', () => {
|
|
26
|
+
const css = buildFontsCss({ sans: 'Inter, sans-serif' })
|
|
27
|
+
expect(css).not.toContain('--basalt-font-head')
|
|
28
|
+
expect(css).not.toContain('--basalt-font-mono')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test('emits all three declarations under one :root block when all three are provided', () => {
|
|
32
|
+
const css = buildFontsCss({
|
|
33
|
+
sans: 'Inter, sans-serif',
|
|
34
|
+
head: 'Poppins, sans-serif',
|
|
35
|
+
mono: 'Fira Code, monospace',
|
|
36
|
+
})
|
|
37
|
+
expect(css).toContain(':root {')
|
|
38
|
+
expect(css).toContain('--basalt-font-sans: Inter, sans-serif;')
|
|
39
|
+
expect(css).toContain('--basalt-font-head: Poppins, sans-serif;')
|
|
40
|
+
expect(css).toContain('--basalt-font-mono: Fira Code, monospace;')
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test('throws on values that could break out of the emitted declaration', () => {
|
|
44
|
+
expect(() => buildFontsCss({ sans: 'Inter; } body { color: red' })).toThrow(
|
|
45
|
+
/Invalid fonts.sans/,
|
|
46
|
+
)
|
|
47
|
+
expect(() => buildFontsCss({ head: 'Poppins }' })).toThrow(/Invalid fonts.head/)
|
|
48
|
+
expect(() => buildFontsCss({ mono: 'Fira /* x */ Code' })).toThrow(/Invalid fonts.mono/)
|
|
49
|
+
expect(() => buildFontsCss({ sans: "'Segoe UI', system-ui, sans-serif" })).not.toThrow()
|
|
50
|
+
})
|
|
51
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `buildRadiusCss` — the pure CSS-building half of the `{ radius }` option (see
|
|
3
|
+
* `../theme/radius-option.test.ts` for the `theme.other.basaltRadius` round-trip this consumes).
|
|
4
|
+
* `BasaltBridge` calls this directly to append overriding `--vx-radius-*` declarations to the same
|
|
5
|
+
* injected `<style>` as the palette CSS; mirrors `build-fonts-css.test.ts`.
|
|
6
|
+
*/
|
|
7
|
+
import { describe, expect, test } from 'bun:test'
|
|
8
|
+
import { deriveRadius } from './palette'
|
|
9
|
+
import { buildRadiusCss } from './index'
|
|
10
|
+
|
|
11
|
+
describe('buildRadiusCss', () => {
|
|
12
|
+
test('returns empty string when radius is undefined', () => {
|
|
13
|
+
expect(buildRadiusCss(undefined)).toBe('')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test('emits all five overriding declarations under one :root block', () => {
|
|
17
|
+
const css = buildRadiusCss(deriveRadius(2))
|
|
18
|
+
expect(css).toContain(':root {')
|
|
19
|
+
expect(css).toContain('--vx-radius-card: 9px;')
|
|
20
|
+
expect(css).toContain('--vx-radius-ctrl: 8px;')
|
|
21
|
+
expect(css).toContain('--vx-radius-tight: 7px;')
|
|
22
|
+
expect(css).toContain('--vx-radius-fine: 6px;')
|
|
23
|
+
expect(css).toContain('--vx-radius-floating: 10px;')
|
|
24
|
+
})
|
|
25
|
+
})
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `deriveSpacing` — the spacing analog of `deriveRadius`. Locks the law (a `1 + 0.1 * level`
|
|
3
|
+
* multiplier, over a narrower `[-3, 3]` range than `deriveRadius`'s `[-5, 5]` — see `deriveSpacing`'s
|
|
4
|
+
* own JSDoc in `palette.ts` for why — applied to every density-tracking anchor/scale-stop/one-off,
|
|
5
|
+
* rounded and floored at 1, plus the row line-height's own additive law) at a handful of levels,
|
|
6
|
+
* plus the throw-and-propagate
|
|
7
|
+
* validation and `buildDensityCss`'s CSS output. `theme/spacing.test.ts` separately locks that
|
|
8
|
+
* `SPACE`/`SPACE_SCALE`/`SPACE_STEP`/`ROW_LINE_HEIGHT` equal `deriveSpacing(0)`'s output
|
|
9
|
+
* byte-for-byte — this file is the law itself (and the CSS builder), not the shipped-identity
|
|
10
|
+
* snapshot. Lives in `tokens/` (a sibling to `derive-radius.test.ts`/`build-radius-css.test.ts`,
|
|
11
|
+
* merged into one file here) rather than extending `theme/spacing.test.ts`: that file's own doc
|
|
12
|
+
* comment scopes it strictly to "the rendered output must stay byte-identical to the numbers
|
|
13
|
+
* shipped" — the LAW at non-zero levels is a different concern, same split radius already made.
|
|
14
|
+
*/
|
|
15
|
+
import { describe, expect, test } from 'bun:test'
|
|
16
|
+
import { buildDensityCss, VX } from './index'
|
|
17
|
+
import { deriveSpacing, scaleSpace } from './palette'
|
|
18
|
+
|
|
19
|
+
// The "deriveSpacing(0) matches SPACE/SPACE_SCALE/SPACE_STEP/ROW_LINE_HEIGHT byte-for-byte" check
|
|
20
|
+
// used to live here as its own test — deleted, not merely renamed: `SPACE`/`SPACE_SCALE`/
|
|
21
|
+
// `SPACE_STEP`/`ROW_LINE_HEIGHT` (`palette.ts`) are DEFINED as `DEFAULT_SPACE_VALUES = deriveSpacing(0)`
|
|
22
|
+
// and its destructured fields, so `expect(deriveSpacing(0)).toEqual({ anchors: SPACE, ... })` compared
|
|
23
|
+
// `deriveSpacing(0)` against itself — no source-level change could ever fail it. The real level-0
|
|
24
|
+
// acceptance gate (a hardcoded literal table, not a derived comparison) lives in
|
|
25
|
+
// `theme/spacing.test.ts`.
|
|
26
|
+
describe('deriveSpacing(0) reproduces the shipped identity exactly', () => {
|
|
27
|
+
test('a non-integer base (proseInlineCodeInsetY: 1.5) survives untouched at level 0', () => {
|
|
28
|
+
// The naive `Math.round(1.5 * 1)` rounds half-up to 2 — `deriveSpacing` must special-case
|
|
29
|
+
// level 0 to skip rounding entirely, or this silently regresses the byte-identical gate.
|
|
30
|
+
expect(deriveSpacing(0).step.proseInlineCodeInsetY).toBe(1.5)
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
describe('VX chart geometry at level 0 (single-sourced from SPACE_STEP)', () => {
|
|
35
|
+
// Locks the shipped identity so a future SPACE_STEP edit can't silently move chart geometry —
|
|
36
|
+
// `VX.dotR`/`VX.legendGap`/`VX.margin` (`tokens/index.ts`) read straight off `SPACE_STEP`, which
|
|
37
|
+
// is itself `deriveSpacing(0).step` (see the top describe block above).
|
|
38
|
+
test('dotR is 5', () => expect(VX.dotR).toBe(5))
|
|
39
|
+
test('legendGap is 22', () => expect(VX.legendGap).toBe(22))
|
|
40
|
+
test('margin is { top: 12, right: 16, bottom: 30, left: 44 }', () => {
|
|
41
|
+
expect(VX.margin).toEqual({ top: 12, right: 16, bottom: 30, left: 44 })
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
describe('a positive level scales anchors/scale/step by the multiplier, rounded', () => {
|
|
46
|
+
test('level +2: a 10px anchor -> 12, a 6px anchor -> 7', () => {
|
|
47
|
+
const result = deriveSpacing(2)
|
|
48
|
+
expect(result.anchors.rowInsetX).toBe(12)
|
|
49
|
+
expect(result.anchors.rowInsetY).toBe(7)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
test('level +3 (the new endpoint — reproduces the old ±5 envelope, 0.1 * 3 === 0.06 * 5): the same two land at 13 / 8, and a 2px one-off lands at 3', () => {
|
|
53
|
+
const result = deriveSpacing(3)
|
|
54
|
+
expect(result.anchors.rowInsetX).toBe(13)
|
|
55
|
+
expect(result.anchors.rowInsetY).toBe(8)
|
|
56
|
+
expect(result.step.proseQuoteInsetY).toBe(3)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('a scale stop moves independently of the anchor stack rhythm', () => {
|
|
60
|
+
const result = deriveSpacing(3)
|
|
61
|
+
expect(result.scale.xs).toBe(14)
|
|
62
|
+
expect(result.scale.md).toBe(23)
|
|
63
|
+
// scale.md (23) diverges from anchors.stackLg (20, rebuilt from the shared stack unit) — the two
|
|
64
|
+
// groups scale by different laws (independently-rounded stops vs one shared unit) and, since the
|
|
65
|
+
// component-roominess retune moved the scale off the stack rhythm, no longer even coincide at
|
|
66
|
+
// level 0. That the two can be read apart at all is the point this locks.
|
|
67
|
+
expect(result.anchors.stackLg).toBe(20)
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
describe('a negative level scales down, floored at 1 for any base >= 1', () => {
|
|
72
|
+
test('level -3 (the new endpoint): a 10px anchor -> 7, a 6px anchor -> 4', () => {
|
|
73
|
+
const result = deriveSpacing(-3)
|
|
74
|
+
expect(result.anchors.rowInsetX).toBe(7)
|
|
75
|
+
expect(result.anchors.rowInsetY).toBe(4)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test('level -3: a 2px one-off lands at 1, not 0 (the floor)', () => {
|
|
79
|
+
expect(deriveSpacing(-3).step.proseQuoteInsetY).toBe(1)
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
test("scaleSpace's unconditional floor actually engages for a sub-1 base — the property `deriveSpacing`'s own [-3, 3] range/bases can never exercise", () => {
|
|
83
|
+
// Every real `SPACE_ANCHORS_BASE`/`SPACE_SCALE_BASE`/`SPACE_STEP_BASE` value is an integer >= 1,
|
|
84
|
+
// and the shallowest multiplier `deriveSpacing` ever passes (0.7, at level -3) still keeps
|
|
85
|
+
// `round(v * 0.7) >= 1` for any `v >= 1` — so looping `deriveSpacing(-3)`'s own output (the old
|
|
86
|
+
// form of this test) can NEVER fail regardless of whether the floor exists at all. Drive
|
|
87
|
+
// `scaleSpace` directly with a sub-1 base instead (as its own JSDoc names this test for) to
|
|
88
|
+
// exercise the actual clamp: without it, `round(0.5 * 0.7) = round(0.35) = 0`.
|
|
89
|
+
expect(scaleSpace(0.5, -3, 0.7)).toBe(1)
|
|
90
|
+
// A future base as small as `0.1` collapses even further without the floor — confirms the clamp
|
|
91
|
+
// holds regardless of how far below 1 a hypothetical base sits, not just at the one boundary case.
|
|
92
|
+
expect(scaleSpace(0.1, -3, 0.7)).toBe(1)
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
describe('the input-height anchor scales with density', () => {
|
|
97
|
+
test('level -3/0/+3: 29 / 42 / 55', () => {
|
|
98
|
+
expect(deriveSpacing(-3).anchors.inputHeight).toBe(29)
|
|
99
|
+
expect(deriveSpacing(0).anchors.inputHeight).toBe(42)
|
|
100
|
+
expect(deriveSpacing(3).anchors.inputHeight).toBe(55)
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
// The "controlHeight tracks inputHeight at every level" cross-level check used to live here as its
|
|
105
|
+
// own describe block — deleted, not merely renamed: both keys read the literal same
|
|
106
|
+
// `CONTROL_HEIGHT_BASE` and are scaled by the SAME deterministic `scaleSpace` call, so
|
|
107
|
+
// `controlHeight === inputHeight` is true BY CONSTRUCTION and can never fail regardless of what the
|
|
108
|
+
// multiplier law actually computes. `theme/density-relations.test.ts`'s "Fix 1" describe block
|
|
109
|
+
// replaced this exact form with one that asserts each key against its own hardcoded expected value
|
|
110
|
+
// (29 / 34 / 38 / 42 / 46 / 50 / 55 across the full level range) — that version bites on a change to
|
|
111
|
+
// `CONTROL_HEIGHT_BASE`, the multiplier law, OR a divergence between the two keys, none of which the
|
|
112
|
+
// by-construction equality could catch. Not re-duplicated.
|
|
113
|
+
|
|
114
|
+
// The 4px-stack-rhythm cross-level relation (2:1 pairs, exact multiples of stackXs) is covered by
|
|
115
|
+
// `theme/density-relations.test.ts`'s "Fix 2" describe block — that version asserts the DOCUMENTED
|
|
116
|
+
// exact multiples (2x/3x/4x/6x of stackXs), which subsumes and is strictly stronger than the
|
|
117
|
+
// `% === 0` divisibility form this file used to duplicate here (any value that IS `stackXs * N`
|
|
118
|
+
// trivially divides `stackXs`, so the weaker form added no independent coverage). Not re-duplicated.
|
|
119
|
+
|
|
120
|
+
describe('rowLineHeight follows its own additive law, not the multiplier', () => {
|
|
121
|
+
test('level -3/0/+3: 1.25 / 1.35 / 1.45', () => {
|
|
122
|
+
expect(deriveSpacing(-3).rowLineHeight).toBe(1.25)
|
|
123
|
+
expect(deriveSpacing(0).rowLineHeight).toBe(1.35)
|
|
124
|
+
expect(deriveSpacing(3).rowLineHeight).toBe(1.45)
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
describe('stickyHeaderClearance/stickyHeaderClearanceMobile derive from their OWN AppShell header, not a shared base (Decision 3 — responsive split)', () => {
|
|
129
|
+
test('level -3/0/+3: desktop 43 / 60 / 77 — appShellHeaderHeight + anchors.stackMd at each level', () => {
|
|
130
|
+
const low = deriveSpacing(-3)
|
|
131
|
+
const zero = deriveSpacing(0)
|
|
132
|
+
const high = deriveSpacing(3)
|
|
133
|
+
expect(low.step.stickyHeaderClearance).toBe(43)
|
|
134
|
+
expect(low.step.stickyHeaderClearance).toBe(low.step.appShellHeaderHeight + low.anchors.stackMd)
|
|
135
|
+
expect(zero.step.stickyHeaderClearance).toBe(60)
|
|
136
|
+
expect(high.step.stickyHeaderClearance).toBe(77)
|
|
137
|
+
expect(high.step.stickyHeaderClearance).toBe(
|
|
138
|
+
high.step.appShellHeaderHeight + high.anchors.stackMd,
|
|
139
|
+
)
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
test('level -3/0/+3: mobile 77 / 109 / 141 — appShellHeaderMobileHeight + anchors.stackMd at each level', () => {
|
|
143
|
+
const low = deriveSpacing(-3)
|
|
144
|
+
const zero = deriveSpacing(0)
|
|
145
|
+
const high = deriveSpacing(3)
|
|
146
|
+
expect(low.step.stickyHeaderClearanceMobile).toBe(77)
|
|
147
|
+
expect(low.step.stickyHeaderClearanceMobile).toBe(
|
|
148
|
+
low.step.appShellHeaderMobileHeight + low.anchors.stackMd,
|
|
149
|
+
)
|
|
150
|
+
expect(zero.step.stickyHeaderClearanceMobile).toBe(109)
|
|
151
|
+
expect(high.step.stickyHeaderClearanceMobile).toBe(141)
|
|
152
|
+
expect(high.step.stickyHeaderClearanceMobile).toBe(
|
|
153
|
+
high.step.appShellHeaderMobileHeight + high.anchors.stackMd,
|
|
154
|
+
)
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
test('every level: each clearance exceeds ONLY the header it exists to clear, exactly by anchors.stackMd', () => {
|
|
158
|
+
for (let level = -3; level <= 3; level++) {
|
|
159
|
+
const { step, anchors } = deriveSpacing(level)
|
|
160
|
+
expect(step.stickyHeaderClearance - step.appShellHeaderHeight).toBe(anchors.stackMd)
|
|
161
|
+
expect(step.stickyHeaderClearanceMobile - step.appShellHeaderMobileHeight).toBe(
|
|
162
|
+
anchors.stackMd,
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
describe('deriveSpacing rejects a malformed level', () => {
|
|
169
|
+
test('a non-integer throws', () => {
|
|
170
|
+
expect(() => deriveSpacing(1.5)).toThrow()
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
test('below -3 throws', () => {
|
|
174
|
+
expect(() => deriveSpacing(-4)).toThrow()
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
test('above 3 throws', () => {
|
|
178
|
+
expect(() => deriveSpacing(4)).toThrow()
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
test('the old ±5 endpoints are now out of range too', () => {
|
|
182
|
+
expect(() => deriveSpacing(-5)).toThrow()
|
|
183
|
+
expect(() => deriveSpacing(5)).toThrow()
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
test('NaN throws', () => {
|
|
187
|
+
expect(() => deriveSpacing(Number.NaN)).toThrow()
|
|
188
|
+
})
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
/** `SpaceValues` key → the `--vx-` suffix `spaceDecls` emits for it (`rowInsetX` → `space-row-inset-x`). */
|
|
192
|
+
const kebab = (key: string): string =>
|
|
193
|
+
`space-${key.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()}`
|
|
194
|
+
|
|
195
|
+
describe('buildDensityCss', () => {
|
|
196
|
+
test('returns empty string when space is undefined', () => {
|
|
197
|
+
expect(buildDensityCss(undefined)).toBe('')
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
test('emits every anchor/one-off declaration under one :root block, at the retuned level', () => {
|
|
201
|
+
const css = buildDensityCss(deriveSpacing(3))
|
|
202
|
+
expect(css).toContain(':root {')
|
|
203
|
+
expect(css).toContain('--vx-space-row-inset-x: 13px;')
|
|
204
|
+
expect(css).toContain('--vx-space-row-inset-y: 8px;')
|
|
205
|
+
expect(css).toContain('--vx-space-row-line-height: 1.45;')
|
|
206
|
+
// REM, not px — see the input-height describe block below for why.
|
|
207
|
+
expect(css).toContain('--vx-space-input-height: 3.4375rem;')
|
|
208
|
+
expect(css).toContain('--vx-space-control-height: 3.4375rem;')
|
|
209
|
+
// 77 (desktop) / 141 (mobile), not the anchor/scale/step multiplier result for an 84px base —
|
|
210
|
+
// both are DERIVED (own header + anchors.stackMd), see the dedicated describe block above.
|
|
211
|
+
expect(css).toContain('--vx-space-sticky-header-clearance: 77px;')
|
|
212
|
+
expect(css).toContain('--vx-space-sticky-header-clearance-mobile: 141px;')
|
|
213
|
+
// JS-number-only constants (Timeline's bulletSize, VX chart geometry, Progress's size) have no
|
|
214
|
+
// CSS var to override — see `spaceDecls`'s doc in `tokens/index.ts`.
|
|
215
|
+
expect(css).not.toContain('--vx-space-timeline-bullet')
|
|
216
|
+
expect(css).not.toContain('--vx-space-chart-legend-gap')
|
|
217
|
+
expect(css).not.toContain('--vx-space-progress-bar-size')
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
// The spot-checks above lock VALUES; this locks the declaration SET. Without it, `spaceDecls`
|
|
221
|
+
// could silently drop a var the migrated CSS modules consume — density would stop applying there
|
|
222
|
+
// and every value-assertion above would still pass. Derived from the `SpaceValues` keys rather
|
|
223
|
+
// than a hand-listed 104-name snapshot, so a newly added anchor/one-off has to be either emitted
|
|
224
|
+
// or explicitly declared JS-number-only here.
|
|
225
|
+
test('emits exactly one var per SpaceValues key, minus the documented JS-number-only reads', () => {
|
|
226
|
+
const space = deriveSpacing(0)
|
|
227
|
+
const emitted = new Set(
|
|
228
|
+
[...buildDensityCss(space).matchAll(/--vx-(space-[a-z0-9-]+):/g)].map((m) => m[1] as string),
|
|
229
|
+
)
|
|
230
|
+
// Read straight off the resolved `SpaceValues` as a JS number instead of through a var — each
|
|
231
|
+
// has zero `var()` consumers, so a declaration would be dead weight. See `spaceDecls`'s doc in
|
|
232
|
+
// `tokens/index.ts` for why, and `deriveSpacing`'s JSDoc for the runtime gap the chart six have.
|
|
233
|
+
const jsNumberOnly = [
|
|
234
|
+
'space-timeline-bullet', // Timeline defaultProps.bulletSize
|
|
235
|
+
'space-progress-bar-size', // Progress defaultProps.size
|
|
236
|
+
'space-sidebar-account-menu-width', // Menu width prop
|
|
237
|
+
'space-sidebar-settings-menu-width', // Menu width prop
|
|
238
|
+
'space-app-shell-header-height', // AppShell header/navbar props
|
|
239
|
+
'space-app-shell-header-mobile-height',
|
|
240
|
+
'space-app-shell-navbar-width',
|
|
241
|
+
'space-app-shell-navbar-rail-width',
|
|
242
|
+
'space-chart-legend-gap', // VX.legendGap / VX.margin / VX.dotR — visx SVG props
|
|
243
|
+
'space-chart-margin-top',
|
|
244
|
+
'space-chart-margin-right',
|
|
245
|
+
'space-chart-margin-bottom',
|
|
246
|
+
'space-chart-margin-left',
|
|
247
|
+
'space-chart-dot-r',
|
|
248
|
+
]
|
|
249
|
+
|
|
250
|
+
// `space.scale.*` (the generic Mantine scale) resolves through `--mantine-spacing-*`, not a
|
|
251
|
+
// `--vx-space-*` var, so it is not part of this contract at all.
|
|
252
|
+
const expected = [
|
|
253
|
+
...Object.keys(space.anchors).map(kebab),
|
|
254
|
+
...Object.keys(space.step).map(kebab),
|
|
255
|
+
'space-row-line-height',
|
|
256
|
+
].filter((name) => !jsNumberOnly.includes(name))
|
|
257
|
+
|
|
258
|
+
expect([...emitted].toSorted()).toEqual(expected.toSorted())
|
|
259
|
+
})
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
describe('the input-height var is emitted in REM, never a flat px', () => {
|
|
263
|
+
test("level 0 emits exactly 2.625rem — Mantine's own --input-height-md value", () => {
|
|
264
|
+
expect(buildDensityCss(deriveSpacing(0))).toContain('--vx-space-input-height: 2.625rem;')
|
|
265
|
+
expect(buildDensityCss(deriveSpacing(0))).not.toContain('--vx-space-input-height: 42px;')
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
test('a retuned level still emits rem, computed from the scaled px anchor', () => {
|
|
269
|
+
// inputHeight scales like every other anchor (42 -> 55 at level +3, the new endpoint), then
|
|
270
|
+
// converts to rem — the LAW stays px-denominated; only the CSS emission is rem, per `pxRem`.
|
|
271
|
+
expect(deriveSpacing(3).anchors.inputHeight).toBe(55)
|
|
272
|
+
expect(buildDensityCss(deriveSpacing(3))).toContain('--vx-space-input-height: 3.4375rem;')
|
|
273
|
+
})
|
|
274
|
+
})
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `deriveRadius` — the radius analog of `deriveTokens`'s color knobs. Locks the law
|
|
3
|
+
* (`docs/DESIGN-SPEC.md` §4) at a handful of levels, plus the throw-and-propagate validation.
|
|
4
|
+
* `theme/radius.test.ts` separately locks that `RADIUS`/`RADIUS_STEP` equal `deriveRadius(0)`'s
|
|
5
|
+
* output byte-for-byte — this file is the law itself, not the shipped-identity snapshot.
|
|
6
|
+
*/
|
|
7
|
+
import { describe, expect, test } from 'bun:test'
|
|
8
|
+
import { deriveRadius, RADIUS, RADIUS_STEP } from './palette'
|
|
9
|
+
|
|
10
|
+
describe('deriveRadius(0) reproduces the shipped identity', () => {
|
|
11
|
+
test('matches RADIUS/RADIUS_STEP exactly', () => {
|
|
12
|
+
expect(deriveRadius(0)).toEqual({
|
|
13
|
+
card: RADIUS.card,
|
|
14
|
+
ctrl: RADIUS.ctrl,
|
|
15
|
+
floating: RADIUS_STEP.floating,
|
|
16
|
+
tight: RADIUS_STEP.tight,
|
|
17
|
+
fine: RADIUS_STEP.fine,
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('card 7, ctrl 6, floating 8, tight 5, fine 4', () => {
|
|
22
|
+
expect(deriveRadius(0)).toEqual({ card: 7, ctrl: 6, floating: 8, tight: 5, fine: 4 })
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
describe('a positive level scales every anchor and its offsets', () => {
|
|
27
|
+
test('level +2: card 9, ctrl 8, floating 10, tight 7, fine 6', () => {
|
|
28
|
+
expect(deriveRadius(2)).toEqual({ card: 9, ctrl: 8, floating: 10, tight: 7, fine: 6 })
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test('level +5: card 12, ctrl 11, floating 13, tight 10, fine 9', () => {
|
|
32
|
+
expect(deriveRadius(5)).toEqual({ card: 12, ctrl: 11, floating: 13, tight: 10, fine: 9 })
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
describe('a negative level clamps at zero instead of going negative', () => {
|
|
37
|
+
test('level -5: card 2, ctrl 1, floating 3, tight 0, fine clamps to 0', () => {
|
|
38
|
+
expect(deriveRadius(-5)).toEqual({ card: 2, ctrl: 1, floating: 3, tight: 0, fine: 0 })
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
test('level -2: card 5, ctrl 4, floating 6, tight 3, fine 2 (no clamp needed yet)', () => {
|
|
42
|
+
expect(deriveRadius(-2)).toEqual({ card: 5, ctrl: 4, floating: 6, tight: 3, fine: 2 })
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
describe('deriveRadius rejects a malformed level', () => {
|
|
47
|
+
test('a non-integer throws', () => {
|
|
48
|
+
expect(() => deriveRadius(1.5)).toThrow()
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
test('below -5 throws', () => {
|
|
52
|
+
expect(() => deriveRadius(-6)).toThrow()
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
test('above 5 throws', () => {
|
|
56
|
+
expect(() => deriveRadius(6)).toThrow()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('NaN throws', () => {
|
|
60
|
+
expect(() => deriveRadius(Number.NaN)).toThrow()
|
|
61
|
+
})
|
|
62
|
+
})
|