basalt-ui 1.0.0 → 1.0.2
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 +12 -12
- package/CHANGELOG.md +19 -0
- package/README.md +31 -44
- package/agent/rules/basalt-charts.md +1 -1
- package/agent/rules/basalt-mantine.md +3 -3
- package/agent/rules/basalt-router.md +1 -1
- package/agent/rules/basalt-state.md +2 -2
- package/agent/rules/basalt-tokens.md +3 -3
- package/agent/skills/basalt-app/SKILL.md +137 -0
- package/agent/skills/basalt-charts/SKILL.md +179 -0
- package/agent/skills/basalt-design/SKILL.md +249 -0
- package/agent/templates/CLAUDE-block.md.tpl +8 -5
- package/agent/templates/__root.tpl +1 -1
- package/agent/templates/query-client.ts.tpl +1 -1
- package/configs/check.yml +8 -8
- package/configs/lefthook.yml +9 -5
- package/configs/oxlint-plugin.js +119 -7
- package/configs/oxlint-plugin.test.ts +73 -3
- package/configs/oxlint.json +2 -71
- package/dist/cli/index.d.ts +71 -28
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +134 -121
- package/dist/surfaces.d.ts +41 -17
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +37 -38
- package/dist/tokens/index.d.ts +1 -0
- package/dist/tokens/index.d.ts.map +1 -1
- package/dist/tokens/index.js +3 -0
- package/llms.txt +2 -2
- package/package.json +2 -2
- package/src/cli/check-theme.test.ts +12 -2
- package/src/cli/help.test.ts +93 -0
- package/src/cli/index.ts +332 -184
- package/src/cli/placement-engine.test.ts +194 -0
- package/src/cli/tarball-parity.test.ts +44 -0
- package/src/cli/template-format.test.ts +64 -0
- package/src/cli/template-ledger.test.ts +219 -0
- package/src/surfaces.ts +78 -43
- package/src/tokens/index.ts +6 -0
- /package/bin/{basalt.mjs → basalt-ui.mjs} +0 -0
package/AGENTS.md
CHANGED
|
@@ -41,27 +41,27 @@ theme. Never write `#rrggbb`, `rgb(…)`, or `hsl(…)` in component or style co
|
|
|
41
41
|
**Motion discipline**: import animation from `motion/react`, never the raw `framer-motion`
|
|
42
42
|
package (enforced by oxlint `no-restricted-imports`). Route transition timing through the shared
|
|
43
43
|
`MOTION_DURATION` / `MOTION_SPRING` / `MOTION_EASE_STANDARD` tokens — never a hardcoded
|
|
44
|
-
duration/spring/ease literal in a `transition={{...}}` prop (enforced by `basalt check-theme`).
|
|
44
|
+
duration/spring/ease literal in a `transition={{...}}` prop (enforced by `basalt-ui check-theme`).
|
|
45
45
|
|
|
46
46
|
## Key commands
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
bunx basalt init # FIRST STEP: scaffold .claude/rules/
|
|
50
|
-
bunx basalt check-theme # fail on off-palette colors in consumer source
|
|
51
|
-
bunx basalt sync # reconcile managed files (.claude/rules/, CLAUDE.md block)
|
|
52
|
-
bunx basalt sync --check # CI freshness gate — exits non-zero if any managed file drifted
|
|
53
|
-
bunx basalt doctor # check consumer repo basalt integration health
|
|
54
|
-
bunx basalt info # print published surface map
|
|
55
|
-
bunx basalt info --json # stable JSON surface map
|
|
56
|
-
bunx basalt guard-hook # PreToolUse theme-guard adapter: reads a Write/Edit payload on stdin, denies off-palette writes
|
|
49
|
+
bunx basalt-ui init # FIRST STEP: scaffold .claude/rules/ + .claude/skills/, managed CLAUDE.md block, DESIGN.md seed, toolchain seeds
|
|
50
|
+
bunx basalt-ui check-theme # fail on off-palette colors in consumer source
|
|
51
|
+
bunx basalt-ui sync # reconcile managed files (.claude/rules/, .claude/skills/, CLAUDE.md block)
|
|
52
|
+
bunx basalt-ui sync --check # CI freshness gate — exits non-zero if any managed file drifted
|
|
53
|
+
bunx basalt-ui doctor # check consumer repo basalt integration health
|
|
54
|
+
bunx basalt-ui info # print published surface map
|
|
55
|
+
bunx basalt-ui info --json # stable JSON surface map
|
|
56
|
+
bunx basalt-ui guard-hook # PreToolUse theme-guard adapter: reads a Write/Edit payload on stdin, denies off-palette writes
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
Register `guard-hook` in `.claude/settings.json` under `hooks.PreToolUse` with matcher
|
|
60
|
-
`Write|Edit|MultiEdit` and command `bunx basalt guard-hook` so the agent can't write off-palette
|
|
60
|
+
`Write|Edit|MultiEdit` and command `bunx basalt-ui guard-hook` so the agent can't write off-palette
|
|
61
61
|
colors without a `theme-allow` comment.
|
|
62
62
|
|
|
63
|
-
> **Framework-internal only** — `bunx basalt check-coverage` is a self-consistency gate for the
|
|
64
|
-
> basalt-ui repo itself (asserts SURFACES ↔
|
|
63
|
+
> **Framework-internal only** — `bunx basalt-ui check-coverage` is a self-consistency gate for the
|
|
64
|
+
> basalt-ui repo itself (asserts SURFACES ↔ rule files ↔ skill files ↔ package.json exports). It
|
|
65
65
|
> is not a consumer command and will skip assertion 3 outside the framework repo.
|
|
66
66
|
|
|
67
67
|
## Machine-readable surface map
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## [1.0.2](https://github.com/jkrumm/basalt-ui/compare/v1.0.1...v1.0.2) (2026-07-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* make the import boundary unclobberable and stop false drift on sync ([98aba84](https://github.com/jkrumm/basalt-ui/commit/98aba8497eb359cbc86e3bee289d21d3e2dbd099))
|
|
7
|
+
|
|
8
|
+
## [1.0.1](https://github.com/jkrumm/basalt-ui/compare/v1.0.0...v1.0.1) (2026-07-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* collapse delivery to one package, one command, one version ([94de69c](https://github.com/jkrumm/basalt-ui/commit/94de69c80b4369265e72bf375839d145ec1cf954))
|
|
14
|
+
* drop argo-shaped CLI defaults ([cd911d2](https://github.com/jkrumm/basalt-ui/commit/cd911d2f2756b678d65c3b65da8f6fbacd4096c1))
|
|
15
|
+
* export the BP hue families and p pair-picker from the tokens entry ([a9b34c5](https://github.com/jkrumm/basalt-ui/commit/a9b34c51dbab3c960c389bda24b10a67dba254e2))
|
|
16
|
+
* let consumers own their CI and git hooks ([15232df](https://github.com/jkrumm/basalt-ui/commit/15232df84ee04e47d2b913ba6bd489542685b67a))
|
|
17
|
+
* make the managed CLAUDE block oxfmt-clean ([8300ea6](https://github.com/jkrumm/basalt-ui/commit/8300ea6e4b06ce6d3a24fcfae22e846299ece829))
|
|
18
|
+
* print help instead of running the command ([a7a866c](https://github.com/jkrumm/basalt-ui/commit/a7a866c9677b71c3b35983fe93262204464f879d))
|
|
19
|
+
|
|
1
20
|
# [1.0.0](https://github.com/jkrumm/basalt-ui/compare/v0.4.2...v1.0.0) (2026-07-16)
|
|
2
21
|
|
|
3
22
|
|
package/README.md
CHANGED
|
@@ -29,44 +29,31 @@ peers, but pnpm/npm consumers must add it explicitly or hit an unexplained build
|
|
|
29
29
|
A real app also needs `@types/react @types/react-dom` (dev) and a standard Vite `vite-env.d.ts`
|
|
30
30
|
for `tsc --noEmit` to pass.
|
|
31
31
|
|
|
32
|
-
### 2. Scaffold the repo doctrine (`basalt init`)
|
|
32
|
+
### 2. Scaffold the repo doctrine (`basalt-ui init`)
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
bunx basalt init
|
|
35
|
+
bunx basalt-ui init
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
That's the whole install — there is no plugin, no marketplace, and no second version to track.
|
|
39
|
+
`init` writes into the consumer repo:
|
|
39
40
|
|
|
40
41
|
- `.claude/rules/basalt-*.md` — twelve Claude Code rules (`basalt-tokens`, `basalt-charts`, `basalt-mantine`, `basalt-router`, `basalt-query`, `basalt-state`, `basalt-forms`, `basalt-notifications`, `basalt-commands`, `basalt-data`, `basalt-agent`, `basalt-content`)
|
|
42
|
+
- `.claude/skills/basalt-{app,design,charts}/SKILL.md` — the three skills (`/basalt-app`, `/basalt-design`, `/basalt-charts`), same managed path as the rules
|
|
41
43
|
- A managed `<!-- basalt:begin/end -->` block in `CLAUDE.md` — stack facts, the DESIGN.md pointer, and the frontend-design restraint override
|
|
42
44
|
- A thin `DESIGN.md` seed — your app's deltas (series dictionary, identity, deviations)
|
|
43
|
-
- Toolchain
|
|
44
|
-
- `.
|
|
45
|
-
- `.basalt/manifest.json` — sha256 per managed file for `sync` three-way diff
|
|
45
|
+
- Toolchain seeds: `.oxlintrc.json` and `lefthook.yml` as `extends` stubs into `node_modules/basalt-ui/configs/` (the presets auto-update with the package), plus `.oxfmtrc.json` and `.github/workflows/check.yml` as starting copies
|
|
46
|
+
- `.basalt/manifest.json` — sha256 per managed file + the basalt-ui version, for `sync` three-way diff and `doctor`
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
claude plugin marketplace add jkrumm/basalt-ui
|
|
51
|
-
claude plugin install basalt@basalt-ui # enable auto-update when prompted
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Gives you `/basalt:app`, `/basalt:design`, `/basalt:charts` in every Claude Code session.
|
|
55
|
-
|
|
56
|
-
### The plugin and `basalt init` are a pair
|
|
57
|
-
|
|
58
|
-
| Channel | Ships | Scope |
|
|
59
|
-
| ----------------- | -------------------------------------------------------------------- | ------------------------------------------------------- |
|
|
60
|
-
| **Plugin** | The three skills (`/basalt:app`, `/basalt:design`, `/basalt:charts`) | User scope — installed once, available in every project |
|
|
61
|
-
| **`basalt init`** | The repo doctrine (rules, CLAUDE block, DESIGN.md, toolchain) | Per repo — run once per consumer |
|
|
62
|
-
|
|
63
|
-
A Claude Code plugin cannot write project context (`CLAUDE.md`, `.claude/rules/`, `DESIGN.md`) — that is why doctrine is a separate per-repo `init`. And `init` cannot auto-install a plugin at user scope — that is why the plugin is a one-time separate step. Skills without `init` degrade to generic advice. `init` without the plugin still loads the rules as context, but the design and charts workflows are not a slash command away. Do both.
|
|
48
|
+
Every file is either **managed** (basalt owns it, `sync` refreshes it, local edits are skipped and
|
|
49
|
+
reported — exactly the files Claude reads, which cannot load from `node_modules`) or a **seed**
|
|
50
|
+
(written once, then yours forever). One rule decides which: does Claude read the file?
|
|
64
51
|
|
|
65
52
|
---
|
|
66
53
|
|
|
67
54
|
## Wire the runtime
|
|
68
55
|
|
|
69
|
-
After `bunx basalt init`, wire the provider, overlays, and vite preset. This mirrors the canonical
|
|
56
|
+
After `bunx basalt-ui init`, wire the provider, overlays, and vite preset. This mirrors the canonical
|
|
70
57
|
reference, `apps/playground/src/main.tsx`:
|
|
71
58
|
|
|
72
59
|
```tsx
|
|
@@ -132,21 +119,21 @@ export default basaltViteConfig({ port: 5173, apiTarget: 'http://localhost:3000'
|
|
|
132
119
|
```
|
|
133
120
|
|
|
134
121
|
> **Local consumption (sibling checkouts).** Developing against an unpublished / `file:`-linked
|
|
135
|
-
> basalt-ui from a sibling repo? Build `dist/` first — `bunx basalt` always resolves
|
|
136
|
-
> `bin/basalt.mjs` → `dist/cli/index.js`, even though the _runtime_ import can ride
|
|
122
|
+
> basalt-ui from a sibling repo? Build `dist/` first — `bunx basalt-ui` always resolves
|
|
123
|
+
> `bin/basalt-ui.mjs` → `dist/cli/index.js`, even though the _runtime_ import can ride
|
|
137
124
|
> `basaltViteConfig`'s `BASALT_LOCAL`/`basaltSrc` source aliasing above. And in a monorepo, add
|
|
138
125
|
> `basalt-ui` as a **root** devDependency (not only a leaf-workspace dep) so its bin hoists into the
|
|
139
|
-
> root `node_modules/.bin` — otherwise `bunx basalt` silently resolves the stale published
|
|
140
|
-
> from npm instead of your local checkout.
|
|
126
|
+
> root `node_modules/.bin` — otherwise `bunx basalt-ui` silently resolves the stale published
|
|
127
|
+
> package from npm instead of your local checkout.
|
|
141
128
|
|
|
142
129
|
```ts
|
|
143
130
|
// Lint — theme guard is the teeth behind the token doctrine
|
|
144
131
|
// package.json scripts:
|
|
145
|
-
"lint": "oxlint . && basalt check-theme"
|
|
132
|
+
"lint": "oxlint . && basalt-ui check-theme"
|
|
146
133
|
```
|
|
147
134
|
|
|
148
|
-
`check-theme` scans
|
|
149
|
-
in your `package.json
|
|
135
|
+
`check-theme` scans `src/` by default — a monorepo points it at its real roots via a `"basalt"`
|
|
136
|
+
key in your `package.json`:
|
|
150
137
|
|
|
151
138
|
```json
|
|
152
139
|
// package.json
|
|
@@ -157,8 +144,8 @@ in your `package.json` (defaults are argo's own paths and will scan 0 files in a
|
|
|
157
144
|
}
|
|
158
145
|
```
|
|
159
146
|
|
|
160
|
-
`
|
|
161
|
-
|
|
147
|
+
`check-theme` fails loudly (instead of a false `✓`) when the configured roots resolve to zero
|
|
148
|
+
scanned files. Other `"basalt"` config keys (`exempt`,
|
|
162
149
|
`spacingSteps`, `forbiddenAccents`, …) are documented on the `BasaltConfig` type.
|
|
163
150
|
|
|
164
151
|
---
|
|
@@ -469,13 +456,13 @@ Current slots: `series` (read by `./charts` + `./tokens`), `commands` (read by `
|
|
|
469
456
|
## CLI
|
|
470
457
|
|
|
471
458
|
```bash
|
|
472
|
-
bunx basalt init # scaffold doctrine into a consumer repo
|
|
473
|
-
bunx basalt sync # three-way diff against .basalt/manifest.json after a basalt-ui upgrade
|
|
474
|
-
bunx basalt sync --check # CI drift gate — non-zero exit on any managed-file drift
|
|
475
|
-
bunx basalt check-theme # palette guard — fails on colors that bypass the central --vx-* system
|
|
476
|
-
bunx basalt doctor # check consumer repo basalt integration health (manifest
|
|
477
|
-
bunx basalt info # human-readable surface map: subpath, layer, rule, skills, optional peers
|
|
478
|
-
bunx basalt info --json # same map as stable JSON (InfoOutput shape)
|
|
459
|
+
bunx basalt-ui init # scaffold doctrine into a consumer repo
|
|
460
|
+
bunx basalt-ui sync # three-way diff against .basalt/manifest.json after a basalt-ui upgrade
|
|
461
|
+
bunx basalt-ui sync --check # CI drift gate — non-zero exit on any managed-file drift
|
|
462
|
+
bunx basalt-ui check-theme # palette guard — fails on colors that bypass the central --vx-* system
|
|
463
|
+
bunx basalt-ui doctor # check consumer repo basalt integration health (manifest + one version axis: node_modules vs manifest)
|
|
464
|
+
bunx basalt-ui info # human-readable surface map: subpath, layer, rule, skills, optional peers
|
|
465
|
+
bunx basalt-ui info --json # same map as stable JSON (InfoOutput shape)
|
|
479
466
|
```
|
|
480
467
|
|
|
481
468
|
`sync` strategy per file: unchanged since last write → overwrite; locally edited → skip (show diff); missing → recreate. `--force` overwrites local edits.
|
|
@@ -490,7 +477,7 @@ bunx basalt info --json # same map as stable JSON (InfoOutput shape)
|
|
|
490
477
|
- **TypeScript**: strict mode throughout
|
|
491
478
|
- **Tarball ships `src/`** alongside `dist/` — go-to-definition lands in real source, not compiled output
|
|
492
479
|
|
|
493
|
-
The `./configs/*` export gives consumer apps raw presets to `extends` or copy via `basalt init`:
|
|
480
|
+
The `./configs/*` export gives consumer apps raw presets to `extends` or copy via `basalt-ui init`:
|
|
494
481
|
|
|
495
482
|
```json
|
|
496
483
|
// .oxlintrc.json
|
|
@@ -499,13 +486,13 @@ The `./configs/*` export gives consumer apps raw presets to `extends` or copy vi
|
|
|
499
486
|
|
|
500
487
|
---
|
|
501
488
|
|
|
502
|
-
## `basalt sync` in CI
|
|
489
|
+
## `basalt-ui sync` in CI
|
|
503
490
|
|
|
504
491
|
Wire the drift gate to catch doctrine falling behind after a basalt-ui upgrade:
|
|
505
492
|
|
|
506
493
|
```yaml
|
|
507
|
-
# .github/workflows/check.yml (
|
|
508
|
-
- run: bunx basalt sync --check
|
|
494
|
+
# .github/workflows/check.yml (seeded by basalt-ui init)
|
|
495
|
+
- run: bunx basalt-ui sync --check
|
|
509
496
|
```
|
|
510
497
|
|
|
511
498
|
---
|
|
@@ -36,7 +36,7 @@ downstream apps too:
|
|
|
36
36
|
shapes and optional highlight state.
|
|
37
37
|
3. **ChartTooltip** + `TooltipHeader` + `TooltipRow` + `TooltipBody` — never `@visx/tooltip` directly.
|
|
38
38
|
4. **AxisLeftNumeric** / **AxisRightNumeric** + **AxisBottomDate** — never raw `<AxisLeft>`/`<AxisBottom>`/`<AxisRight>`
|
|
39
|
-
(they miss theme tokens + smart ticks). Enforced by `basalt check-theme` (`raw-visx-axis` guard
|
|
39
|
+
(they miss theme tokens + smart ticks). Enforced by `basalt-ui check-theme` (`raw-visx-axis` guard
|
|
40
40
|
fails the build on a raw axis in a `/charts/` file; escape via `theme-allow`), not just convention.
|
|
41
41
|
5. **HoverOverlay** for mouse capture, **HoverContext** for cross-chart crosshair sync,
|
|
42
42
|
**useChartTooltip** for tip state, **useHoverSync** for the shared cursor. Wrap a group of
|
|
@@ -143,7 +143,7 @@ section divider, not card depth) are both fine.
|
|
|
143
143
|
consumer code must compose Mantine layout/surface primitives — `Box`, `Flex`, `Grid`,
|
|
144
144
|
`SimpleGrid`, `Stack`, `Group`, `Paper`, `Card` — instead of raw `<div>`/`<span>` with inline
|
|
145
145
|
`style`. Raw HTML with inline layout/surface styling defeats the token system.
|
|
146
|
-
- **Mechanical enforcement.** `basalt check-theme` adds five surface guard kinds (each a config knob,
|
|
146
|
+
- **Mechanical enforcement.** `basalt-ui check-theme` adds five surface guard kinds (each a config knob,
|
|
147
147
|
default ON; `theme-allow` line-comment escape): `off-system-surface-var` (raw ramp-step vars),
|
|
148
148
|
`card-with-border` (`withBorder` on a `Card`/`Paper`), `raw-html-layout` (raw `<div>`/`<span>` with
|
|
149
149
|
inline layout/surface styling), `inline-spacing` (inline spacing literals), `inline-display`
|
|
@@ -188,7 +188,7 @@ shape doctrine lives here; the spacing/radius/type **tokens** are in basalt-toke
|
|
|
188
188
|
separate `border` property). Cards must never diverge: same radius, same shadow. Never
|
|
189
189
|
inline-override `border`/`borderRadius`/`boxShadow`/`backgroundColor` on a surface — use the
|
|
190
190
|
radius token (`radius="md"` / `var(--vx-radius-card)`) + `VX.shadowCard` + `VX.surface.*`.
|
|
191
|
-
Mechanically enforced by `basalt check-theme`'s `raw-surface` guard. Outer spacing comes from the
|
|
191
|
+
Mechanically enforced by `basalt-ui check-theme`'s `raw-surface` guard. Outer spacing comes from the
|
|
192
192
|
parent `Stack`/`SimpleGrid` gap, not an intrinsic card margin.
|
|
193
193
|
- **Depth = `shadow-card`, not a plain hairline** (see `docs/DESIGN-SPEC.md` in the basalt-ui repo,
|
|
194
194
|
doctrine inversion #1 — this supersedes the old "never a drop shadow" rule). Elevation tiers: 0 flat (no shadow — body,
|
|
@@ -318,7 +318,7 @@ precedent as `@visx/*`: an internal implementation detail, not a peer the consum
|
|
|
318
318
|
- **Never a hardcoded duration/spring/ease literal in a `transition={{...}}` prop.** Import
|
|
319
319
|
`MOTION_DURATION` / `MOTION_SPRING` / `MOTION_EASE_STANDARD` from `basalt-ui` instead — the
|
|
320
320
|
motion analog of routing color through `VX.*`. `MOTION_DURATION` is capped at 0.3s (300ms),
|
|
321
|
-
matching the interaction-feedback ceiling above. Mechanically enforced by `basalt check-theme`'s
|
|
321
|
+
matching the interaction-feedback ceiling above. Mechanically enforced by `basalt-ui check-theme`'s
|
|
322
322
|
`raw-motion-value` guard (default ON; `theme-allow` line-comment escape).
|
|
323
323
|
- **Always branch on `useReducedMotion`** (`@mantine/hooks`) — render a real unanimated code path
|
|
324
324
|
(no `motion.*` wrapper at all), not just `transition={{ duration: 0 }}`. See `ThemeToggle`'s
|
|
@@ -108,7 +108,7 @@ Install `@tanstack/react-router` as a peer, then import from `basalt-ui/router-t
|
|
|
108
108
|
tree (`src/routeTree.gen.ts`) has been generated. In CI and after adding routes, run
|
|
109
109
|
`tsr generate` (or `bun run typecheck`, which triggers it) before relying on breadcrumb or nav data.
|
|
110
110
|
- The loader's `context.queryClient` requires `createRootRouteWithContext<{ queryClient: QueryClient }>()`.
|
|
111
|
-
Run `basalt init` to scaffold a `query-client.ts` + `__root.tsx` seed that wires the TanStack
|
|
111
|
+
Run `basalt-ui init` to scaffold a `query-client.ts` + `__root.tsx` seed that wires the TanStack
|
|
112
112
|
Router + Query context correctly — the generated `__root.tsx` uses
|
|
113
113
|
`createRootRouteWithContext<{ queryClient }>()` and passes the client through `RouterProvider`.
|
|
114
114
|
|
|
@@ -9,7 +9,7 @@ paths:
|
|
|
9
9
|
# Basalt State
|
|
10
10
|
|
|
11
11
|
How to place state in a basalt-ui app. The **theme-scheme rule** below is
|
|
12
|
-
guard-enforced (`basalt check-theme` bans `localStorage.getItem('theme')`); the rest is **advisory**.
|
|
12
|
+
guard-enforced (`basalt-ui check-theme` bans `localStorage.getItem('theme')`); the rest is **advisory**.
|
|
13
13
|
|
|
14
14
|
## State placement
|
|
15
15
|
|
|
@@ -21,7 +21,7 @@ Pick the right home for each kind of state — don't dump everything into one st
|
|
|
21
21
|
might link to.
|
|
22
22
|
- **Theme / color scheme** → `useMantineColorScheme()` from Mantine — **never** a client store, and
|
|
23
23
|
**never** `localStorage.getItem('theme')`. The scheme persists to Mantine's own key and resolves the
|
|
24
|
-
`--vx-*` tokens via CSS; reading it any other way breaks scheme reactivity and trips `basalt check-theme`.
|
|
24
|
+
`--vx-*` tokens via CSS; reading it any other way breaks scheme reactivity and trips `basalt-ui check-theme`.
|
|
25
25
|
- **UI preferences that must survive navigation but aren't URL-worthy** (sidebar collapsed, panel
|
|
26
26
|
layout, draft filters) → `createPersistedState` from `basalt-ui/state` — the framework's own
|
|
27
27
|
versioned localStorage primitive (see below). `BasaltShell` already persists its own collapse state
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
source: basalt-ui
|
|
3
|
-
description: Color, spacing, radius, and type discipline — route every value through the basalt-ui token system. Enforced by `basalt check-theme`.
|
|
3
|
+
description: Color, spacing, radius, and type discipline — route every value through the basalt-ui token system. Enforced by `basalt-ui check-theme`.
|
|
4
4
|
paths:
|
|
5
5
|
- 'src/**'
|
|
6
6
|
- 'apps/**/src/**'
|
|
@@ -21,8 +21,8 @@ surface (60/30/10, pushed toward 90/10); the accent only points — primary CTA,
|
|
|
21
21
|
status pops — never floods. (Blueprint/Basalt zinc-charcoal are the historical hue-tuning
|
|
22
22
|
ancestors; `docs/DESIGN-SPEC.md` in the basalt-ui repo supersedes both — see its "Doctrine
|
|
23
23
|
inversions" section.) This
|
|
24
|
-
rule is the operational checklist; it is enforced mechanically by **`basalt check-theme`**
|
|
25
|
-
(wire it into `lint`: `oxlint . && basalt check-theme`). A violation fails the build. Escape hatch: a
|
|
24
|
+
rule is the operational checklist; it is enforced mechanically by **`basalt-ui check-theme`**
|
|
25
|
+
(wire it into `lint`: `oxlint . && basalt-ui check-theme`). A violation fails the build. Escape hatch: a
|
|
26
26
|
`theme-allow` line comment (diff-visible, deliberate).
|
|
27
27
|
|
|
28
28
|
`check-theme` reads its config from your `package.json` `"basalt"` key
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: basalt-app
|
|
3
|
+
description: Scaffold or refresh a basalt-ui app — guided wrapper around 'basalt-ui init' (first-time scaffold) and 'basalt-ui sync' (drift-managed refresh). The whole agentic layer ships in the npm package — init places the skills, rules, CLAUDE block, and DESIGN.md; sync keeps the managed half fresh. Use when setting up basalt-ui in a new/existing app, wiring the provider/shell/vite preset, or when the doctrine feels missing.
|
|
4
|
+
when_to_use: User is adding basalt-ui to a new or existing app, asks how to set it up / scaffold it, wants to wire BasaltProvider / BasaltShell / the vite preset, refresh the shipped rules and DESIGN.md, or run a freshness check in CI. Also when /basalt-design reports no consumer DESIGN.md (the app isn't scaffolded yet).
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
`/basalt-app` scaffolds a basalt-ui consumer and keeps its shipped doctrine fresh. It wraps the two
|
|
8
|
+
CLI subcommands — `basalt-ui init` (first run) and `basalt-ui sync` (refresh) — and explains the
|
|
9
|
+
wiring they don't do for you (provider, shell, vite). All of it via `bunx basalt-ui` (Bun runtime).
|
|
10
|
+
|
|
11
|
+
## One package, one command, one version
|
|
12
|
+
|
|
13
|
+
Everything ships in the `basalt-ui` npm package — components, toolchain presets, rules, skills,
|
|
14
|
+
templates. Becoming a consumer is exactly two steps:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
bun add basalt-ui
|
|
18
|
+
bunx basalt-ui init
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
There is no plugin and no marketplace. `init`/`sync` place every file with one of two modes, and
|
|
22
|
+
which mode a file gets answers a single question — **does Claude read it?**
|
|
23
|
+
|
|
24
|
+
| Mode | Files | Lifecycle |
|
|
25
|
+
| ----------- | ----------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
26
|
+
| **managed** | `.claude/rules/basalt-*.md`, `.claude/skills/basalt-*/SKILL.md`, the `CLAUDE.md` block | basalt owns it; `sync` refreshes it; a local edit is skipped and reported (`--force` overwrites); the sync diff is the review gate |
|
|
27
|
+
| **seed** | `DESIGN.md`, `.oxlintrc.json`, `.oxfmtrc.json`, `lefthook.yml`, `.github/workflows/check.yml`, optional scaffolds | written once, then yours forever; `sync` recreates it only when missing and never reports it |
|
|
28
|
+
|
|
29
|
+
Claude Code cannot load rules or skills from `node_modules` — that platform limit is the only
|
|
30
|
+
reason anything is copied. Everything a machine reads is a **reference** instead: the seeded
|
|
31
|
+
`.oxlintrc.json` and `lefthook.yml` just `extends` the presets inside
|
|
32
|
+
`node_modules/basalt-ui/configs/`, so the toolchain auto-updates with the package while you still
|
|
33
|
+
own the files.
|
|
34
|
+
|
|
35
|
+
## First-time scaffold: `bunx basalt-ui init`
|
|
36
|
+
|
|
37
|
+
`init` writes the repo-side doctrine and toolchain into a consumer (monorepo globs supported):
|
|
38
|
+
|
|
39
|
+
- `.claude/rules/basalt-*.md` — the twelve shipped rules (`basalt-tokens`, `basalt-charts`,
|
|
40
|
+
`basalt-mantine`, `basalt-router`, `basalt-query`, `basalt-state`, `basalt-forms`,
|
|
41
|
+
`basalt-notifications`, `basalt-commands`, `basalt-data`, `basalt-agent`, `basalt-content`),
|
|
42
|
+
managed verbatim.
|
|
43
|
+
- `.claude/skills/basalt-{app,charts,design}/SKILL.md` — the three skills (`/basalt-app`,
|
|
44
|
+
`/basalt-charts`, `/basalt-design`), managed verbatim, same path the rules take.
|
|
45
|
+
- A managed `<!-- basalt:begin --> ... <!-- basalt:end -->` block in `CLAUDE.md`: stack facts, the
|
|
46
|
+
**DESIGN.md-is-law** pointer, and the **frontend-design restraint override** (in a dashboard, the
|
|
47
|
+
bold move is calm — defer to `/basalt-design`, not generic "make it striking" instincts).
|
|
48
|
+
- A **thin** `DESIGN.md` seed (deltas only on top of the `basalt-*` rules): identity confirmation,
|
|
49
|
+
the series dictionary, app deviations. The CLAUDE block `@`-imports it, so it auto-loads.
|
|
50
|
+
- Toolchain seeds: `.oxlintrc.json` and `lefthook.yml` are `extends` stubs pointing into
|
|
51
|
+
`node_modules/basalt-ui/configs/`; `.oxfmtrc.json` is a starting copy (oxfmt has no `extends`);
|
|
52
|
+
`.github/workflows/check.yml` is a starting workflow. All four are yours after the first write.
|
|
53
|
+
- `.basalt/manifest.json` — a sha256 per managed file + the basalt-ui version that wrote it, so
|
|
54
|
+
`sync` can three-way diff and `doctor` can spot a stale install.
|
|
55
|
+
|
|
56
|
+
After `init`, do the runtime wiring (the CLI scaffolds files, not your app's composition):
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
// Provider — wraps MantineProvider, injects the --vx-* palette, bridges the Vx tokens
|
|
60
|
+
import { BasaltProvider } from 'basalt-ui'
|
|
61
|
+
;<BasaltProvider>{/* app */}</BasaltProvider>
|
|
62
|
+
|
|
63
|
+
// Shell — sidebar / mobile-nav / breadcrumbs / page-header; router-agnostic
|
|
64
|
+
import { BasaltShell, NavCountBadge, ThemeToggle } from 'basalt-ui'
|
|
65
|
+
// <ThemeToggle /> in globalActions — cycles light/dark/system on click, hover/focus reveals
|
|
66
|
+
// a direct-select popover. Animated (motion) sun/moon glyph, never a computer/monitor icon.
|
|
67
|
+
|
|
68
|
+
// Theme — start from the base, override deltas only
|
|
69
|
+
import { createBasaltTheme } from 'basalt-ui'
|
|
70
|
+
const theme = createBasaltTheme({
|
|
71
|
+
/* app deltas */
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
// vite.config.ts — the shipped preset (dedupe react + @mantine/*, strictPort, /api proxy, BASALT_LOCAL alias)
|
|
77
|
+
import { basaltViteConfig } from 'basalt-ui/vite'
|
|
78
|
+
export default basaltViteConfig({ port: 5173, apiTarget: 'http://localhost:3000' })
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
// Tailwind era is over — there is no Tailwind. Styles come from:
|
|
83
|
+
import 'basalt-ui/styles.css' // @layer basalt base styles, iOS input safety net, font stack
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Lint wires as `oxlint . && basalt-ui check-theme` — the theme guard is the teeth behind the token
|
|
87
|
+
doctrine. The consumer series file (`src/lib/series.ts` by default; configurable via
|
|
88
|
+
`basalt.seriesModulePath`) is the single guard-exempt palette source — see `/basalt-charts`.
|
|
89
|
+
|
|
90
|
+
## Refresh: `bunx basalt-ui sync`
|
|
91
|
+
|
|
92
|
+
`sync` re-applies shipped doctrine after a basalt-ui upgrade, three-way against
|
|
93
|
+
`.basalt/manifest.json`:
|
|
94
|
+
|
|
95
|
+
- **Unchanged since last write** → overwrite with the new version.
|
|
96
|
+
- **Locally edited** → show a diff and **skip** (preserves your edits) unless `--force`.
|
|
97
|
+
- **Missing** → recreate.
|
|
98
|
+
- `sync --check` makes no changes and exits non-zero on drift — wire it as a CI freshness gate so a
|
|
99
|
+
consumer can't silently fall behind the shipped rules.
|
|
100
|
+
|
|
101
|
+
Seeds (`DESIGN.md`, the toolchain files, the scaffolds) are never reconciled or drift-reported —
|
|
102
|
+
they are yours. The managed files (rules, skills, the CLAUDE block) are framework-owned and meant
|
|
103
|
+
to be overwritten; the sync diff is where you review a doctrine change before committing it.
|
|
104
|
+
|
|
105
|
+
## Precedence the scaffold establishes
|
|
106
|
+
|
|
107
|
+
After scaffolding, the doctrine resolves in this order (highest wins):
|
|
108
|
+
|
|
109
|
+
> consumer `DESIGN.md` (deltas) > shipped `basalt-*` rules > skills
|
|
110
|
+
|
|
111
|
+
So an app deviation goes in `DESIGN.md`; the universal law and its enforcement live in the
|
|
112
|
+
`basalt-*` rules; and the skills (`/basalt-design`, `/basalt-charts`) are the method that obeys
|
|
113
|
+
both.
|
|
114
|
+
|
|
115
|
+
## Checklist
|
|
116
|
+
|
|
117
|
+
- Ran `bun add basalt-ui && bunx basalt-ui init` — rules, skills, CLAUDE block, DESIGN.md all
|
|
118
|
+
present from the one package.
|
|
119
|
+
- `BasaltProvider` wraps the app; `createBasaltTheme` used for theme deltas; `basalt-ui/styles.css`
|
|
120
|
+
imported.
|
|
121
|
+
- `basaltViteConfig` adopted; `oxlint . && basalt-ui check-theme` is the lint command.
|
|
122
|
+
- A thin `DESIGN.md` (deltas) + the twelve `basalt-*` rules + the managed CLAUDE block are present.
|
|
123
|
+
- `src/lib/series.ts` exists as the one guard-exempt series source (for any app metric colors).
|
|
124
|
+
- `basalt-ui sync --check` wired in CI (recommended) to catch drift on future upgrades.
|
|
125
|
+
|
|
126
|
+
## Notes
|
|
127
|
+
|
|
128
|
+
- `init`, `sync`, and `check-theme` are all **real**. `sync` reconciles via a sha256 three-way diff
|
|
129
|
+
(`--check` is a CI drift gate, `--force` overwrites local edits); `check-theme` is the palette
|
|
130
|
+
guard; `doctor` verifies the installed basalt-ui version against the manifest. All via
|
|
131
|
+
`bunx basalt-ui …`.
|
|
132
|
+
- The framework ships **no** icon or notification dep — pass icons as `ReactNode` and wire toasts
|
|
133
|
+
yourself (e.g. `ThemeLabControls`' `copyIcon` / `onCopy`).
|
|
134
|
+
- The framework DOES ship `motion` (motion.dev, formerly framer-motion) as a bundled dependency —
|
|
135
|
+
animated chrome (`ThemeToggle` today) comes for free, no consumer dependency needed. Reach for
|
|
136
|
+
the shared `MOTION_DURATION` / `MOTION_SPRING` tokens for any new animated interaction rather
|
|
137
|
+
than inventing ad hoc durations/easings or a competing animation library.
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: basalt-charts
|
|
3
|
+
description: Add or extend a chart in a basalt-ui app — pick a kind vs go bespoke (Rule of Three), register a consumer series with defineSeries/groupTokens (since VX.series is app-side, not shipped), compose the visx primitives, and respect the @visx-only-in-charts + Mantine-free boundary. Use when adding a new chart, a new metric/series color, or extracting a repeated chart shape into a kind.
|
|
4
|
+
when_to_use: User wants to add a chart, restyle an existing one structurally, introduce a new metric/series and its color, extract a recurring chart shape into a reusable kind, or asks where chart series colors live / how to register them. The how-to companion to /basalt-design (which owns the aesthetic law).
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
`/basalt-charts` is the how-to for the chart system. `/basalt-design` owns the aesthetic law
|
|
8
|
+
(palette, restraint, the theme-lab loop) and the DESIGN.md precedence — read it for "what color /
|
|
9
|
+
how should this look". This skill answers "how do I wire it" with basalt-ui's `./charts` and
|
|
10
|
+
`./tokens` surfaces.
|
|
11
|
+
|
|
12
|
+
## The decision: kind vs bespoke (Rule of Three)
|
|
13
|
+
|
|
14
|
+
Before writing chart code, decide which of three paths you are on:
|
|
15
|
+
|
|
16
|
+
1. **Reuse a shipped kind.** basalt-ui ships `ZonedLine`, `Bars`, `StackedArea`, `Donut`,
|
|
17
|
+
`MultiLine`, `DualPanel`, `Heatmap`. If the shape matches, use it — props are declarative (data,
|
|
18
|
+
width/height, `getX`/`getY` accessors, zones/thresholds/refLines as plain arrays, `seriesLabel`,
|
|
19
|
+
`formatValue`). Done.
|
|
20
|
+
- **`MultiLine`** — N series on a shared y-axis: legend-hover dimming, per-series synced dots,
|
|
21
|
+
dashed companion (MA) lines, per-point markers (PR stars / status dots), zones + refLines,
|
|
22
|
+
fixed or auto domain (also covers z-score/σ charts via a fixed symmetric domain + zero
|
|
23
|
+
refLine). Replaces bespoke multi-line / relative-progression / training-load /
|
|
24
|
+
strength-composite / fitness-trends.
|
|
25
|
+
- **`DualPanel`** — top line-pane + bottom signed-histogram pane sharing ONE x-scale and ONE
|
|
26
|
+
cursor; optional fill-between two top lines, zones, refLines. Replaces bespoke divergence /
|
|
27
|
+
momentum.
|
|
28
|
+
- **`Heatmap`** — category×category intensity grid (`color-mix` alpha), per-cell tooltip,
|
|
29
|
+
optional gradient legend strip. Replaces bespoke time-of-day.
|
|
30
|
+
2. **Extract a new kind (second instance of a pattern).** When you are about to build the _second_
|
|
31
|
+
chart of a shape that has no shipped kind, extract a kind. Don't extract on the first; don't
|
|
32
|
+
wait past the third. A new kind lives in the consumer's chart kinds dir (or, if generic enough
|
|
33
|
+
to promote, gets contributed to basalt-ui `src/charts/kinds/`). Migrate both call sites onto it.
|
|
34
|
+
3. **Stay bespoke (genuinely unique).** A one-off dual-panel shape (e.g. MACD) composes the
|
|
35
|
+
primitives directly in the page's chart file — not in `kinds/`.
|
|
36
|
+
|
|
37
|
+
> Anti-pattern: a single `<Chart type="..." config={...} />` god-component that switches by kind.
|
|
38
|
+
> That is the Recharts trap. Prefer N small kinds. **If a chart doesn't fit the primitives, add a
|
|
39
|
+
> kind — don't loosen the primitives.**
|
|
40
|
+
|
|
41
|
+
A good kind's props: `data`, `width`, `height`, `chartId`, generic `getX`/`getY` accessors, zones /
|
|
42
|
+
thresholds / refLines arrays, `seriesLabel`, `formatValue`, optional `tooltipLabel`. Bespoke escape
|
|
43
|
+
hatches (`renderExtraTooltipRows`) are fine; they must not grow into a god-object config.
|
|
44
|
+
|
|
45
|
+
## Register a consumer series (VX.series is app-side)
|
|
46
|
+
|
|
47
|
+
The framework ships generic primitives and the framework palette (semantic / status / neutral /
|
|
48
|
+
surface) — **but not a domain series tree.** `VX.series` does not exist in basalt-ui; argo's
|
|
49
|
+
`SERIES`/`ACTIVITY`/`USAGE_*` maps stayed app-side. Each consumer rebuilds its own series in **one
|
|
50
|
+
guard-exempt file** (e.g. `src/lib/series.ts`), using the shipped extensibility helpers from
|
|
51
|
+
`basalt-ui/tokens`:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
// src/lib/series.ts — the ONE file exempt from `basalt-ui check-theme` (it IS the palette source)
|
|
55
|
+
import { defineSeries, groupTokens, seriesTokens, buildPaletteCss } from 'basalt-ui/tokens'
|
|
56
|
+
|
|
57
|
+
// 1. Author the per-theme pairs (hue keeps identity, shifts shade across schemes).
|
|
58
|
+
const HEALTH = defineSeries({
|
|
59
|
+
hrv: { light: '#634DBF', dark: '#7C6BD6' }, // violet — lighter on dark to avoid glow
|
|
60
|
+
restingHr: { light: '#C22762', dark: '#E0639A' },
|
|
61
|
+
})
|
|
62
|
+
const WALKING = defineSeries({
|
|
63
|
+
intensityMin: { light: '#3F7D4F', dark: '#5FA372' }, // forest green — muted status hue
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
// 2. Turn the maps into namespaced token refs (var(--vx-health-hrv), ...).
|
|
67
|
+
// seriesTokens(map, prefix?) for a flat namespace; groupTokens(name, map) namespaces under name.
|
|
68
|
+
export const SERIES = {
|
|
69
|
+
...seriesTokens(HEALTH), // → { hrv: 'var(--vx-hrv)', restingHr: 'var(--vx-restingHr)' }
|
|
70
|
+
walking: groupTokens('walking', WALKING), // → { intensityMin: 'var(--vx-walking-intensityMin)', ... }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 3. Feed the same maps into the palette CSS so the vars exist in both schemes.
|
|
74
|
+
export const PALETTE_CSS = buildPaletteCss({
|
|
75
|
+
groups: { health: HEALTH, walking: WALKING },
|
|
76
|
+
derived: ['--vx-hrv-area: 12%'], // optional scheme-independent derived vars
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- `seriesTokens` / `groupTokens` are **exact-keyed**: a typo or a stale key fails `tsc`, so the
|
|
81
|
+
token surface can't silently drift from the palette data.
|
|
82
|
+
- `defineSeries` is the typed authoring entry — it returns the map (sugar; pairs feed both the CSS
|
|
83
|
+
and the tokens).
|
|
84
|
+
- Inject `PALETTE_CSS` once (BasaltProvider injects the framework palette; the consumer appends its
|
|
85
|
+
series CSS — or passes `injectPalette={false}` and head-injects both).
|
|
86
|
+
- Then charts read `SERIES.hrv`, never a hex. This is what keeps `basalt-ui check-theme` green.
|
|
87
|
+
|
|
88
|
+
Theme tuning of these series happens in the theme lab — pass them as `groups` to
|
|
89
|
+
`ThemeLabControls` (see `/basalt-design`).
|
|
90
|
+
|
|
91
|
+
## Compose the primitives (never hand-roll)
|
|
92
|
+
|
|
93
|
+
Every chart — kind or bespoke — composes the shipped primitives. The contract is social and
|
|
94
|
+
lint-backed; it is easier to compose them than to work around them.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import {
|
|
98
|
+
ChartCard,
|
|
99
|
+
ChartLegend,
|
|
100
|
+
AxisBottomDate,
|
|
101
|
+
AxisLeftNumeric,
|
|
102
|
+
HoverOverlay,
|
|
103
|
+
AreaGradient,
|
|
104
|
+
areaFillUrl,
|
|
105
|
+
ChartTooltip,
|
|
106
|
+
TooltipHeader,
|
|
107
|
+
TooltipRow,
|
|
108
|
+
useChartTooltip,
|
|
109
|
+
useHoverSync,
|
|
110
|
+
VX,
|
|
111
|
+
alpha,
|
|
112
|
+
} from 'basalt-ui/charts' // ./charts re-exports the token layer too
|
|
113
|
+
import { SERIES } from '../lib/series'
|
|
114
|
+
|
|
115
|
+
function HrvChart({ data, width, height }: HrvChartProps) {
|
|
116
|
+
const tip = useChartTooltip<HrvPoint>()
|
|
117
|
+
// ... scales ...
|
|
118
|
+
return (
|
|
119
|
+
<ChartCard title="HRV" info="7-day rolling">
|
|
120
|
+
<svg width={width} height={height}>
|
|
121
|
+
<AreaGradient id="hrv" color={SERIES.hrv} />
|
|
122
|
+
{/* ...LinePath fill={areaFillUrl('hrv')} stroke={SERIES.hrv}... */}
|
|
123
|
+
<AxisLeftNumeric scale={yScale} /* tokenized ticks */ />
|
|
124
|
+
<AxisBottomDate scale={xScale} />
|
|
125
|
+
<HoverOverlay {...tip.overlayProps} />
|
|
126
|
+
</svg>
|
|
127
|
+
<ChartLegend entries={[{ label: 'HRV', color: SERIES.hrv, shape: 'line' }]} />
|
|
128
|
+
<ChartTooltip {...tip.tooltipProps}>
|
|
129
|
+
<TooltipHeader>{/* date */}</TooltipHeader>
|
|
130
|
+
<TooltipRow swatch={SERIES.hrv} label="HRV" value={/* ... */} />
|
|
131
|
+
</ChartTooltip>
|
|
132
|
+
</ChartCard>
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Never substitute: hand-rolled legend markup, a raw `<AxisLeft>`/`<AxisBottom>`, a direct
|
|
138
|
+
`@visx/tooltip` import, or an `rgba()` fill. Use `ChartLegend`, the tokenized axes, `ChartTooltip`,
|
|
139
|
+
and `alpha(token, a)`. Sparklines (`charts/sparklines/`) are the one exemption from the
|
|
140
|
+
Card/Legend/Tooltip composition — but they still use `VX.*` tokens.
|
|
141
|
+
|
|
142
|
+
## Cross-chart cursor sync
|
|
143
|
+
|
|
144
|
+
Wrap a group of date-aligned charts in `ChartHoverSync` (from `basalt-ui/charts`) to activate
|
|
145
|
+
cross-chart cursor sync — hovering one chart casts a ghost crosshair on every sibling. Without the
|
|
146
|
+
provider, `useHoverSync` runs per-chart only (and logs a dev warning):
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { ChartHoverSync } from 'basalt-ui/charts'
|
|
150
|
+
;<ChartHoverSync>
|
|
151
|
+
<ChartCard>…</ChartCard>
|
|
152
|
+
<ChartCard>…</ChartCard>
|
|
153
|
+
</ChartHoverSync>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Respect the boundary (oxlint-enforced)
|
|
157
|
+
|
|
158
|
+
- **`@visx/*` may only be imported inside chart files.** The shipped consumer oxlint preset bans
|
|
159
|
+
direct `@visx/*` outside `**/charts/**`. Need a raw visx primitive for a bespoke chart? Pull it
|
|
160
|
+
from basalt-ui's curated re-export in `basalt-ui/charts`, or keep the chart under a charts dir.
|
|
161
|
+
- **`./charts` and `./tokens` are Mantine-free** — zero `@mantine/*` imports. Keep new chart code
|
|
162
|
+
free of Mantine so a charts/tokens-only consumer never pulls Mantine in.
|
|
163
|
+
- **No raw color literals** anywhere except the one guard-exempt series file (and a deliberate
|
|
164
|
+
`theme-allow` line). `basalt-ui check-theme` is the teeth; run it before committing.
|
|
165
|
+
- **No raw visx axes.** `basalt-ui check-theme`'s `raw-visx-axis` guard fails the build on a raw
|
|
166
|
+
`<AxisLeft>`/`<AxisBottom>`/`<AxisRight>` inside any `/charts/` file — use the tokenized
|
|
167
|
+
`AxisLeftNumeric` / `AxisRightNumeric` / `AxisBottomDate` (escape via `theme-allow`).
|
|
168
|
+
|
|
169
|
+
## Checklist for a new chart
|
|
170
|
+
|
|
171
|
+
- Picked the right path: reused a kind / extracted on the second instance / stayed bespoke for a
|
|
172
|
+
true one-off.
|
|
173
|
+
- Any new metric color is a `{ light, dark }` pair in the consumer series file, exposed via
|
|
174
|
+
`seriesTokens`/`groupTokens`, and wired into `PALETTE_CSS` via `buildPaletteCss`.
|
|
175
|
+
- Charts read `SERIES.*` / `VX.*` — `basalt-ui check-theme` green, zero raw hex.
|
|
176
|
+
- Composed `ChartCard` / `ChartLegend` / tokenized axes / `ChartTooltip` — no hand-rolled markup,
|
|
177
|
+
no direct `@visx/tooltip`.
|
|
178
|
+
- `@visx/*` stays inside chart files; chart code imports no `@mantine/*`.
|
|
179
|
+
- Tuned both schemes via the theme lab where the hue needed it (defer to `/basalt-design`).
|