basalt-ui 1.1.1 → 1.3.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 +46 -0
- package/README.md +64 -8
- package/agent/rules/basalt-app.md +126 -0
- package/agent/rules/basalt-content.md +3 -1
- package/agent/rules/basalt-tokens.md +14 -5
- 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 +29 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +80 -9
- 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 +266 -38
- 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 +22 -11
- package/dist/surfaces.d.ts +21 -11
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +10 -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 +143 -7
- package/dist/tokens/index.d.ts.map +1 -1
- package/dist/tokens/index.js +322 -48
- 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/tokens.css +248 -0
- 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 +14 -4
- package/package.json +41 -10
- 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 +129 -6
- package/src/cli/tokens-css.test.ts +90 -0
- 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 +483 -15
- package/src/guard/index.ts +426 -47
- 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 +22 -11
- package/src/surfaces.ts +24 -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 +534 -48
- 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/index.ts
CHANGED
|
@@ -68,14 +68,60 @@ import type {
|
|
|
68
68
|
MantineThemeOverride,
|
|
69
69
|
VariantColorsResolver,
|
|
70
70
|
} from '@mantine/core'
|
|
71
|
-
import {
|
|
72
|
-
|
|
71
|
+
import {
|
|
72
|
+
BP,
|
|
73
|
+
buildPaletteData,
|
|
74
|
+
deriveRadius,
|
|
75
|
+
deriveSpacing,
|
|
76
|
+
RADIUS_STEP,
|
|
77
|
+
SPACE_FIXED,
|
|
78
|
+
} from '../tokens/palette'
|
|
79
|
+
import type { PaletteData, RadiusValues, SpaceValues } from '../tokens/palette'
|
|
80
|
+
import { DEFAULT_DERIVE_CONFIG, isDefaultDeriveConfig, resolveDeriveConfig } from '../tokens/derive'
|
|
81
|
+
import type { DeriveConfig } from '../tokens/derive'
|
|
82
|
+
import { pxRem, VX } from '../tokens'
|
|
83
|
+
import type { BasaltFontsConfig } from '../tokens'
|
|
73
84
|
import controlsClasses from './controls.module.css'
|
|
74
85
|
import floatingClasses from './floating.module.css'
|
|
75
86
|
import navLinkClasses from './nav-link.module.css'
|
|
76
87
|
import segmentedControlClasses from './segmented-control.module.css'
|
|
77
88
|
import timelineClasses from './timeline.module.css'
|
|
78
89
|
|
|
90
|
+
/**
|
|
91
|
+
* The `fonts` option's resolved shape — defined in `basalt-ui/tokens` (`BasaltFontsConfig`,
|
|
92
|
+
* paired with its pure builder `buildFontsCss` there); re-exported here since
|
|
93
|
+
* `CreateBasaltThemeOptions.fonts` below is its primary production entry point. See
|
|
94
|
+
* {@link CreateBasaltThemeOptions.fonts}.
|
|
95
|
+
*/
|
|
96
|
+
export type { BasaltFontsConfig } from '../tokens'
|
|
97
|
+
|
|
98
|
+
// The active resolved SpaceValues off the running theme (as opposed to the static level-0
|
|
99
|
+
// snapshot) — see its own doc comment for why it lives here rather than in `tokens/`.
|
|
100
|
+
export { useBasaltSpacing } from './use-basalt-spacing'
|
|
101
|
+
|
|
102
|
+
// Typed `theme.other.basaltDerive` / `theme.other.basaltFonts` / `theme.other.basaltRadius` /
|
|
103
|
+
// `theme.other.basaltDensity` reads (Mantine's `MantineThemeOther` ships an index signature, so
|
|
104
|
+
// this merge is additive — no widening of the existing `[key: string]: any`). Set by
|
|
105
|
+
// `createBasaltTheme`'s non-default `{ derive }` / `{ fonts }` / `{ radius }` / `{ density }` paths;
|
|
106
|
+
// `BasaltProvider` reads them to decide whether to inject the pre-baked static palette CSS or a
|
|
107
|
+
// re-derived one for the resolved config, and to emit the matching `--basalt-font-*` /
|
|
108
|
+
// `--vx-radius-*` / `--vx-space-*` override declarations.
|
|
109
|
+
declare module '@mantine/core' {
|
|
110
|
+
interface MantineThemeOther {
|
|
111
|
+
basaltDerive?: DeriveConfig
|
|
112
|
+
basaltFonts?: BasaltFontsConfig
|
|
113
|
+
basaltRadius?: RadiusValues
|
|
114
|
+
basaltDensity?: SpaceValues
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// `pxRem` (px → plain rem STRING literal, e.g. `pxRem(6)` → `'0.375rem'`) is imported from
|
|
119
|
+
// `../tokens` — single-sourced there so `tokens/index.ts`'s own rem-emitting vars
|
|
120
|
+
// (`--vx-space-input-height`) and this module's radius/spacing scale steps can never compute the
|
|
121
|
+
// px→rem conversion two different ways. NOT Mantine's own `rem()` helper, which instead emits a
|
|
122
|
+
// `calc(...)` expression bound to `--mantine-scale` — a different value (see the `Input.extend`
|
|
123
|
+
// `vars` override below for where that scaling is reconstructed).
|
|
124
|
+
|
|
79
125
|
// Basalt families are 5 stops dark→light. Expand to a 10-shade Mantine tuple (light→dark).
|
|
80
126
|
function hexToRgb(h: string): [number, number, number] {
|
|
81
127
|
const n = Number.parseInt(h.slice(1), 16)
|
|
@@ -105,12 +151,13 @@ function ramp10(stops: readonly string[]): MantineColorsTuple {
|
|
|
105
151
|
*
|
|
106
152
|
* `ramp10` linearly interpolates a 5-stop family across 10 fractional positions — that can only
|
|
107
153
|
* land EXACTLY on a raw family stop at the two extremes (index 0 / 9), never at an arbitrary
|
|
108
|
-
* middle index. Two indices of the blue family must be EXACT
|
|
109
|
-
*
|
|
154
|
+
* middle index. Two indices of the blue family must be EXACT, GENERATED accent hexes (see
|
|
155
|
+
* `ACCENT` in `tokens/palette.ts` — computed from `tokens/derive.ts`, not hand-picked), so both
|
|
156
|
+
* are pinned after the ramp is built (the rest still reads as one coherent sky-blue scale):
|
|
110
157
|
*
|
|
111
|
-
* • index 6 = `primaryShade` → `ACCENT.accentFill
|
|
158
|
+
* • index 6 = `primaryShade` → `ACCENT.accentFill`. Mantine derives
|
|
112
159
|
* `--mantine-color-blue-filled` from it, i.e. every filled control's surface.
|
|
113
|
-
* • index 4 → `ACCENT.accent.dark
|
|
160
|
+
* • index 4 → `ACCENT.accent.dark`. Mantine HARDCODES the dark-scheme
|
|
114
161
|
* `--mantine-color-{c}-text` to shade 4 (not to `primaryShade`), so this is what keeps the
|
|
115
162
|
* accent LIGHT when it is used as ink on dark — the other half of the ink/surface split.
|
|
116
163
|
*/
|
|
@@ -123,22 +170,39 @@ function pinShades(
|
|
|
123
170
|
return out as unknown as MantineColorsTuple
|
|
124
171
|
}
|
|
125
172
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
173
|
+
/** The shipped, config-independent palette data — `baseTheme` / `cssVariablesResolver` below are
|
|
174
|
+
* built from this once, at module load. */
|
|
175
|
+
const DEFAULT_PALETTE_DATA = buildPaletteData(DEFAULT_DERIVE_CONFIG)
|
|
176
|
+
|
|
177
|
+
/** The shipped, level-0 radius values — `buildTheme`'s default `radius` param. */
|
|
178
|
+
const DEFAULT_RADIUS_VALUES: RadiusValues = deriveRadius(0)
|
|
179
|
+
|
|
180
|
+
/** The shipped, level-0 spacing values — `buildTheme`'s default `spacing` param. */
|
|
181
|
+
const DEFAULT_SPACE_VALUES: SpaceValues = deriveSpacing(0)
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Build the dark Mantine tuple for `data` at 10 fixed indices:
|
|
185
|
+
* text=dark[0], dimmed=dark[2], border=dark[4], hover=dark[5], surface=dark[6], body=dark[7].
|
|
186
|
+
* Generator-derived — `data.INK` / `data.SURFACE`'s own dark stops, for the shipped default config
|
|
187
|
+
* as much as for any other `neutral`/level configuration, so a palette retune (including the
|
|
188
|
+
* default identity) always tracks the generator's current dark output with no separately-pinned
|
|
189
|
+
* literal to drift out of sync. Indices 8-9 (below-body / darkest extreme) stay the structural
|
|
190
|
+
* `BP.darkGray[0]` / near-black constant — they are not part of the generator's surface-stop set.
|
|
191
|
+
*/
|
|
192
|
+
function buildDarkTuple(data: PaletteData): MantineColorsTuple {
|
|
193
|
+
return [
|
|
194
|
+
data.INK.ink.dark,
|
|
195
|
+
data.INK.ink2.dark,
|
|
196
|
+
data.INK.muted.dark,
|
|
197
|
+
data.INK.faint.dark,
|
|
198
|
+
data.SURFACE.border.dark,
|
|
199
|
+
data.SURFACE.panelHover.dark,
|
|
200
|
+
data.SURFACE.panel.dark,
|
|
201
|
+
data.SURFACE.bg.dark,
|
|
202
|
+
BP.darkGray[0],
|
|
203
|
+
'#09090b',
|
|
204
|
+
] as unknown as MantineColorsTuple
|
|
205
|
+
}
|
|
142
206
|
|
|
143
207
|
/**
|
|
144
208
|
* ON-COLOR: the foreground for a filled surface, decided in CSS. THE fix for Mantine's
|
|
@@ -224,7 +288,11 @@ function legibleOn(background: string, theme: MantineTheme): string {
|
|
|
224
288
|
}
|
|
225
289
|
|
|
226
290
|
/** The `--vx-on-*` block for one scheme: contrast-picked against the shade THAT scheme fills with. */
|
|
227
|
-
function onColorVars(
|
|
291
|
+
function onColorVars(
|
|
292
|
+
theme: MantineTheme,
|
|
293
|
+
colorScheme: 'light' | 'dark',
|
|
294
|
+
data: PaletteData,
|
|
295
|
+
): Record<string, string> {
|
|
228
296
|
const shade = getPrimaryShade(theme, colorScheme)
|
|
229
297
|
const vars: Record<string, string> = {}
|
|
230
298
|
for (const [name, tuple] of Object.entries(theme.colors)) {
|
|
@@ -236,7 +304,7 @@ function onColorVars(theme: MantineTheme, colorScheme: 'light' | 'dark'): Record
|
|
|
236
304
|
// chrome with it. Everything else is a generic surface with no declared foreground: measure it.
|
|
237
305
|
vars[`--vx-on-${name}`] =
|
|
238
306
|
name === theme.primaryColor
|
|
239
|
-
? `var(--vx-onAccent, ${ACCENT.onAccent[colorScheme]})`
|
|
307
|
+
? `var(--vx-onAccent, ${data.ACCENT.onAccent[colorScheme]})`
|
|
240
308
|
: legibleOn(filled, theme)
|
|
241
309
|
}
|
|
242
310
|
return vars
|
|
@@ -285,6 +353,27 @@ const basaltVariantColorResolver: VariantColorsResolver = (input) => {
|
|
|
285
353
|
}
|
|
286
354
|
}
|
|
287
355
|
|
|
356
|
+
/** Options for {@link buildTheme} — the radius/spacing dimensions, collapsed into one typed
|
|
357
|
+
* object per the repo's "typed objects as function arguments" rule rather than positional params
|
|
358
|
+
* (a third dimension made positional transposition a real risk). */
|
|
359
|
+
type BuildThemeOptions = {
|
|
360
|
+
/**
|
|
361
|
+
* Defaults to `DEFAULT_RADIUS_VALUES` (`deriveRadius(0)`, the shipped identity) — pass a
|
|
362
|
+
* different `RadiusValues` to rebuild every radius-anchored `defaultProps`/`styles` number AND
|
|
363
|
+
* the `radius` size-scale from a retuned level instead (`createBasaltTheme`'s `{ radius }`
|
|
364
|
+
* option).
|
|
365
|
+
*/
|
|
366
|
+
radius?: RadiusValues
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Defaults to `DEFAULT_SPACE_VALUES` (`deriveSpacing(0)`, the shipped identity) — pass a
|
|
370
|
+
* different `SpaceValues` to rebuild the `spacing` size-scale AND every density-anchored
|
|
371
|
+
* `defaultProps` number (Timeline's `bulletSize`, Progress's `size`) from a retuned level
|
|
372
|
+
* instead (`createBasaltTheme`'s `{ density }` option).
|
|
373
|
+
*/
|
|
374
|
+
spacing?: SpaceValues
|
|
375
|
+
}
|
|
376
|
+
|
|
288
377
|
/**
|
|
289
378
|
* Basalt base theme — Mantine `createTheme` bound to the Basalt zinc palette.
|
|
290
379
|
*
|
|
@@ -296,510 +385,620 @@ const basaltVariantColorResolver: VariantColorsResolver = (input) => {
|
|
|
296
385
|
* `defaultProps` — it covers every input Mantine ships (Autocomplete, MultiSelect, TagsInput,
|
|
297
386
|
* PinInput, …) plus any consumer that passes an explicit `size="xs"`. Enumerating components in
|
|
298
387
|
* `defaultProps` could never do that; the previous attempt missed seven of them.
|
|
388
|
+
*
|
|
389
|
+
* See {@link BuildThemeOptions} for what `radius`/`spacing` default to and rebuild.
|
|
299
390
|
*/
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
fontFamily: 'var(--basalt-font-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
//
|
|
372
|
-
//
|
|
373
|
-
//
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
},
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
title: {
|
|
410
|
-
fontFamily: 'var(--basalt-font-head)',
|
|
411
|
-
fontWeight: 550,
|
|
412
|
-
fontStretch: '88%',
|
|
413
|
-
},
|
|
414
|
-
},
|
|
415
|
-
}),
|
|
416
|
-
// "Ink earns its color" — a nav selection is UI state, not the identity accent on the LABEL.
|
|
417
|
-
// The active item is panel bg + `shadow-card` (forced here at the THEME level via NavLink's
|
|
418
|
-
// `--nl-*` vars, so it holds for every render path — including a consumer's router `<Link>`
|
|
419
|
-
// via `renderNavLink`, which never sees the shell CSS module); the active ICON is
|
|
420
|
-
// accent-colored via `nav-link.module.css` (targets the `[data-position='left']` leftSection,
|
|
421
|
-
// which the flat `vars`/`styles` API can't express conditionally on `[data-active]`).
|
|
422
|
-
NavLink: NavLink.extend({
|
|
423
|
-
vars: () => ({
|
|
424
|
-
root: {
|
|
425
|
-
'--nl-bg': 'var(--vx-surface-panel)',
|
|
426
|
-
'--nl-color': 'var(--vx-ink)',
|
|
427
|
-
'--nl-hover': 'color-mix(in srgb, var(--vx-ink) 6%, transparent)',
|
|
391
|
+
function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): MantineThemeOverride {
|
|
392
|
+
const { radius = DEFAULT_RADIUS_VALUES, spacing = DEFAULT_SPACE_VALUES } = options
|
|
393
|
+
const { ACCENT, FILL } = data
|
|
394
|
+
return createTheme({
|
|
395
|
+
primaryColor: 'blue',
|
|
396
|
+
// ONE shade in both schemes — a filled control is a SURFACE, and the accent surface is the same
|
|
397
|
+
// hex either way (see `ACCENT.accentFill`). The scheme-inverting half of the accent lives in
|
|
398
|
+
// Mantine's dark `--mantine-color-{c}-text`, which is hardcoded to shade 4 = `ACCENT.accent.dark`.
|
|
399
|
+
primaryShade: 6,
|
|
400
|
+
autoContrast: true,
|
|
401
|
+
luminanceThreshold: 0.45,
|
|
402
|
+
// Force the `light` variant to a faint, AA-legible tint in both schemes (see resolver above).
|
|
403
|
+
variantColorResolver: basaltVariantColorResolver,
|
|
404
|
+
white: '#ffffff',
|
|
405
|
+
black: '#18181b',
|
|
406
|
+
// The three-font system (docs/DESIGN-SPEC.md §3): Nunito Sans body / Hubot Sans condensed
|
|
407
|
+
// headings / JetBrains Mono for numerals + micro-labels. The `--basalt-font-*` vars stay the
|
|
408
|
+
// override seam (shipped in styles.css, with system-font fallback chains).
|
|
409
|
+
fontFamily: 'var(--basalt-font-sans, ui-sans-serif, system-ui, sans-serif)',
|
|
410
|
+
fontFamilyMonospace: "var(--basalt-font-mono, ui-monospace, 'SF Mono', Menlo, monospace)",
|
|
411
|
+
headings: {
|
|
412
|
+
fontFamily: 'var(--basalt-font-head, var(--basalt-font-sans, ui-sans-serif, sans-serif))',
|
|
413
|
+
fontWeight: '550',
|
|
414
|
+
},
|
|
415
|
+
// Control radius tier (docs/DESIGN-SPEC.md §4: inputs, search, buttons, segmented track, icon
|
|
416
|
+
// buttons ≥28px sit at ~6px). `radius.md` = 0.375rem = 6px, mirrored by `--vx-radius-ctrl` — every
|
|
417
|
+
// control without its own explicit `radius` prop (Button, ActionIcon, TextInput, NumberInput,
|
|
418
|
+
// PasswordInput, Select, Textarea) falls back to this default. Card/Paper bypass this scale
|
|
419
|
+
// entirely — they resolve straight to `var(--vx-radius-card)` (7px, see the
|
|
420
|
+
// `components.Card`/`Paper` overrides below).
|
|
421
|
+
defaultRadius: 'md',
|
|
422
|
+
// Named weight ladder (v9 fontWeights).
|
|
423
|
+
fontWeights: { regular: '400', medium: '500', semibold: '600', bold: '700' },
|
|
424
|
+
// The OWNED type scale — Mantine's xs…xl re-expressed from the single `VX.text` ladder
|
|
425
|
+
// (`tokens/index.ts`), so `<Text size="sm">` and a `--vx-text-sm` CSS module read the same step.
|
|
426
|
+
// Passed through Mantine's `rem()` (→ `calc(Xrem * var(--mantine-scale))`) rather than raw px, so
|
|
427
|
+
// the component surface honors the user's browser font-size and Mantine's own scale factor —
|
|
428
|
+
// the px numbers in `VX.text` exist only for inline styles and visx SVG, which can't take `var()`.
|
|
429
|
+
// `md` is the body step. Mantine's default ladder (12/14/16/18/20) is now fully replaced.
|
|
430
|
+
fontSizes: {
|
|
431
|
+
xs: rem(VX.text.xs),
|
|
432
|
+
sm: rem(VX.text.sm),
|
|
433
|
+
md: rem(VX.text.md),
|
|
434
|
+
lg: rem(VX.text.lg),
|
|
435
|
+
xl: rem(VX.text.xl),
|
|
436
|
+
},
|
|
437
|
+
// Deliberate, OWNED spacing + radius scales — the single edit point, not inherited Mantine
|
|
438
|
+
// defaults. Denser than Mantine's stock lg/xl for a tighter, data-driven surface. 10 12 16 18 24.
|
|
439
|
+
// Reads `spacing.scale`, NOT `spacing.anchors` — a scale stop tracks density independently of
|
|
440
|
+
// any component anchor even where the level-0 numbers coincide (see `SPACE_SCALE`'s doc in
|
|
441
|
+
// `tokens/palette.ts`).
|
|
442
|
+
spacing: {
|
|
443
|
+
xs: pxRem(spacing.scale.xs),
|
|
444
|
+
sm: pxRem(spacing.scale.sm),
|
|
445
|
+
md: pxRem(spacing.scale.md),
|
|
446
|
+
lg: pxRem(spacing.scale.lg),
|
|
447
|
+
xl: pxRem(spacing.scale.xl),
|
|
448
|
+
},
|
|
449
|
+
// 2 4 6 16 32 — the size scale; `md` = `radius.ctrl` (6px at level 0) is the control-radius
|
|
450
|
+
// default (`defaultRadius: 'md'`, inputs/buttons). Card/Paper/Popover/Modal/Notification read
|
|
451
|
+
// `--vx-radius-*` directly instead (7px cards / 6px controls at level 0), so the larger steps of
|
|
452
|
+
// this scale no longer mirror either anchor — `xs`/`lg`/`xl` are independent `RADIUS_STEP`
|
|
453
|
+
// constants (fixed regardless of the radius knob), `sm` shares `radius.fine` with the Progress
|
|
454
|
+
// bar (see below).
|
|
455
|
+
radius: {
|
|
456
|
+
xs: pxRem(RADIUS_STEP.scaleXs),
|
|
457
|
+
sm: pxRem(radius.fine),
|
|
458
|
+
md: pxRem(radius.ctrl),
|
|
459
|
+
lg: pxRem(RADIUS_STEP.scaleLg),
|
|
460
|
+
xl: pxRem(RADIUS_STEP.scaleXl),
|
|
461
|
+
},
|
|
462
|
+
// Shade 6 (= `primaryShade`) is pinned to the FILL BAND for every family, so the JS ramp and the
|
|
463
|
+
// `--vx-fill-*` tokens hold the SAME hex. That keeps `-filled` / `-text`(light) / `-outline`
|
|
464
|
+
// internally consistent, and lets the on-color be measured straight off the tuple (below).
|
|
465
|
+
colors: {
|
|
466
|
+
dark: buildDarkTuple(data),
|
|
467
|
+
gray: pinShades(ramp10(BP.gray), { 6: FILL.gray }),
|
|
468
|
+
blue: pinShades(ramp10(BP.blue), { 4: ACCENT.accent.dark, 6: ACCENT.accentFill.light }),
|
|
469
|
+
cyan: pinShades(ramp10(BP.cerulean), { 6: FILL.cyan }),
|
|
470
|
+
teal: pinShades(ramp10(BP.turquoise), { 6: FILL.teal }),
|
|
471
|
+
green: pinShades(ramp10(BP.forest), { 6: FILL.green }),
|
|
472
|
+
lime: pinShades(ramp10(BP.lime), { 6: FILL.lime }),
|
|
473
|
+
yellow: pinShades(ramp10(BP.gold), { 6: FILL.yellow }),
|
|
474
|
+
orange: pinShades(ramp10(BP.orange), { 6: FILL.orange }),
|
|
475
|
+
red: pinShades(ramp10(BP.red), { 6: FILL.red }),
|
|
476
|
+
pink: pinShades(ramp10(BP.rose), { 6: FILL.pink }),
|
|
477
|
+
grape: pinShades(ramp10(BP.violet), { 6: FILL.grape }),
|
|
478
|
+
violet: pinShades(ramp10(BP.violet), { 6: FILL.violet }),
|
|
479
|
+
indigo: pinShades(ramp10(BP.indigo), { 6: FILL.indigo }),
|
|
480
|
+
},
|
|
481
|
+
components: {
|
|
482
|
+
// Depth = `shadow-card` (a whisper shadow + a 1px ring baked into the SAME value) — never a
|
|
483
|
+
// separate `border` property (docs/DESIGN-SPEC.md doctrine inversion #1). Cards carry no
|
|
484
|
+
// `withBorder` at all; the ring lives inside `--vx-shadow-card`.
|
|
485
|
+
// ONE card identity, enforced at the theme so NO component can diverge. Every card-like
|
|
486
|
+
// surface — Mantine `Card`, a bare `Paper` used as a card, and the Mantine-free `ChartCard` —
|
|
487
|
+
// resolves to the SAME three tokens:
|
|
488
|
+
// • background → `--vx-surface-panel` (the panel surface, NOT the page body).
|
|
489
|
+
// • depth → `--vx-shadow-card` (whisper shadow + ring, replaces `withBorder`).
|
|
490
|
+
// • radius → `--vx-radius-card` (7px).
|
|
491
|
+
// This is the single source the user's "strict surface across components" demands; the
|
|
492
|
+
// `raw-surface` guard then stops consumers re-overriding any of it inline.
|
|
493
|
+
Card: Card.extend({
|
|
494
|
+
styles: {
|
|
495
|
+
root: {
|
|
496
|
+
backgroundColor: 'var(--vx-surface-panel)',
|
|
497
|
+
boxShadow: 'var(--vx-shadow-card)',
|
|
498
|
+
borderRadius: 'var(--vx-radius-card)',
|
|
499
|
+
},
|
|
428
500
|
},
|
|
429
|
-
children: {},
|
|
430
501
|
}),
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
classNames: { root: navLinkClasses.root },
|
|
439
|
-
styles: {
|
|
440
|
-
root: {
|
|
441
|
-
// Row geometry (docs/DESIGN-SPEC.md §5): 6px 10px padding lands ~29-30px rows. Mantine
|
|
442
|
-
// v9 hardcodes NavLink padding (`8px var(--mantine-spacing-sm)` — there is NO
|
|
443
|
-
// `--nl-padding` var), so the spec padding is forced inline here, where it wins
|
|
444
|
-
// deterministically on every render path.
|
|
445
|
-
padding: '6px 10px',
|
|
446
|
-
// The body step on the ROOT, not just the label: the body element sizes itself from the
|
|
447
|
-
// root's inherited line-height (which, left at the default 1.55, alone pushed rows to
|
|
448
|
-
// ~37px). The tightened 1.35 keeps rows compact as the scale grows.
|
|
449
|
-
fontSize: VX.text.md,
|
|
450
|
-
lineHeight: '1.35',
|
|
451
|
-
// Nav rows sit in the 5-6px radius tier (docs/DESIGN-SPEC.md §4), not square.
|
|
452
|
-
borderRadius: 6,
|
|
502
|
+
Paper: Paper.extend({
|
|
503
|
+
styles: {
|
|
504
|
+
root: {
|
|
505
|
+
backgroundColor: 'var(--vx-surface-panel)',
|
|
506
|
+
boxShadow: 'var(--vx-shadow-card)',
|
|
507
|
+
borderRadius: 'var(--vx-radius-card)',
|
|
508
|
+
},
|
|
453
509
|
},
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
TextInput: TextInput.extend({ defaultProps: { size: 'md' } }),
|
|
471
|
-
NumberInput: NumberInput.extend({ defaultProps: { size: 'md' } }),
|
|
472
|
-
PasswordInput: PasswordInput.extend({ defaultProps: { size: 'md' } }),
|
|
473
|
-
Select: Select.extend({ defaultProps: { size: 'md' } }),
|
|
474
|
-
Textarea: Textarea.extend({ defaultProps: { size: 'md' } }),
|
|
475
|
-
// PillsInput (MultiSelect/TagsInput's outer field) renders `InputBase` internally but under
|
|
476
|
-
// its OWN `__staticSelector: 'PillsInput'`, so it never reads `theme.components.Input` — the
|
|
477
|
-
// field idiom above never reached it. `PillsInput.classes === InputBase.classes`, so the SAME
|
|
478
|
-
// part names apply here; reusing both control classes picks up the exact `[data-variant]` rules
|
|
479
|
-
// in controls.module.css for free, no new CSS needed. Both slots are required — `wrapper` alone
|
|
480
|
-
// would land the vars but leave the field flat, since the depth lives on `input`.
|
|
481
|
-
PillsInput: PillsInput.extend({
|
|
482
|
-
classNames: { wrapper: controlsClasses.inputWrapper, input: controlsClasses.input },
|
|
483
|
-
}),
|
|
484
|
-
// Button / ActionIcon (`default` variant): same `shadow-card` depth as every other control
|
|
485
|
-
// surface (docs/DESIGN-SPEC.md §5: "search trigger … panel + shadow-card", "icon button …
|
|
486
|
-
// panel + shadow-card"; doctrine inversion #1). Background already resolves through the shared
|
|
487
|
-
// `--mantine-color-default` var (→ `--vx-surface-panel`, see cssVariablesResolver below) and
|
|
488
|
-
// the border through `--mantine-color-default-border` (→ transparent, same resolver) — neither
|
|
489
|
-
// component had a `.extend()` block at all before this, which is why they never picked up
|
|
490
|
-
// either. Only the shadow needs adding here, in controls.module.css: Mantine's own
|
|
491
|
-
// `[data-variant='default']` rule never declares a `box-shadow`, so no specificity fight is
|
|
492
|
-
// needed to win one. `filled`/`subtle`/`light` variants are untouched — scoped by attribute
|
|
493
|
-
// selector in the CSS, not here.
|
|
494
|
-
Button: Button.extend({ classNames: { root: controlsClasses.buttonRoot } }),
|
|
495
|
-
ActionIcon: ActionIcon.extend({ classNames: { root: controlsClasses.actionIconRoot } }),
|
|
496
|
-
// CheckboxCard / RadioCard (`withBorder`, true by default): same live regression as Button/
|
|
497
|
-
// ActionIcon before this pass — Mantine ships `border: 1px solid transparent` as the BASE
|
|
498
|
-
// `[data-with-border]` declaration, but its own `:where([data-mantine-color-scheme=…])` block
|
|
499
|
-
// re-colors that to gray-3/dark-4 (pinned to `--vx-surface-border` by the strict-surface lever
|
|
500
|
-
// below), landing a real, flat hairline with no shadow at all — the exact "flat and edgeless"
|
|
501
|
-
// symptom, just via a different mechanism (`[data-with-border]`, not the `default`-variant
|
|
502
|
-
// border var). `.checkboxCardRoot[data-with-border]` / `.radioCardRoot[data-with-border]` are
|
|
503
|
-
// real attribute selectors ((0,2,0)) — Mantine's own rule wraps the same attribute in `:where()`
|
|
504
|
-
// (0 specificity, landing at (0,1,0) total), so no `html[…]` prefix fight is needed here either.
|
|
505
|
-
// Neither component sets a background of its own, so panel bg is added alongside the shadow —
|
|
506
|
-
// the same panel-bg + shadow-card + no-border triad as Card/Paper.
|
|
507
|
-
CheckboxCard: CheckboxCard.extend({
|
|
508
|
-
classNames: { card: controlsClasses.checkboxCardRoot },
|
|
509
|
-
}),
|
|
510
|
-
RadioCard: RadioCard.extend({
|
|
511
|
-
classNames: { card: controlsClasses.radioCardRoot },
|
|
512
|
-
}),
|
|
513
|
-
// Chip: unlike Button/Input, Chip has no literal `variant="default"` — its OWN default (no
|
|
514
|
-
// `variant` prop passed) resolves internally to `variant: 'filled'` (Chip's neutral/unselected
|
|
515
|
-
// look, NOT a "loud" filled color — `light`/`outline` are the other two Chip variants). The
|
|
516
|
-
// unchecked `filled`-variant label already ships a transparent border (`gray-1`/`dark-5` tint,
|
|
517
|
-
// no shadow) — borderless but flat, the same symptom as CheckboxCard/RadioCard above. The class
|
|
518
|
-
// is wired conditionally (function-form `classNames`, same pattern as the `vars` on-color
|
|
519
|
-
// re-points below) so it NEVER reaches a consumer-chosen `light`/`outline` Chip.
|
|
520
|
-
Chip: Chip.extend({
|
|
521
|
-
classNames: (_theme, props) =>
|
|
522
|
-
(props.variant ?? 'filled') === 'filled' ? { label: controlsClasses.chipLabel } : {},
|
|
523
|
-
}),
|
|
524
|
-
// Track = ink-6% tint, radius 7, 2px padding; active segment = panel bg + `shadow-ctrl`,
|
|
525
|
-
// radius 5. `--sc-radius`/`--sc-color` don't reach the root track background (Mantine
|
|
526
|
-
// hardcodes that to a raw gray step), so it's forced via `styles.root` same as Card/Paper.
|
|
527
|
-
// The active-only ink label color + weight can't live in the flat `styles.label` object
|
|
528
|
-
// (applies to every option regardless of state), so it's in segmented-control.module.css
|
|
529
|
-
// instead — same pattern as NavLink's active-icon accent.
|
|
530
|
-
SegmentedControl: SegmentedControl.extend({
|
|
531
|
-
defaultProps: { radius: 7 },
|
|
532
|
-
classNames: { label: segmentedControlClasses.label },
|
|
533
|
-
styles: {
|
|
534
|
-
root: {
|
|
535
|
-
backgroundColor: 'color-mix(in srgb, var(--vx-ink) 6%, transparent)',
|
|
536
|
-
padding: 2,
|
|
537
|
-
},
|
|
538
|
-
indicator: {
|
|
539
|
-
backgroundColor: 'var(--vx-surface-panel)',
|
|
540
|
-
boxShadow: 'var(--vx-shadow-ctrl)',
|
|
541
|
-
borderRadius: 5,
|
|
542
|
-
},
|
|
543
|
-
},
|
|
544
|
-
}),
|
|
545
|
-
// Track = ink-8%; leader/section fill colors are a per-usage `color` prop (left to consumers).
|
|
546
|
-
Progress: Progress.extend({
|
|
547
|
-
defaultProps: { size: 6, radius: 4 },
|
|
548
|
-
styles: {
|
|
549
|
-
root: { backgroundColor: 'color-mix(in srgb, var(--vx-ink) 8%, transparent)' },
|
|
550
|
-
},
|
|
551
|
-
}),
|
|
552
|
-
// Activity-feed idiom: 20-24px bullet, hairline connecting line (not Mantine's heavy default),
|
|
553
|
-
// head-weight title, muted body — zero call-site work for an on-spec Timeline. `bulletSize`/
|
|
554
|
-
// `lineWidth` land through Timeline's OWN `varsResolver` (real component vars, not our `styles`
|
|
555
|
-
// object), so they aren't subject to the custom-property stripping below. The bullet's
|
|
556
|
-
// panel/hairline/accent-active treatment and the line's divider color ARE custom-property
|
|
557
|
-
// declarations / state-selectors — both unreachable from a flat `styles` object (same
|
|
558
|
-
// reasoning as SegmentedControl's active-label rule and NavLink's active-icon rule) — so they
|
|
559
|
-
// live in `timeline.module.css` instead. `TimelineItem` renders through the PARENT Timeline's
|
|
560
|
-
// style context (`ctx.getStyles`), so `item`/`itemBullet`/`itemTitle`/`itemContent` are all
|
|
561
|
-
// themed from this ONE extend — no separate `TimelineItem` override needed.
|
|
562
|
-
Timeline: Timeline.extend({
|
|
563
|
-
defaultProps: { bulletSize: 22, lineWidth: 1 },
|
|
564
|
-
// The active bullet's icon sits on the accent fill — on-color, not a baked white (see above).
|
|
565
|
-
vars: (theme, props) => ({ root: { '--tl-icon-color': onColorFor(theme, props) } }),
|
|
566
|
-
classNames: {
|
|
567
|
-
item: timelineClasses.item,
|
|
568
|
-
itemBullet: timelineClasses.itemBullet,
|
|
569
|
-
},
|
|
570
|
-
styles: {
|
|
571
|
-
itemTitle: {
|
|
572
|
-
fontSize: VX.text.md,
|
|
573
|
-
fontWeight: 600,
|
|
574
|
-
color: 'var(--vx-ink)',
|
|
575
|
-
},
|
|
576
|
-
itemContent: {
|
|
577
|
-
fontSize: VX.text.md,
|
|
578
|
-
color: 'var(--vx-muted)',
|
|
579
|
-
},
|
|
580
|
-
},
|
|
581
|
-
}),
|
|
582
|
-
// ── Floating layer (docs/DESIGN-SPEC.md §5) ─────────────────────────────────────────────
|
|
583
|
-
// ONE idiom for every detached surface: overlay surface + a REAL 1px `--vx-surface-border`
|
|
584
|
-
// border + the overlay elevation shadow. The border must be a real `border` property (never
|
|
585
|
-
// "ring in the shadow" like cards): Mantine's arrow is a rotated square that draws
|
|
586
|
-
// `1px solid var(--popover-border-color)` and inherits the dropdown's background — with
|
|
587
|
-
// `border: 'none'` on the dropdown the arrow rendered as a broken floating diamond edge.
|
|
588
|
-
// (`--popover-border-color` resolves to gray-2/dark-4, both pinned to `--vx-surface-border`
|
|
589
|
-
// by the resolver below, so dropdown and arrow always share the same edge color.)
|
|
590
|
-
|
|
591
|
-
// Tooltip is a standalone floating primitive (not Popover-based) — themed directly. Its arrow
|
|
592
|
-
// ships border-less (`border: 0`), so the same edge is applied inline to keep the ring closed.
|
|
593
|
-
Tooltip: Tooltip.extend({
|
|
594
|
-
defaultProps: { radius: 8 },
|
|
595
|
-
styles: {
|
|
596
|
-
tooltip: {
|
|
597
|
-
backgroundColor: 'var(--vx-surface-overlay)',
|
|
598
|
-
color: 'var(--vx-ink)',
|
|
599
|
-
border: '1px solid var(--vx-surface-border)',
|
|
600
|
-
boxShadow: 'var(--vx-shadow-overlay)',
|
|
510
|
+
}),
|
|
511
|
+
// Mantine's default Badge radius is a full 1000px pill; the spec's delta/status badges sit at
|
|
512
|
+
// radius 6 (docs/DESIGN-SPEC.md §4/§5). Count badges (radius 5) are a distinct, smaller-radius
|
|
513
|
+
// usage left to the call site (`radius={5}` prop) since Badge has no state to key off here.
|
|
514
|
+
Badge: Badge.extend({ defaultProps: { radius: radius.ctrl } }),
|
|
515
|
+
// Alert renders its title in the body font by default; bring it onto the head-font idiom
|
|
516
|
+
// (docs/DESIGN-SPEC.md §5) like every other titled surface. Radius/padding/color tint are
|
|
517
|
+
// already on-system (defaultRadius 'md' control tier + the variant color resolver), so only
|
|
518
|
+
// the title font is overridden.
|
|
519
|
+
Alert: Alert.extend({
|
|
520
|
+
styles: {
|
|
521
|
+
title: {
|
|
522
|
+
fontFamily: 'var(--basalt-font-head)',
|
|
523
|
+
fontWeight: 550,
|
|
524
|
+
fontStretch: '88%',
|
|
525
|
+
},
|
|
601
526
|
},
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
527
|
+
}),
|
|
528
|
+
// "Ink earns its color" — a nav selection is UI state, not the identity accent on the LABEL.
|
|
529
|
+
// The active item is panel bg + `shadow-card` (forced here at the THEME level via NavLink's
|
|
530
|
+
// `--nl-*` vars, so it holds for every render path — including a consumer's router `<Link>`
|
|
531
|
+
// via `renderNavLink`, which never sees the shell CSS module); the active ICON is
|
|
532
|
+
// accent-colored via `nav-link.module.css` (targets the `[data-position='left']` leftSection,
|
|
533
|
+
// which the flat `vars`/`styles` API can't express conditionally on `[data-active]`).
|
|
534
|
+
NavLink: NavLink.extend({
|
|
535
|
+
vars: () => ({
|
|
536
|
+
root: {
|
|
537
|
+
'--nl-bg': 'var(--vx-surface-panel)',
|
|
538
|
+
'--nl-color': 'var(--vx-ink)',
|
|
539
|
+
'--nl-hover': 'color-mix(in srgb, var(--vx-ink) 6%, transparent)',
|
|
540
|
+
},
|
|
541
|
+
children: {},
|
|
542
|
+
}),
|
|
543
|
+
// Dense, rounded nav rows — applied at the THEME level so they survive EVERY render path,
|
|
544
|
+
// including a consumer's router `<Link>` via `renderNavLink`, which never sees the shell CSS
|
|
545
|
+
// module (the module's `.link` only reaches the shell's own fallback `<NavLink>`). Same
|
|
546
|
+
// reasoning as the `--nl-*` fill above: layout is single-sourced here, not in two places.
|
|
547
|
+
// The active-weight/shadow/icon-accent state selectors can't live in `styles` (flat inline
|
|
548
|
+
// props only) — they're in nav-link.module.css, wired via `classNames` so they reach the
|
|
549
|
+
// same every-render-path scope.
|
|
550
|
+
classNames: { root: navLinkClasses.root },
|
|
551
|
+
styles: {
|
|
552
|
+
root: {
|
|
553
|
+
// Row geometry (docs/DESIGN-SPEC.md §5): 6px 10px padding lands ~29-30px rows. Mantine
|
|
554
|
+
// v9 hardcodes NavLink padding (`8px var(--mantine-spacing-sm)` — there is NO
|
|
555
|
+
// `--nl-padding` var), so the spec padding is forced inline here, where it wins
|
|
556
|
+
// deterministically on every render path.
|
|
557
|
+
padding: 'var(--vx-space-row-inset-y) var(--vx-space-row-inset-x)',
|
|
558
|
+
// The body step on the ROOT, not just the label: the body element sizes itself from the
|
|
559
|
+
// root's inherited line-height (which, left at the default 1.55, alone pushed rows to
|
|
560
|
+
// ~37px). The tightened 1.35 keeps rows compact as the scale grows. Reads
|
|
561
|
+
// `--vx-space-row-line-height` (density-tracking, ADDITIVE law — see `deriveSpacing`'s
|
|
562
|
+
// doc in `tokens/palette.ts` for why this one differs from the padding's multiplier).
|
|
563
|
+
fontSize: VX.text.md,
|
|
564
|
+
lineHeight: 'var(--vx-space-row-line-height)',
|
|
565
|
+
// Nav rows sit in the 5-6px radius tier (docs/DESIGN-SPEC.md §4), not square.
|
|
566
|
+
borderRadius: 'var(--vx-radius-ctrl)',
|
|
567
|
+
},
|
|
568
|
+
// Mantine pins the label at `font-size-sm` explicitly, so the root value alone
|
|
569
|
+
// doesn't reach it.
|
|
570
|
+
label: { fontSize: VX.text.md, lineHeight: 'var(--vx-space-row-line-height)' },
|
|
614
571
|
},
|
|
615
|
-
},
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
572
|
+
}),
|
|
573
|
+
// Field idiom (docs/DESIGN-SPEC.md §5): field surface + `shadow-card` depth + faint placeholder,
|
|
574
|
+
// accent border + subtle accent ring on focus — see controls.module.css. The two slots carry
|
|
575
|
+
// different halves of it: the `wrapper` is where Mantine declares the `--input-*` vars, the
|
|
576
|
+
// `input` is the box that actually paints the surface (bg + radius) and therefore the only
|
|
577
|
+
// legal home for the shadow's ring. Theming the base `Input` covers
|
|
578
|
+
// TextInput/NumberInput/PasswordInput/Select/Textarea, which all render it internally (only
|
|
579
|
+
// `size` needs per-component defaults, since each resolves its own).
|
|
580
|
+
Input: Input.extend({
|
|
581
|
+
defaultProps: { size: 'md' },
|
|
582
|
+
// Density coupling: Input's OWN `varsResolver` sets `--input-height` to
|
|
583
|
+
// `getSize(props.size, 'input-height')` (`@mantine/core/esm/components/Input/Input.mjs`),
|
|
584
|
+
// which resolves to Mantine's global, non-retunable
|
|
585
|
+
// `--input-height-md: calc(2.625rem * var(--mantine-scale))` — IDENTICAL in both
|
|
586
|
+
// `styles.css` and the `styles.layer.css` variant Basalt consumers actually load (verified
|
|
587
|
+
// in the installed package, not assumed). It is rem-relative to the root font size AND
|
|
588
|
+
// scale-aware, not a flat px — so the override must reconstruct BOTH halves, not just the
|
|
589
|
+
// number: `--vx-space-input-height` (`tokens/index.ts`) already carries the rem half (via
|
|
590
|
+
// `pxRem`, the same conversion the `spacing`/`radius` scales use), and the
|
|
591
|
+
// `calc(... * var(--mantine-scale))` wrapper here supplies the scale half — the tokens
|
|
592
|
+
// layer stays Mantine-free, so it cannot reference `--mantine-scale` itself; this
|
|
593
|
+
// Mantine-coupled call site is where that coupling is legitimate. Flattening either half into a bare px value
|
|
594
|
+
// would desync input height from a user's root-font-size accessibility setting and from
|
|
595
|
+
// Mantine's global `--mantine-scale` knob — a real regression, not a cosmetic one. Theme
|
|
596
|
+
// `vars` here merges AFTER a component's own `varsResolver` (Mantine `useStyles`'s
|
|
597
|
+
// `mergeVars`, confirmed in `core/styles-api/use-styles/use-styles.mjs`), so re-pointing
|
|
598
|
+
// `--input-height` here wins on every render path — same established pattern as NavLink's
|
|
599
|
+
// `--nl-*` fill / Checkbox's `--checkbox-icon-color` above. Scoped to `size === 'md'` (the
|
|
600
|
+
// framework's own default, set by `defaultProps` above): a caller that explicitly requests a
|
|
601
|
+
// different size (e.g. `size="xs"`, see the iOS-floor note above) keeps Mantine's own static
|
|
602
|
+
// height for that size — `undefined` here means "leave Mantine's value alone" (`mergeVars`
|
|
603
|
+
// strips it before merging).
|
|
604
|
+
vars: (_theme, props) => ({
|
|
605
|
+
wrapper: {
|
|
606
|
+
'--input-height':
|
|
607
|
+
props.size === 'md'
|
|
608
|
+
? 'calc(var(--vx-space-input-height) * var(--mantine-scale))'
|
|
609
|
+
: undefined,
|
|
610
|
+
},
|
|
611
|
+
}),
|
|
612
|
+
classNames: { wrapper: controlsClasses.inputWrapper, input: controlsClasses.input },
|
|
613
|
+
}),
|
|
614
|
+
TextInput: TextInput.extend({ defaultProps: { size: 'md' } }),
|
|
615
|
+
NumberInput: NumberInput.extend({ defaultProps: { size: 'md' } }),
|
|
616
|
+
PasswordInput: PasswordInput.extend({ defaultProps: { size: 'md' } }),
|
|
617
|
+
Select: Select.extend({ defaultProps: { size: 'md' } }),
|
|
618
|
+
Textarea: Textarea.extend({ defaultProps: { size: 'md' } }),
|
|
619
|
+
// PillsInput (MultiSelect/TagsInput's outer field) renders `InputBase` internally but under
|
|
620
|
+
// its OWN `__staticSelector: 'PillsInput'`, so it never reads `theme.components.Input` — the
|
|
621
|
+
// field idiom above never reached it. `PillsInput.classes === InputBase.classes`, so the SAME
|
|
622
|
+
// part names apply here; reusing both control classes picks up the exact `[data-variant]` rules
|
|
623
|
+
// in controls.module.css for free, no new CSS needed. Both slots are required — `wrapper` alone
|
|
624
|
+
// would land the vars but leave the field flat, since the depth lives on `input`.
|
|
625
|
+
PillsInput: PillsInput.extend({
|
|
626
|
+
classNames: { wrapper: controlsClasses.inputWrapper, input: controlsClasses.input },
|
|
627
|
+
}),
|
|
628
|
+
// Button / ActionIcon (`default` variant): same `shadow-card` depth as every other control
|
|
629
|
+
// surface (docs/DESIGN-SPEC.md §5: "search trigger … panel + shadow-card", "icon button …
|
|
630
|
+
// panel + shadow-card"; doctrine inversion #1). Background already resolves through the shared
|
|
631
|
+
// `--mantine-color-default` var (→ `--vx-surface-panel`, see cssVariablesResolver below) and
|
|
632
|
+
// the border through `--mantine-color-default-border` (→ transparent, same resolver) — neither
|
|
633
|
+
// component had a `.extend()` block at all before this, which is why they never picked up
|
|
634
|
+
// either. Only the shadow needs adding here, in controls.module.css: Mantine's own
|
|
635
|
+
// `[data-variant='default']` rule never declares a `box-shadow`, so no specificity fight is
|
|
636
|
+
// needed to win one. `filled`/`subtle`/`light` variants are untouched — scoped by attribute
|
|
637
|
+
// selector in the CSS, not here.
|
|
638
|
+
//
|
|
639
|
+
// Density coupling: mirrors Input's `--input-height` override above — Mantine's OWN
|
|
640
|
+
// `--button-height-md`/`--ai-size` (via `--ai-size-md`) are global, non-retunable statics
|
|
641
|
+
// (`getSize(size, 'button-height'/'ai-size')`, `@mantine/core/esm/components/{Button,
|
|
642
|
+
// ActionIcon}/{Button,ActionIcon}.mjs`), so a `size="md"` Button/ActionIcon placed beside a
|
|
643
|
+
// `size="md"` Input (the framework's own default, set by `defaultProps` above) only matched the
|
|
644
|
+
// Input's height at density level 0 — every other level left the two heights diverging by as
|
|
645
|
+
// much as 13px. `--vx-space-control-height` (`tokens/index.ts`) is single-sourced from the
|
|
646
|
+
// SAME `SPACE_ANCHORS_BASE.controlHeight` anchor `--vx-space-input-height` reads (see that
|
|
647
|
+
// anchor's doc in `tokens/palette.ts`), so the two can never drift. Scoped to `size === 'md'`,
|
|
648
|
+
// same rationale as Input's override: `undefined` leaves an explicitly different size (e.g.
|
|
649
|
+
// `size="xs"`) on Mantine's own static height.
|
|
650
|
+
Button: Button.extend({
|
|
651
|
+
classNames: { root: controlsClasses.buttonRoot },
|
|
652
|
+
vars: (_theme, props) => ({
|
|
653
|
+
root: {
|
|
654
|
+
'--button-height':
|
|
655
|
+
props.size === 'md'
|
|
656
|
+
? 'calc(var(--vx-space-control-height) * var(--mantine-scale))'
|
|
657
|
+
: undefined,
|
|
658
|
+
},
|
|
659
|
+
}),
|
|
660
|
+
}),
|
|
661
|
+
ActionIcon: ActionIcon.extend({
|
|
662
|
+
classNames: { root: controlsClasses.actionIconRoot },
|
|
663
|
+
vars: (_theme, props) => ({
|
|
664
|
+
root: {
|
|
665
|
+
'--ai-size':
|
|
666
|
+
props.size === 'md'
|
|
667
|
+
? 'calc(var(--vx-space-control-height) * var(--mantine-scale))'
|
|
668
|
+
: undefined,
|
|
669
|
+
},
|
|
670
|
+
}),
|
|
671
|
+
}),
|
|
672
|
+
// CheckboxCard / RadioCard (`withBorder`, true by default): same live regression as Button/
|
|
673
|
+
// ActionIcon before this pass — Mantine ships `border: 1px solid transparent` as the BASE
|
|
674
|
+
// `[data-with-border]` declaration, but its own `:where([data-mantine-color-scheme=…])` block
|
|
675
|
+
// re-colors that to gray-3/dark-4 (pinned to `--vx-surface-border` by the strict-surface lever
|
|
676
|
+
// below), landing a real, flat hairline with no shadow at all — the exact "flat and edgeless"
|
|
677
|
+
// symptom, just via a different mechanism (`[data-with-border]`, not the `default`-variant
|
|
678
|
+
// border var). `.checkboxCardRoot[data-with-border]` / `.radioCardRoot[data-with-border]` are
|
|
679
|
+
// real attribute selectors ((0,2,0)) — Mantine's own rule wraps the same attribute in `:where()`
|
|
680
|
+
// (0 specificity, landing at (0,1,0) total), so no `html[…]` prefix fight is needed here either.
|
|
681
|
+
// Neither component sets a background of its own, so panel bg is added alongside the shadow —
|
|
682
|
+
// the same panel-bg + shadow-card + no-border triad as Card/Paper.
|
|
683
|
+
CheckboxCard: CheckboxCard.extend({
|
|
684
|
+
classNames: { card: controlsClasses.checkboxCardRoot },
|
|
685
|
+
}),
|
|
686
|
+
RadioCard: RadioCard.extend({
|
|
687
|
+
classNames: { card: controlsClasses.radioCardRoot },
|
|
688
|
+
}),
|
|
689
|
+
// Chip: unlike Button/Input, Chip has no literal `variant="default"` — its OWN default (no
|
|
690
|
+
// `variant` prop passed) resolves internally to `variant: 'filled'` (Chip's neutral/unselected
|
|
691
|
+
// look, NOT a "loud" filled color — `light`/`outline` are the other two Chip variants). The
|
|
692
|
+
// unchecked `filled`-variant label already ships a transparent border (`gray-1`/`dark-5` tint,
|
|
693
|
+
// no shadow) — borderless but flat, the same symptom as CheckboxCard/RadioCard above. The class
|
|
694
|
+
// is wired conditionally (function-form `classNames`, same pattern as the `vars` on-color
|
|
695
|
+
// re-points below) so it NEVER reaches a consumer-chosen `light`/`outline` Chip.
|
|
696
|
+
Chip: Chip.extend({
|
|
697
|
+
classNames: (_theme, props) =>
|
|
698
|
+
(props.variant ?? 'filled') === 'filled' ? { label: controlsClasses.chipLabel } : {},
|
|
699
|
+
}),
|
|
700
|
+
// Track = ink-6% tint, radius 7, 2px padding; active segment = panel bg + `shadow-ctrl`,
|
|
701
|
+
// radius 5. `--sc-radius`/`--sc-color` don't reach the root track background (Mantine
|
|
702
|
+
// hardcodes that to a raw gray step), so it's forced via `styles.root` same as Card/Paper.
|
|
703
|
+
// The active-only ink label color + weight can't live in the flat `styles.label` object
|
|
704
|
+
// (applies to every option regardless of state), so it's in segmented-control.module.css
|
|
705
|
+
// instead — same pattern as NavLink's active-icon accent.
|
|
706
|
+
//
|
|
707
|
+
// The track's padding is `SPACE_FIXED.segmentedTrackInset`, a plain literal — NOT a
|
|
708
|
+
// `--vx-space-*` var — because it is density-EXEMPT: it is load-bearing for the nested-corner
|
|
709
|
+
// law (`RADIUS.card === RADIUS_STEP.tight + segmentedTrackInset`, see that constant's doc in
|
|
710
|
+
// `tokens/palette.ts`), and `radius.card`/`RADIUS_STEP.tight` two lines below already track the
|
|
711
|
+
// RADIUS knob together, so the inset between them must stay fixed at exactly 2 regardless of
|
|
712
|
+
// density.
|
|
713
|
+
SegmentedControl: SegmentedControl.extend({
|
|
714
|
+
defaultProps: { radius: radius.card },
|
|
715
|
+
classNames: { label: segmentedControlClasses.label },
|
|
716
|
+
styles: {
|
|
717
|
+
root: {
|
|
718
|
+
backgroundColor: 'color-mix(in srgb, var(--vx-ink) 6%, transparent)',
|
|
719
|
+
padding: `${SPACE_FIXED.segmentedTrackInset}px`,
|
|
720
|
+
},
|
|
721
|
+
indicator: {
|
|
722
|
+
backgroundColor: 'var(--vx-surface-panel)',
|
|
723
|
+
boxShadow: 'var(--vx-shadow-ctrl)',
|
|
724
|
+
borderRadius: 'var(--vx-radius-tight)',
|
|
725
|
+
},
|
|
628
726
|
},
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
727
|
+
}),
|
|
728
|
+
// Track = ink-8%; leader/section fill colors are a per-usage `color` prop (left to consumers).
|
|
729
|
+
Progress: Progress.extend({
|
|
730
|
+
// `size` is a NUMBER, not a `var()` string — same rem()-comma-trap reasoning as Timeline's
|
|
731
|
+
// `bulletSize`/`lineWidth` below, so it reads the resolved `spacing.step.progressBarSize`
|
|
732
|
+
// (density-tracking) rather than a hand-typed literal.
|
|
733
|
+
defaultProps: { size: spacing.step.progressBarSize, radius: radius.fine },
|
|
734
|
+
styles: {
|
|
735
|
+
root: { backgroundColor: 'color-mix(in srgb, var(--vx-ink) 8%, transparent)' },
|
|
637
736
|
},
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
styles
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
737
|
+
}),
|
|
738
|
+
// Activity-feed idiom: 20-24px bullet, hairline connecting line (not Mantine's heavy default),
|
|
739
|
+
// head-weight title, muted body — zero call-site work for an on-spec Timeline. `bulletSize`/
|
|
740
|
+
// `lineWidth` land through Timeline's OWN `varsResolver` (real component vars, not our `styles`
|
|
741
|
+
// object), so they aren't subject to the custom-property stripping below. The bullet's
|
|
742
|
+
// panel/hairline/accent-active treatment and the line's divider color ARE custom-property
|
|
743
|
+
// declarations / state-selectors — both unreachable from a flat `styles` object (same
|
|
744
|
+
// reasoning as SegmentedControl's active-label rule and NavLink's active-icon rule) — so they
|
|
745
|
+
// live in `timeline.module.css` instead. `TimelineItem` renders through the PARENT Timeline's
|
|
746
|
+
// style context (`ctx.getStyles`), so `item`/`itemBullet`/`itemTitle`/`itemContent` are all
|
|
747
|
+
// themed from this ONE extend — no separate `TimelineItem` override needed.
|
|
748
|
+
Timeline: Timeline.extend({
|
|
749
|
+
// NUMBERS, not `var()` strings: `bulletSize`/`lineWidth` land through Timeline's own
|
|
750
|
+
// `rem()` conversion (`@mantine/core/esm/core/utils/units-converters/rem.mjs` splits on `,`
|
|
751
|
+
// and ` ` before checking numerics), which passes a bare `var(--x)` through intact but
|
|
752
|
+
// silently mangles a `var(--x, <fallback>)` into garbage CSS — never add a fallback here.
|
|
753
|
+
defaultProps: { bulletSize: spacing.step.timelineBullet, lineWidth: SPACE_FIXED.hairline },
|
|
754
|
+
// The active bullet's icon sits on the accent fill — on-color, not a baked white (see above).
|
|
755
|
+
vars: (theme, props) => ({ root: { '--tl-icon-color': onColorFor(theme, props) } }),
|
|
756
|
+
classNames: {
|
|
757
|
+
item: timelineClasses.item,
|
|
758
|
+
itemBullet: timelineClasses.itemBullet,
|
|
649
759
|
},
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
backgroundColor: 'var(--vx-surface-overlay)',
|
|
661
|
-
boxShadow: 'var(--vx-shadow-overlay)',
|
|
760
|
+
styles: {
|
|
761
|
+
itemTitle: {
|
|
762
|
+
fontSize: VX.text.md,
|
|
763
|
+
fontWeight: 600,
|
|
764
|
+
color: 'var(--vx-ink)',
|
|
765
|
+
},
|
|
766
|
+
itemContent: {
|
|
767
|
+
fontSize: VX.text.md,
|
|
768
|
+
color: 'var(--vx-muted)',
|
|
769
|
+
},
|
|
662
770
|
},
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
771
|
+
}),
|
|
772
|
+
// ── Floating layer (docs/DESIGN-SPEC.md §5) ─────────────────────────────────────────────
|
|
773
|
+
// ONE idiom for every detached surface: overlay surface + a REAL 1px `--vx-surface-border`
|
|
774
|
+
// border + the overlay elevation shadow. The border must be a real `border` property (never
|
|
775
|
+
// "ring in the shadow" like cards): Mantine's arrow is a rotated square that draws
|
|
776
|
+
// `1px solid var(--popover-border-color)` and inherits the dropdown's background — with
|
|
777
|
+
// `border: 'none'` on the dropdown the arrow rendered as a broken floating diamond edge.
|
|
778
|
+
// (`--popover-border-color` resolves to gray-2/dark-4, both pinned to `--vx-surface-border`
|
|
779
|
+
// by the resolver below, so dropdown and arrow always share the same edge color.)
|
|
780
|
+
|
|
781
|
+
// Tooltip is a standalone floating primitive (not Popover-based) — themed directly. Its arrow
|
|
782
|
+
// ships border-less (`border: 0`), so the same edge is applied inline to keep the ring closed.
|
|
783
|
+
Tooltip: Tooltip.extend({
|
|
784
|
+
defaultProps: { radius: radius.floating },
|
|
785
|
+
styles: {
|
|
786
|
+
tooltip: {
|
|
787
|
+
backgroundColor: 'var(--vx-surface-overlay)',
|
|
788
|
+
color: 'var(--vx-ink)',
|
|
789
|
+
border: '1px solid var(--vx-surface-border)',
|
|
790
|
+
boxShadow: 'var(--vx-shadow-overlay)',
|
|
791
|
+
},
|
|
792
|
+
arrow: { border: '1px solid var(--vx-surface-border)' },
|
|
668
793
|
},
|
|
669
|
-
},
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
794
|
+
}),
|
|
795
|
+
// Popover is the shared floating primitive underneath Menu (Menu renders `<Popover>`
|
|
796
|
+
// internally with no `radius`/`shadow` of its own), so theming it here covers both.
|
|
797
|
+
Popover: Popover.extend({
|
|
798
|
+
defaultProps: { radius: radius.floating },
|
|
799
|
+
styles: {
|
|
800
|
+
dropdown: {
|
|
801
|
+
backgroundColor: 'var(--vx-surface-overlay)',
|
|
802
|
+
border: '1px solid var(--vx-surface-border)',
|
|
803
|
+
boxShadow: 'var(--vx-shadow-overlay)',
|
|
804
|
+
},
|
|
677
805
|
},
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
806
|
+
}),
|
|
807
|
+
// Menu rows: 13px, radius 6, ghost ink-6% hover (floating.module.css — custom properties are
|
|
808
|
+
// stripped from `styles` objects, and Menu's internal Popover does NOT consume
|
|
809
|
+
// `components.Popover.styles`, so the dropdown surface is repeated here). Menu.Label = the
|
|
810
|
+
// mono micro-label idiom; dividers use the layout-divider token.
|
|
811
|
+
Menu: Menu.extend({
|
|
812
|
+
classNames: { item: floatingClasses.menuItem },
|
|
813
|
+
styles: {
|
|
814
|
+
dropdown: {
|
|
815
|
+
backgroundColor: 'var(--vx-surface-overlay)',
|
|
816
|
+
border: '1px solid var(--vx-surface-border)',
|
|
817
|
+
boxShadow: 'var(--vx-shadow-overlay)',
|
|
818
|
+
},
|
|
819
|
+
item: {
|
|
820
|
+
fontSize: VX.text.md,
|
|
821
|
+
borderRadius: 'var(--vx-radius-ctrl)',
|
|
822
|
+
padding: 'var(--vx-space-row-inset-y) var(--vx-space-row-inset-x)',
|
|
823
|
+
},
|
|
824
|
+
label: {
|
|
825
|
+
fontFamily: 'var(--basalt-font-mono)',
|
|
826
|
+
fontSize: VX.text.micro,
|
|
827
|
+
fontWeight: 500,
|
|
828
|
+
letterSpacing: '0.06em',
|
|
829
|
+
textTransform: 'uppercase',
|
|
830
|
+
color: 'var(--vx-faint)',
|
|
831
|
+
},
|
|
832
|
+
divider: { borderColor: 'var(--vx-divider)' },
|
|
683
833
|
},
|
|
684
|
-
},
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
border: 'none',
|
|
695
|
-
color: 'var(--vx-ink2)',
|
|
696
|
-
borderRadius: 5,
|
|
834
|
+
}),
|
|
835
|
+
// Combobox is the floating primitive underneath Select/Autocomplete/MultiSelect — like Menu,
|
|
836
|
+
// it doesn't consume `components.Popover.styles`, so the overlay dropdown idiom is repeated.
|
|
837
|
+
Combobox: Combobox.extend({
|
|
838
|
+
styles: {
|
|
839
|
+
dropdown: {
|
|
840
|
+
backgroundColor: 'var(--vx-surface-overlay)',
|
|
841
|
+
border: '1px solid var(--vx-surface-border)',
|
|
842
|
+
boxShadow: 'var(--vx-shadow-overlay)',
|
|
843
|
+
},
|
|
697
844
|
},
|
|
698
|
-
},
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
845
|
+
}),
|
|
846
|
+
// Modal/Drawer: overlay surface + overlay shadow on the content. The header goes transparent —
|
|
847
|
+
// Mantine paints it `--mantine-color-body`, which read as a grey band over the overlay
|
|
848
|
+
// surface. Title = head font; close button = the ghost idiom (floating.module.css).
|
|
849
|
+
Modal: Modal.extend({
|
|
850
|
+
defaultProps: { radius: radius.floating },
|
|
851
|
+
classNames: { close: floatingClasses.closeButton },
|
|
852
|
+
styles: {
|
|
853
|
+
content: {
|
|
854
|
+
backgroundColor: 'var(--vx-surface-overlay)',
|
|
855
|
+
boxShadow: 'var(--vx-shadow-overlay)',
|
|
856
|
+
},
|
|
857
|
+
header: { backgroundColor: 'transparent' },
|
|
858
|
+
title: {
|
|
859
|
+
fontFamily: 'var(--basalt-font-head)',
|
|
860
|
+
fontWeight: 550,
|
|
861
|
+
fontStretch: '88%',
|
|
862
|
+
},
|
|
705
863
|
},
|
|
706
|
-
},
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
textTransform: 'uppercase',
|
|
721
|
-
color: 'var(--vx-faint)',
|
|
864
|
+
}),
|
|
865
|
+
Drawer: Drawer.extend({
|
|
866
|
+
classNames: { close: floatingClasses.closeButton },
|
|
867
|
+
styles: {
|
|
868
|
+
content: {
|
|
869
|
+
backgroundColor: 'var(--vx-surface-overlay)',
|
|
870
|
+
boxShadow: 'var(--vx-shadow-overlay)',
|
|
871
|
+
},
|
|
872
|
+
header: { backgroundColor: 'transparent' },
|
|
873
|
+
title: {
|
|
874
|
+
fontFamily: 'var(--basalt-font-head)',
|
|
875
|
+
fontWeight: 550,
|
|
876
|
+
fontStretch: '88%',
|
|
877
|
+
},
|
|
722
878
|
},
|
|
723
|
-
},
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
// `--tabs-color` / `--tabs-radius`, yet Tabs' OWN varsResolver writes `--tabs-text-color` —
|
|
737
|
-
// an upstream type gap, so the var it actually paints the active tab with is otherwise
|
|
738
|
-
// unreachable from the theme.
|
|
739
|
-
vars: (theme, props) =>
|
|
740
|
-
({ root: { '--tabs-text-color': onColorFor(theme, props) } }) as unknown as {
|
|
741
|
-
root: Record<'--tabs-color' | '--tabs-radius', string | undefined>
|
|
879
|
+
}),
|
|
880
|
+
// Kbd/Code share the ink-tint idiom (docs/DESIGN-SPEC.md §2: "segmented-control track /
|
|
881
|
+
// count-badge bg: ink 6–8%") — mono, ink-7% bg, radius 5.
|
|
882
|
+
// Flat mono chip (mock's ⌘K badge) — Mantine's default Kbd draws a 3px "keyboard key" bottom
|
|
883
|
+
// border that reads as a heavy off-system rule, so the border goes entirely.
|
|
884
|
+
Kbd: Kbd.extend({
|
|
885
|
+
styles: {
|
|
886
|
+
root: {
|
|
887
|
+
backgroundColor: 'color-mix(in srgb, var(--vx-ink) 7%, transparent)',
|
|
888
|
+
border: 'none',
|
|
889
|
+
color: 'var(--vx-ink2)',
|
|
890
|
+
borderRadius: 'var(--vx-radius-tight)',
|
|
891
|
+
},
|
|
742
892
|
},
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
// Checkbox/Radio paints a white checkmark on the light accent fill — invisible.
|
|
751
|
-
Checkbox: Checkbox.extend({
|
|
752
|
-
vars: (theme, props) => ({
|
|
753
|
-
root: {
|
|
754
|
-
// `iconColor` is an explicit call-site override, and `outline` paints the mark in the
|
|
755
|
-
// color itself on a transparent box — neither is an on-color surface.
|
|
756
|
-
'--checkbox-icon-color':
|
|
757
|
-
props.iconColor || props.variant === 'outline' ? undefined : onColorFor(theme, props),
|
|
893
|
+
}),
|
|
894
|
+
Code: Code.extend({
|
|
895
|
+
styles: {
|
|
896
|
+
root: {
|
|
897
|
+
backgroundColor: 'color-mix(in srgb, var(--vx-ink) 7%, transparent)',
|
|
898
|
+
borderRadius: 'var(--vx-radius-tight)',
|
|
899
|
+
},
|
|
758
900
|
},
|
|
759
901
|
}),
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
902
|
+
// Header cells become a micro-label (mono, uppercase, faint) — numeral/tabular styling for
|
|
903
|
+
// body cells is a per-table call-site concern, left to consumers. `--table-border-color`
|
|
904
|
+
// drives row separators AND the opt-in `withTableBorder` outer border — both drop to the
|
|
905
|
+
// hairline (Mantine's default reads gray-3/dark-4 = the STRONG line, too heavy in a card).
|
|
906
|
+
Table: Table.extend({
|
|
907
|
+
classNames: { table: controlsClasses.tableRoot },
|
|
908
|
+
styles: {
|
|
909
|
+
th: {
|
|
910
|
+
fontFamily: 'var(--basalt-font-mono)',
|
|
911
|
+
fontSize: VX.text.micro,
|
|
912
|
+
fontWeight: 500,
|
|
913
|
+
letterSpacing: '0.06em',
|
|
914
|
+
textTransform: 'uppercase',
|
|
915
|
+
color: 'var(--vx-faint)',
|
|
916
|
+
},
|
|
766
917
|
},
|
|
767
918
|
}),
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
919
|
+
// The v9 thumb indicator is a center dot painted in the TRACK color — over the remapped
|
|
920
|
+
// neutral track it read as an artifact, so it's disabled: clean track, plain thumb, accent
|
|
921
|
+
// fill when checked (`--switch-color` defaults to the primary filled shade = the accent).
|
|
922
|
+
Switch: Switch.extend({ defaultProps: { withThumbIndicator: false } }),
|
|
923
|
+
// The tab-list bottom rule (and the inactive-tab hover underline) is a layout separator, not
|
|
924
|
+
// control chrome — it reads the divider token instead of the heavy gray-3/dark-4 line
|
|
925
|
+
// (controls.module.css; custom properties are stripped from `styles` objects). The active tab
|
|
926
|
+
// underline keeps `--tabs-color` (accent) untouched.
|
|
927
|
+
Tabs: Tabs.extend({
|
|
928
|
+
classNames: { root: controlsClasses.tabsRoot },
|
|
929
|
+
// The on-color re-point (see below). Cast: Mantine's `TabsCssVariables` type declares only
|
|
930
|
+
// `--tabs-color` / `--tabs-radius`, yet Tabs' OWN varsResolver writes `--tabs-text-color` —
|
|
931
|
+
// an upstream type gap, so the var it actually paints the active tab with is otherwise
|
|
932
|
+
// unreachable from the theme.
|
|
933
|
+
vars: (theme, props) =>
|
|
934
|
+
({ root: { '--tabs-text-color': onColorFor(theme, props) } }) as unknown as {
|
|
935
|
+
root: Record<'--tabs-color' | '--tabs-radius', string | undefined>
|
|
936
|
+
},
|
|
772
937
|
}),
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
},
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
938
|
+
|
|
939
|
+
// ── ON-COLOR re-points (see the ON-COLOR doctrine above) ────────────────────────────────
|
|
940
|
+
// These components never reach `variantColorResolver` — each calls Mantine's `getContrastColor`
|
|
941
|
+
// straight from its own `varsResolver`, so each bakes the same scheme-blind white into its ONE
|
|
942
|
+
// foreground var. Theme `vars` merge AFTER a component's own `varsResolver` (Mantine
|
|
943
|
+
// `useStyles`), so re-pointing that var here wins on every render path. Without this, a dark-mode
|
|
944
|
+
// Checkbox/Radio paints a white checkmark on the light accent fill — invisible.
|
|
945
|
+
Checkbox: Checkbox.extend({
|
|
946
|
+
vars: (theme, props) => ({
|
|
947
|
+
root: {
|
|
948
|
+
// `iconColor` is an explicit call-site override, and `outline` paints the mark in the
|
|
949
|
+
// color itself on a transparent box — neither is an on-color surface.
|
|
950
|
+
'--checkbox-icon-color':
|
|
951
|
+
props.iconColor || props.variant === 'outline' ? undefined : onColorFor(theme, props),
|
|
952
|
+
},
|
|
953
|
+
}),
|
|
954
|
+
}),
|
|
955
|
+
Radio: Radio.extend({
|
|
956
|
+
vars: (theme, props) => ({
|
|
957
|
+
root: {
|
|
958
|
+
'--radio-icon-color':
|
|
959
|
+
props.iconColor || props.variant === 'outline' ? undefined : onColorFor(theme, props),
|
|
960
|
+
},
|
|
961
|
+
}),
|
|
962
|
+
}),
|
|
963
|
+
Pagination: Pagination.extend({
|
|
964
|
+
vars: (theme, props) => ({
|
|
965
|
+
root: { '--pagination-active-color': onColorFor(theme, props) },
|
|
966
|
+
}),
|
|
967
|
+
}),
|
|
968
|
+
Stepper: Stepper.extend({
|
|
969
|
+
vars: (theme, props) => ({ root: { '--stepper-icon-color': onColorFor(theme, props) } }),
|
|
970
|
+
}),
|
|
971
|
+
Indicator: Indicator.extend({
|
|
972
|
+
vars: (theme, props) => ({ root: { '--indicator-text-color': onColorFor(theme, props) } }),
|
|
973
|
+
}),
|
|
974
|
+
// Accordion (default variant): hairline separators between items only — the color retune AND
|
|
975
|
+
// the last item's outer border-bottom drop both live in controls.module.css.
|
|
976
|
+
Accordion: Accordion.extend({ classNames: { item: controlsClasses.accordionItem } }),
|
|
977
|
+
// Parents faint, separator line-colored — the current-page treatment (head font, weight) is a
|
|
978
|
+
// shell-level concern (AppBreadcrumbs), not this generic Mantine primitive.
|
|
979
|
+
Breadcrumbs: Breadcrumbs.extend({
|
|
980
|
+
styles: {
|
|
981
|
+
breadcrumb: { color: 'var(--vx-faint)' },
|
|
982
|
+
separator: { color: 'var(--vx-surface-border)' },
|
|
798
983
|
},
|
|
799
|
-
},
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
}
|
|
984
|
+
}),
|
|
985
|
+
// Card idiom — same panel + shadow-card as every other surface.
|
|
986
|
+
Notification: Notification.extend({
|
|
987
|
+
defaultProps: { radius: radius.floating },
|
|
988
|
+
styles: {
|
|
989
|
+
root: {
|
|
990
|
+
backgroundColor: 'var(--vx-surface-panel)',
|
|
991
|
+
boxShadow: 'var(--vx-shadow-card)',
|
|
992
|
+
},
|
|
993
|
+
},
|
|
994
|
+
}),
|
|
995
|
+
},
|
|
996
|
+
})
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
/** The static, shipped-identity theme — `buildTheme` evaluated once at
|
|
1000
|
+
* `DEFAULT_DERIVE_CONFIG` (memoized by `buildPaletteData`), not per import. */
|
|
1001
|
+
export const baseTheme: MantineThemeOverride = buildTheme(DEFAULT_PALETTE_DATA)
|
|
803
1002
|
|
|
804
1003
|
/**
|
|
805
1004
|
* Bind Mantine's surface system to the SAME `--vx-*` variables the charts use, so chrome and
|
|
@@ -837,8 +1036,13 @@ export const baseTheme: MantineThemeOverride = createTheme({
|
|
|
837
1036
|
* emits, so they cannot drift, and they cover the window before the palette <style> lands
|
|
838
1037
|
* (`injectPalette={false}`).
|
|
839
1038
|
*/
|
|
840
|
-
function accentBridge(
|
|
1039
|
+
function accentBridge(
|
|
1040
|
+
theme: MantineTheme,
|
|
1041
|
+
side: 'light' | 'dark',
|
|
1042
|
+
data: PaletteData,
|
|
1043
|
+
): Record<string, string> {
|
|
841
1044
|
const c = theme.primaryColor
|
|
1045
|
+
const { ACCENT } = data
|
|
842
1046
|
return {
|
|
843
1047
|
[`--mantine-color-${c}-filled`]: `var(--vx-accentFill, ${ACCENT.accentFill[side]})`,
|
|
844
1048
|
[`--mantine-color-${c}-filled-hover`]: `var(--vx-accentFillHover, ${ACCENT.accentFillHover[side]})`,
|
|
@@ -859,9 +1063,9 @@ function accentBridge(theme: MantineTheme, side: 'light' | 'dark'): Record<strin
|
|
|
859
1063
|
* `dark` is deliberately not a member — `color="dark"` is a near-black surface by intent, not a
|
|
860
1064
|
* band color, and forcing it into the band would turn it into a mid grey.
|
|
861
1065
|
*/
|
|
862
|
-
function familyBridge(): Record<string, string> {
|
|
1066
|
+
function familyBridge(data: PaletteData): Record<string, string> {
|
|
863
1067
|
const vars: Record<string, string> = {}
|
|
864
|
-
for (const [name, hex] of Object.entries(FILL)) {
|
|
1068
|
+
for (const [name, hex] of Object.entries(data.FILL)) {
|
|
865
1069
|
vars[`--mantine-color-${name}-filled`] = `var(--vx-fill-${name}, ${hex})`
|
|
866
1070
|
vars[`--mantine-color-${name}-filled-hover`] =
|
|
867
1071
|
`var(--vx-fillHover-${name}, color-mix(in srgb, ${hex} 88%, #000))`
|
|
@@ -869,65 +1073,228 @@ function familyBridge(): Record<string, string> {
|
|
|
869
1073
|
return vars
|
|
870
1074
|
}
|
|
871
1075
|
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
1076
|
+
/**
|
|
1077
|
+
* Build the `cssVariablesResolver` bound to a given palette `data` — the derive-config-dependent
|
|
1078
|
+
* half of the fallback hexes below (see `buildTheme` above for the same split on `theme.colors`).
|
|
1079
|
+
* `cssVariablesResolver` (the static, shipped export) is `buildCssVariablesResolver(DEFAULT_PALETTE_DATA)`
|
|
1080
|
+
* evaluated ONCE below — and that is the ONLY resolver instance `BasaltProvider` ever wires in,
|
|
1081
|
+
* unconditionally, regardless of derive config. `createBasaltTheme`'s non-default `{ derive }` path
|
|
1082
|
+
* does NOT call this function: it rebuilds `theme.colors` (via `buildTheme`) but leaves the CSS
|
|
1083
|
+
* variables resolver at its shipped default. A retuned identity instead reaches paint time through
|
|
1084
|
+
* `BasaltBridge`'s injected `<style>` (the palette CSS built from the SAME resolved config, keyed
|
|
1085
|
+
* by `theme.other.basaltDerive`), which wins the cascade over the resolver's inline fallback hexes.
|
|
1086
|
+
* Limitation: `injectPalette={false}` combined with a custom `derive` therefore leaves the
|
|
1087
|
+
* resolver's fallback hexes at the shipped defaults — a consumer taking over palette injection
|
|
1088
|
+
* (SSR/head) with a non-default derive config must also emit `buildPaletteCss(opts, buildPaletteData(config))`
|
|
1089
|
+
* themselves, or those fallbacks silently mismatch the intended identity.
|
|
1090
|
+
*/
|
|
1091
|
+
function buildCssVariablesResolver(data: PaletteData): CSSVariablesResolver {
|
|
1092
|
+
const { INK, NEUTRAL, SURFACE } = data
|
|
1093
|
+
return (theme) => ({
|
|
1094
|
+
variables: {},
|
|
1095
|
+
light: {
|
|
1096
|
+
...onColorVars(theme, 'light', data),
|
|
1097
|
+
...familyBridge(data),
|
|
1098
|
+
...accentBridge(theme, 'light', data),
|
|
1099
|
+
'--mantine-color-body': `var(--vx-surface-bg, ${SURFACE.bg.light})`, // page background
|
|
1100
|
+
'--mantine-color-default': `var(--vx-surface-panel, ${SURFACE.panel.light})`, // cards / default controls
|
|
1101
|
+
'--mantine-color-default-hover': `var(--vx-surface-elevated, ${SURFACE.elevated.light})`,
|
|
1102
|
+
// THE central lever for doctrine inversion #1 on CONTROLS (docs/DESIGN-SPEC.md §8): depth is
|
|
1103
|
+
// `shadow-card`, never a hairline, for every `variant="default"` control — not just Card/Paper.
|
|
1104
|
+
// `defaultVariantColorsResolver`'s `variant === 'default'` branch reads this ONE var for every
|
|
1105
|
+
// component that uses it (Button, ActionIcon, Chip, CheckboxCard, RadioCard, …), so pointing it
|
|
1106
|
+
// at `transparent` kills the stock 1px hairline everywhere at once. `transparent`, not `border:
|
|
1107
|
+
// none` — the 1px border BOX stays, so focus/error can recolor the same box with no layout
|
|
1108
|
+
// shift and `[data-error]` still wins a visible border.
|
|
1109
|
+
'--mantine-color-default-border': 'transparent',
|
|
1110
|
+
'--mantine-color-dimmed': `var(--vx-neutral, ${NEUTRAL.neutral.light})`, // secondary / muted text
|
|
1111
|
+
'--mantine-color-text': `var(--vx-ink, ${INK.ink.light})`, // primary body/heading text
|
|
1112
|
+
'--app-shell-border-color': `var(--vx-surface-border, ${SURFACE.border.light})`,
|
|
1113
|
+
// THE strict-surface lever. Mantine components do NOT chain border/surface colors through
|
|
1114
|
+
// `--mantine-color-default-*`; each hardcodes a RAW ramp step (`--mantine-color-gray-{2,3,4}`
|
|
1115
|
+
// on light) directly — which is why AppShell/Table/Input/Divider/Tabs/Popover/Accordion borders
|
|
1116
|
+
// render an off-system color while cards use the hairline. Collapse the border-class ramp
|
|
1117
|
+
// steps onto the ONE "line" token so EVERY component's border is identical and the agent
|
|
1118
|
+
// cannot reintroduce a divergent border. (Hover/subtle BG steps are handled below.)
|
|
1119
|
+
'--mantine-color-gray-2': `var(--vx-surface-border, ${SURFACE.border.light})`,
|
|
1120
|
+
'--mantine-color-gray-3': `var(--vx-surface-border, ${SURFACE.border.light})`,
|
|
1121
|
+
'--mantine-color-gray-4': `var(--vx-surface-border, ${SURFACE.border.light})`,
|
|
1122
|
+
// Hover/subtle/striped/track surfaces read `gray-0/1` raw → the dedicated subtle token (a faint
|
|
1123
|
+
// step below panel, so hover is actually visible). Dark hover uses the generator-derived
|
|
1124
|
+
// dark-5/6/7 steps (`buildDarkTuple`), already on-identity.
|
|
1125
|
+
'--mantine-color-gray-0': `var(--vx-surface-subtle, ${SURFACE.subtle.light})`,
|
|
1126
|
+
'--mantine-color-gray-1': `var(--vx-surface-subtle, ${SURFACE.subtle.light})`,
|
|
1127
|
+
},
|
|
1128
|
+
dark: {
|
|
1129
|
+
...onColorVars(theme, 'dark', data),
|
|
1130
|
+
...familyBridge(data),
|
|
1131
|
+
...accentBridge(theme, 'dark', data),
|
|
1132
|
+
'--mantine-color-body': `var(--vx-surface-bg, ${SURFACE.bg.dark})`,
|
|
1133
|
+
'--mantine-color-default': `var(--vx-surface-panel, ${SURFACE.panel.dark})`,
|
|
1134
|
+
'--mantine-color-default-hover': `var(--vx-surface-elevated, ${SURFACE.elevated.dark})`,
|
|
1135
|
+
// See the light block above — same lever, both schemes.
|
|
1136
|
+
'--mantine-color-default-border': 'transparent',
|
|
1137
|
+
'--mantine-color-dimmed': `var(--vx-neutral, ${NEUTRAL.neutral.dark})`,
|
|
1138
|
+
'--mantine-color-text': `var(--vx-ink, ${INK.ink.dark})`,
|
|
1139
|
+
'--app-shell-border-color': `var(--vx-surface-border, ${SURFACE.border.dark})`,
|
|
1140
|
+
// Dark components read `--mantine-color-dark-4` (border) raw. `buildDarkTuple` already sets
|
|
1141
|
+
// dark-4, but to a slightly lighter step than the hairline token, so layout borders read
|
|
1142
|
+
// marginally heavier than card borders. Pin dark-4 to the SAME "line" token for parity.
|
|
1143
|
+
'--mantine-color-dark-4': `var(--vx-surface-border, ${SURFACE.border.dark})`,
|
|
1144
|
+
},
|
|
1145
|
+
})
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/** The static, shipped-identity resolver — `buildCssVariablesResolver` evaluated once at
|
|
1149
|
+
* `DEFAULT_DERIVE_CONFIG`. Unchanged call signature (`cssVariablesResolver(theme)`), so it drops
|
|
1150
|
+
* straight into `<MantineProvider cssVariablesResolver={cssVariablesResolver}>` as before. */
|
|
1151
|
+
export const cssVariablesResolver: CSSVariablesResolver =
|
|
1152
|
+
buildCssVariablesResolver(DEFAULT_PALETTE_DATA)
|
|
1153
|
+
|
|
1154
|
+
/** Options for {@link createBasaltTheme}'s derive-config path. */
|
|
1155
|
+
export type CreateBasaltThemeOptions = {
|
|
1156
|
+
/**
|
|
1157
|
+
* Retune the shipped palette identity from the six-knob derive engine (`basalt-ui/tokens`'s
|
|
1158
|
+
* `DeriveConfig`) instead of the shipped `#0077bd` zinc default. Omitted knobs fall back to
|
|
1159
|
+
* {@link DEFAULT_DERIVE_CONFIG}'s value for that knob (`resolveDeriveConfig`).
|
|
1160
|
+
*
|
|
1161
|
+
* This is the ONE place a consumer sets the palette identity — everything else follows: the
|
|
1162
|
+
* Mantine color ramps, the on-color contrast measurements, and the CSS-variables resolver
|
|
1163
|
+
* fallbacks are all rebuilt from the SAME resolved config, and the config itself is stashed on
|
|
1164
|
+
* `theme.other.basaltDerive` so `BasaltProvider` can inject the matching `--vx-*` stylesheet
|
|
1165
|
+
* automatically. For live DEV-time tuning instead of a fixed production identity, see
|
|
1166
|
+
* `DeriveControls` (`basalt-ui/theme-lab`).
|
|
1167
|
+
*/
|
|
1168
|
+
derive?: Partial<DeriveConfig>
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* Retune the three-font system (`docs/DESIGN-SPEC.md` §3: Nunito Sans body / Hubot Sans
|
|
1172
|
+
* condensed headings / JetBrains Mono numerals + micro-labels) instead of the shipped stacks.
|
|
1173
|
+
* THIS is the font entry point — a consumer must not set `fontFamily` literals in component code
|
|
1174
|
+
* (enforced by the `raw-font-family` guard kind, `./guard`); overriding Mantine's `fontFamily` via
|
|
1175
|
+
* `overrides` is unnecessary because the theme already reads `--basalt-font-sans/head/mono`.
|
|
1176
|
+
*
|
|
1177
|
+
* Each value is a FULL CSS font-family stack string (bring your own fallback chain) —
|
|
1178
|
+
* an omitted key keeps the shipped `styles.css` fallback untouched. The resolved value is
|
|
1179
|
+
* stashed on `theme.other.basaltFonts` so `BasaltProvider` can inject the matching
|
|
1180
|
+
* `--basalt-font-*` declarations — it rides the SAME `<style>` injection as the palette CSS, so
|
|
1181
|
+
* `injectPalette={false}` (SSR/head injection) also opts fonts out; a consumer taking over
|
|
1182
|
+
* injection must then emit those declarations itself.
|
|
1183
|
+
*
|
|
1184
|
+
* @example
|
|
1185
|
+
* createBasaltTheme(undefined, { fonts: { sans: 'Inter, sans-serif' } })
|
|
1186
|
+
*/
|
|
1187
|
+
fonts?: BasaltFontsConfig
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* Retune the two radius anchors (`card`/`ctrl`, `docs/DESIGN-SPEC.md` §4) and their dependent
|
|
1191
|
+
* offsets from a single integer level in `[-5, 5]` (default `0` = the shipped identity: card 7,
|
|
1192
|
+
* ctrl 6) — see `deriveRadius` (`basalt-ui/tokens`) for the exact law. Rebuilds every
|
|
1193
|
+
* radius-anchored `defaultProps`/`styles` number in the Mantine theme AND the `radius` size-scale
|
|
1194
|
+
* from the level's values. The resolved {@link RadiusValues} is stashed on
|
|
1195
|
+
* `theme.other.basaltRadius` (only when non-default) so `BasaltProvider` can emit the matching
|
|
1196
|
+
* `--vx-radius-*` override declarations — it rides the SAME `<style>` injection as the palette
|
|
1197
|
+
* CSS, so `injectPalette={false}` also opts the radius override out.
|
|
1198
|
+
*
|
|
1199
|
+
* For live DEV-time tuning instead of a fixed production identity, see the "Radius" slider on
|
|
1200
|
+
* `DeriveControls` (`basalt-ui/theme-lab`) — that dev-tool path can only move the CSS vars, not
|
|
1201
|
+
* the defaultProps numbers baked into the theme object; this option covers both.
|
|
1202
|
+
*
|
|
1203
|
+
* @example
|
|
1204
|
+
* createBasaltTheme(undefined, { radius: 2 })
|
|
1205
|
+
*/
|
|
1206
|
+
radius?: number
|
|
1207
|
+
|
|
1208
|
+
/**
|
|
1209
|
+
* Retune spacing DENSITY from a single integer level in `[-3, 3]` (default `0` = the shipped
|
|
1210
|
+
* identity) — narrower than `radius`'s `[-5, 5]` on purpose (see `deriveSpacing`'s JSDoc,
|
|
1211
|
+
* `basalt-ui/tokens`, for why: the same `0.7..1.30` multiplier envelope at fewer, more meaningful
|
|
1212
|
+
* notches). The law: a multiplier, `1 + 0.1 * level`, applied to every density-tracking anchor/
|
|
1213
|
+
* scale-stop/one-off (rounded, floored at 1), plus an independent additive law for the NavLink row
|
|
1214
|
+
* line-height. Rebuilds every
|
|
1215
|
+
* density-anchored `defaultProps`/`styles` number in the Mantine theme (Timeline's `bulletSize`,
|
|
1216
|
+
* Progress's `size`) AND the `spacing` size-scale from the level's values. The resolved
|
|
1217
|
+
* {@link SpaceValues} is stashed on `theme.other.basaltDensity` (only when non-default) so
|
|
1218
|
+
* `BasaltProvider` can emit the matching `--vx-space-*` override declarations — it rides the SAME
|
|
1219
|
+
* `<style>` injection as the palette CSS, so `injectPalette={false}` also opts the density
|
|
1220
|
+
* override out.
|
|
1221
|
+
*
|
|
1222
|
+
* For live DEV-time tuning instead of a fixed production identity, see the "Density" slider on
|
|
1223
|
+
* `DeriveControls` (`basalt-ui/theme-lab`) — that dev-tool path can only move the CSS vars, not
|
|
1224
|
+
* the defaultProps numbers baked into the theme object; this option covers both.
|
|
1225
|
+
*
|
|
1226
|
+
* @example
|
|
1227
|
+
* createBasaltTheme(undefined, { density: -2 })
|
|
1228
|
+
*/
|
|
1229
|
+
density?: number
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
/**
|
|
1233
|
+
* `true` when `fonts` sets at least one slot — an empty object (or one whose every key is
|
|
1234
|
+
* `undefined`) configures nothing, so `createBasaltTheme` must treat it as absent and stay on the
|
|
1235
|
+
* static `baseTheme` fast path rather than paying for a `mergeThemeOverrides` call that would only
|
|
1236
|
+
* stash an empty `basaltFonts: {}` on `theme.other`.
|
|
1237
|
+
*/
|
|
1238
|
+
function hasFontsConfig(fonts: BasaltFontsConfig | undefined): fonts is BasaltFontsConfig {
|
|
1239
|
+
return fonts !== undefined && Object.values(fonts).some((value) => value !== undefined)
|
|
1240
|
+
}
|
|
925
1241
|
|
|
926
1242
|
/**
|
|
927
1243
|
* Build the Basalt theme, optionally merged with consumer overrides. Overrides win on conflict
|
|
928
1244
|
* (Mantine `mergeThemeOverrides` is last-wins), so a consumer can retune any field without
|
|
929
1245
|
* forking the base.
|
|
1246
|
+
*
|
|
1247
|
+
* Pass `{ derive }` to retune the palette identity instead of the shipped default, `{ fonts }` to
|
|
1248
|
+
* retune the three-font system, `{ radius }` to retune the two radius anchors, and/or `{ density }`
|
|
1249
|
+
* to retune spacing density (see {@link CreateBasaltThemeOptions}); the default (no `options`, or
|
|
1250
|
+
* `derive`/`radius`/`density` that resolve back to nothing non-default and a `fonts` that sets no
|
|
1251
|
+
* slot — an omitted, empty, or all-`undefined`-keys object) stays on the pre-baked static
|
|
1252
|
+
* `baseTheme` — zero extra derivation work, byte-identical to the shipped identity.
|
|
1253
|
+
*
|
|
1254
|
+
* Call this at MODULE scope, not inline in a component's render — the non-default `{ derive }` /
|
|
1255
|
+
* `{ fonts }` / `{ radius }` / `{ density }` paths build a fresh `MantineThemeOverride` object on
|
|
1256
|
+
* every call (`mergeThemeOverrides(...)`), so calling it per-render would hand `MantineProvider` a
|
|
1257
|
+
* new `theme` reference every render and churn Mantine's theme context (and every consumer
|
|
1258
|
+
* subscribed to it) for no reason.
|
|
1259
|
+
*
|
|
1260
|
+
* `overrides.other` deep-merges onto the derive-produced `other` (Mantine's `mergeThemeOverrides` /
|
|
1261
|
+
* `deepMerge` recurse into plain-object values rather than replacing them wholesale), so passing
|
|
1262
|
+
* `{ other: { myFlag: true } }` alongside a non-default `derive`/`fonts`/`radius`/`density` still
|
|
1263
|
+
* leaves `other.basaltDerive`/`other.basaltFonts`/`other.basaltRadius`/`other.basaltDensity` intact
|
|
1264
|
+
* — it is only lost if a consumer's own `overrides.other` explicitly sets that same key.
|
|
930
1265
|
*/
|
|
931
|
-
export function createBasaltTheme(
|
|
932
|
-
|
|
1266
|
+
export function createBasaltTheme(
|
|
1267
|
+
overrides?: MantineThemeOverride,
|
|
1268
|
+
options?: CreateBasaltThemeOptions,
|
|
1269
|
+
): MantineThemeOverride {
|
|
1270
|
+
const resolvedConfig = resolveDeriveConfig(options?.derive)
|
|
1271
|
+
const radiusLevel = options?.radius ?? 0
|
|
1272
|
+
const radiusValues = deriveRadius(radiusLevel)
|
|
1273
|
+
const isDefaultRadius = radiusLevel === 0
|
|
1274
|
+
const densityLevel = options?.density ?? 0
|
|
1275
|
+
const spaceValues = deriveSpacing(densityLevel)
|
|
1276
|
+
const isDefaultDensity = densityLevel === 0
|
|
1277
|
+
const isDefaultDerive = isDefaultDeriveConfig(resolvedConfig)
|
|
1278
|
+
|
|
1279
|
+
let theme: MantineThemeOverride
|
|
1280
|
+
if (isDefaultDerive && isDefaultRadius && isDefaultDensity) {
|
|
1281
|
+
theme = baseTheme
|
|
1282
|
+
} else {
|
|
1283
|
+
const paletteData = isDefaultDerive ? DEFAULT_PALETTE_DATA : buildPaletteData(resolvedConfig)
|
|
1284
|
+
theme = mergeThemeOverrides(
|
|
1285
|
+
buildTheme(paletteData, { radius: radiusValues, spacing: spaceValues }),
|
|
1286
|
+
{
|
|
1287
|
+
other: {
|
|
1288
|
+
...(isDefaultDerive ? {} : { basaltDerive: resolvedConfig }),
|
|
1289
|
+
...(isDefaultRadius ? {} : { basaltRadius: radiusValues }),
|
|
1290
|
+
...(isDefaultDensity ? {} : { basaltDensity: spaceValues }),
|
|
1291
|
+
},
|
|
1292
|
+
},
|
|
1293
|
+
)
|
|
1294
|
+
}
|
|
1295
|
+
const fontsConfig = options?.fonts
|
|
1296
|
+
if (hasFontsConfig(fontsConfig)) {
|
|
1297
|
+
theme = mergeThemeOverrides(theme, { other: { basaltFonts: fontsConfig } })
|
|
1298
|
+
}
|
|
1299
|
+
return overrides ? mergeThemeOverrides(theme, overrides) : theme
|
|
933
1300
|
}
|