@designtools/tokens 0.13.0 → 0.15.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/dist/index.d.ts CHANGED
@@ -192,7 +192,7 @@ interface TokenSystem {
192
192
  p3?: GamutTokens;
193
193
  }
194
194
  /**
195
- * Where a ground's tokens come from, for its text and for everything else (its tint).
195
+ * Where a ground's tokens come from: its text, its lines (its tint) and its panels.
196
196
  * `page`: the page's own tokens of the ground's polarity, wherever they read; `own`: steps on
197
197
  * the ground's own ramp, searched to their floors; or one colour for all of them: `white`,
198
198
  * `black`, or a step written `<ramp>-<step>` (`sage-100`).
@@ -213,8 +213,10 @@ type GroundAction = "page" | "own" | GroundColour | `${GroundColour}/${GroundCol
213
213
  interface GroundSpec {
214
214
  ramp: string;
215
215
  step: ShadeNumber;
216
- /** Lines, panels, the card, the input edge, the ring and the buttons. Default: `own` */
216
+ /** Lines: borders, the input edge, the ring, and the buttons with them. Default: `own` */
217
217
  tint?: GroundFill;
218
+ /** Panels: the card (`--surface`) and the quiet panel (`--neutral-subdued`). Default: the page's under `tint: "page"`, else `own` */
219
+ panels?: GroundFill;
218
220
  /** Body and secondary text. Default: `page` */
219
221
  text?: GroundFill;
220
222
  /** The main button. Default: unset, following the tint */
@@ -240,6 +242,7 @@ interface GroundTokens {
240
242
  /** Whether the ground reads as light (dark text) or dark (light text): which page mode it borrows */
241
243
  polarity: "light" | "dark";
242
244
  tint: GroundFill;
245
+ panels: GroundFill;
243
246
  text: GroundFill;
244
247
  /** Where its main button comes from, when it doesn't follow the tint */
245
248
  action?: GroundAction;
@@ -446,8 +449,10 @@ interface GenerationOptions {
446
449
  * decorative, or `primary` for a brand band.
447
450
  */
448
451
  grounds?: Record<string, GroundSpec>;
449
- /** Where every ground's tint comes from, unless it says otherwise. Default `own` */
452
+ /** Where every ground's lines come from, unless it says otherwise. Default `own` */
450
453
  groundTint?: GroundFill;
454
+ /** Where every ground's panels come from, unless it says otherwise. Default: as its lines, the page's or `own` */
455
+ groundPanels?: GroundFill;
451
456
  /** Where every ground's text comes from, unless it says otherwise. Default `page` */
452
457
  groundText?: GroundFill;
453
458
  /** Where every ground's main button comes from, unless it says otherwise. Default: the tint's */
@@ -527,6 +532,7 @@ interface SavedConfig {
527
532
  pageSurfaces?: GenerationOptions["pageSurfaces"];
528
533
  grounds?: GenerationOptions["grounds"];
529
534
  groundTint?: GroundFill;
535
+ groundPanels?: GroundFill;
530
536
  groundText?: GroundFill;
531
537
  groundAction?: GroundAction;
532
538
  shadeOverrides: SemanticShadeOverrides;
@@ -1073,14 +1079,15 @@ declare function snapShade(shade: ShadeNumber, active: readonly ShadeNumber[]):
1073
1079
  * Re-anchor a lightness-factor table so the seed lands on `seedShade`.
1074
1080
  *
1075
1081
  * The table is signed: positive entries are a fraction of the headroom above the
1076
- * seed, negative a fraction of the headroom below, and the anchor is 0. Moving
1077
- * the anchor changes how many steps sit either side of it, so each side's curve
1078
- * is resampled onto its new slot count. That keeps the ramp's perceptual shape —
1079
- * gentle at the light end, larger jumps at the dark end for text contrast —
1080
- * rather than stretching one uniform gradient.
1082
+ * seed, negative a fraction of the headroom below, and the anchor is 0. Moved off
1083
+ * 500, each step keeps the spacing a typical 500 ramp has around that step, rather
1084
+ * than the spacing it has around 500: a navy at 900 takes a 900's neighbours, an
1085
+ * 800 a little lighter, not a 500's 400, a third of the way to white. Stretching
1086
+ * the 500 curve over the new slots did that, so the step next to a deep seed
1087
+ * always jumped 38% of the way to white, whatever step the seed was on.
1081
1088
  *
1082
- * A side left with a single slot reaches that curve's extreme, since that one
1083
- * step stands in for the whole remaining range.
1089
+ * The step at each end keeps the table's extreme (the palest and deepest factor),
1090
+ * so the ends still reach the lightness range; a 500 seed gets the table unchanged.
1084
1091
  */
1085
1092
  declare function reanchorFactors(base: readonly number[], seedShade: ShadeNumber): number[];
1086
1093
  /**
@@ -1162,8 +1169,10 @@ declare function isAPCAAvailable(): boolean;
1162
1169
  * a ground doesn't change is already right inside it in either mode. The ground's own scope then
1163
1170
  * writes only what differs, every value a ramp step (or white or black), never a computed colour.
1164
1171
  *
1165
- * What differs comes from two choices per ground:
1166
- * - tint, for lines, panels, the card, the input edge, the ring and the buttons;
1172
+ * What differs comes from three choices per ground:
1173
+ * - tint, for its lines: borders, the input edge and the ring, and the buttons with them;
1174
+ * - panels, for the card and the quiet panel (`--neutral-subdued`); unset, they follow the
1175
+ * lines, the page's with the page's lines and the ground's own otherwise;
1167
1176
  * - text, for body and secondary text.
1168
1177
  * Each is `page` (the page's tokens, where they read), `own` (steps on the ground's ramp, each
1169
1178
  * searched to its floor) or one colour (`white`, `black`, `sage-100`). Any other colour (accent,
@@ -1255,6 +1264,47 @@ interface ContractBreak {
1255
1264
  /** Every step whose promise differs between colours, light to dark. Empty when every step means the same everywhere. */
1256
1265
  declare function stepContract(palette: PrimitivePalette): ContractBreak[];
1257
1266
 
1267
+ /**
1268
+ * The one sanctioned place to override the generated colour: a project's `tokens.local.css`, loaded
1269
+ * straight after `tokens.css`. It exists for the few values a flag or the seed can't say, and it is held
1270
+ * to the system's own terms, so every project overrides the same way:
1271
+ *
1272
+ * - selectors are the generator's own: `:root`, `[data-theme="light"]`, `[data-theme="dark"]`, `.dark`,
1273
+ * and `[data-surface="<ground>"]` (or `"canvas"`, the page), alone or in a list; no at-rules;
1274
+ * - names are tokens the generator writes; never a `--color-*` alias or ramp step (a ramp step is moved
1275
+ * with shade overrides, a token by setting the token itself), and never a new name;
1276
+ * - values point at the system: `var()` references, a ramp step nudged with relative colour
1277
+ * (`oklch(from var(--color-…) …)`) or mixed (`color-mix()`); never a literal colour.
1278
+ *
1279
+ * `checkLocalOverrides` reports every override as pinned by hand and re-checks contrast for each pair an
1280
+ * override touches, so a pinned surface can't quietly fail its text.
1281
+ */
1282
+ interface LocalOverride {
1283
+ selector: string;
1284
+ name: string;
1285
+ value: string;
1286
+ }
1287
+ interface LocalProblem {
1288
+ kind: "selector" | "name" | "value" | "contrast" | "syntax";
1289
+ message: string;
1290
+ }
1291
+ interface LocalReport {
1292
+ overrides: LocalOverride[];
1293
+ problems: LocalProblem[];
1294
+ }
1295
+ declare const TARGETS: {
1296
+ readonly "aa-large": 3;
1297
+ readonly aa: 4.5;
1298
+ readonly aaa: 7;
1299
+ };
1300
+ /**
1301
+ * Check a project's overrides against the system and against contrast. `generated` is the tokens file
1302
+ * the generator writes (css or tailwind-v4); `local` is the override file.
1303
+ */
1304
+ declare function checkLocalOverrides(generated: string, local: string, target?: keyof typeof TARGETS): LocalReport;
1305
+ /** The file `init` writes: empty, with its rules at the head. */
1306
+ declare const LOCAL_TEMPLATE = "/* tokens.local.css: the project's overrides of the generated colour, loaded after tokens.css.\n Most changes are an input instead (a flag, the seed, shade overrides): use this only for a value\n the generator can't say. generate-tokens --local checks it against the system:\n - selectors: :root, [data-theme=\"light\"], [data-theme=\"dark\"], .dark, [data-surface=\"<ground>\"];\n - names: tokens the generator writes (never a --color- alias or ramp step, never a new name);\n - values: var() references, or a ramp step nudged with oklch(from var(--color-\u2026) \u2026); never a literal colour.\n Each override is reported as pinned by hand, and the pairs it touches are re-checked for contrast. */\n";
1307
+
1258
1308
  /**
1259
1309
  * The non-colour scale: space, size, type, radius, shadow, motion, screen sizes and widths. The colour
1260
1310
  * generator works a palette out from a seed; the scale has no seed, so this is a set of defaults, written
@@ -1296,5 +1346,29 @@ type ScaleOverride = string | {
1296
1346
  declare function applyScaleOverrides(tiers: ScaleTier[], overrides: Record<string, ScaleOverride>): ScaleTier[];
1297
1347
  type ScaleFormat = "css" | "tailwind-v4" | "tailwind-v3" | "dtcg" | "json";
1298
1348
  declare function exportScale(tiers: ScaleTier[], format: ScaleFormat, header?: string): string;
1349
+ /**
1350
+ * The mark an owned scale carries: written once by `generate-tokens scale --init` (or `init`), then the
1351
+ * project's file, edited by hand and never regenerated. The values are the project's; the names are the
1352
+ * contract, which `verifyScale` checks.
1353
+ */
1354
+ declare const OWNED_SCALE_MARK = "@designtools/tokens scale";
1355
+ /** The header an owned scale opens with. */
1356
+ declare function ownedScaleHeader(version: string): string;
1357
+ /** Whether a stylesheet is an owned scale. */
1358
+ declare function isOwnedScale(css: string): boolean;
1359
+ interface ScaleVerdict {
1360
+ /** Names the scale promises that the file no longer has. */
1361
+ missing: string[];
1362
+ /** Names that belong to no tier: a second system beside the scale. */
1363
+ strays: string[];
1364
+ /** Names the project added inside a tier: its own steps, which are fine. */
1365
+ own: string[];
1366
+ }
1367
+ /**
1368
+ * Check a scale file's names against the contract: every default name is still there, and every
1369
+ * name the project added sits inside a tier's namespace. Values are never compared; they are the
1370
+ * project's. Reads the custom properties declared anywhere in the file.
1371
+ */
1372
+ declare function verifyScale(css: string): ScaleVerdict;
1299
1373
 
1300
- export { ALIAS_PAIRS, type APCAContrastResult, APCAUnavailableError, type BrandColors, type CVDType, type ChromaProfile, type ChromaShape, type ColorFormat, type ColorScale, type ContractBreak, type ContrastAlgorithm, type ContrastTarget, DEFAULT_NEUTRAL_COLOR, DEFAULT_SEED_SHADE, type Declaration, type ExportFormat, type ExportOptions, type ExtendedSemanticColor, type FamilyShape, type ForegroundRef, GENERATOR_NAME, GROUND_BASE_TOKENS, GROUND_COLOR_PARTS, GROUND_SELECTOR, type Gamut, type GamutTokens, type GenerationOptions, type GroundAction, type GroundColour, type GroundFill, type GroundRef, type GroundSpec, type GroundTokens, type HueDrift, type LightnessStrategy, type MergeResult, type PageContrast, type PageSurface, type PaletteOptions, type PrimitivePalette, type Provenance, SECTIONED_FORMATS, SHADE_PRESETS, type SavedConfig, type ScaleFormat, type ScaleOptions, type ScaleOverride, type ScaleTier, type ScaleTierId, type ScaleToken, type SeedFile, type SelectedTokens, type SemanticColorPair, type SemanticGamuts, type SemanticShadeOverrides, type SemanticTokens, type ShadeNumber, type SliceDiff, type SurfaceRef, type SurfaceShadeOverrides, type SurfaceTokens, TAILWIND_SHADES, TOKEN_SECTIONS, type TokenSection, type TokenSystem, type UsageReport, type UsageVerdict, type UtilityShadeOverrides, type UtilityTokens, VALID_SHADES, type VariantShadeOverrides, type WCAGContrastResult, WIDE_GAMUT_QUERY, adjustChroma, adjustLightness, aliasOf, applyScaleOverrides, checkRampChroma, checkSemanticContrast, checkSemanticContrastAPCA, checkSurfaceContrast, chromaShadeFor, classifyAPCALevel, computeAccessibilityScore, defaultScale, diffSlice, exportScale, exportToCss, exportToDtcg, exportToTailwindV3, exportToTailwindV4, exportTokens, externalReferences, familiesOf, familySeedShade, findContrastingColorAPCA, fingerprint, formatColorAs, formatColorShort, formatOklchInGamut, generateColorScale, generateColorScaleAPCA, generateGroundTokens, generatePrimitivePalette, generateSemanticTokens, generateSurfaceTokens, generateTokens, generateUtilityTokens, getAPCAContrast, getContrastRatio, getOklchString, getRelativeLuminance, getShade, groundTokenNames, isAPCAAvailable, isInGamut, meetsWCAG_AA, meetsWCAG_AAA, mergeSlice, modeSelectors, oklchToHex, parseProvenance, parseToOklch, provenanceComment, rangeOf, readDeclarations, reanchorFactors, reservedSurfaceNames, resolveShades, seedFingerprint, selectTokenSections, serialiseUsage, simulateCVD, snapShade, stableStringify, stepContract, suggestStep, tokenFamilies, usageReport, withJsonProvenance };
1374
+ export { ALIAS_PAIRS, type APCAContrastResult, APCAUnavailableError, type BrandColors, type CVDType, type ChromaProfile, type ChromaShape, type ColorFormat, type ColorScale, type ContractBreak, type ContrastAlgorithm, type ContrastTarget, DEFAULT_NEUTRAL_COLOR, DEFAULT_SEED_SHADE, type Declaration, type ExportFormat, type ExportOptions, type ExtendedSemanticColor, type FamilyShape, type ForegroundRef, GENERATOR_NAME, GROUND_BASE_TOKENS, GROUND_COLOR_PARTS, GROUND_SELECTOR, type Gamut, type GamutTokens, type GenerationOptions, type GroundAction, type GroundColour, type GroundFill, type GroundRef, type GroundSpec, type GroundTokens, type HueDrift, LOCAL_TEMPLATE, type LightnessStrategy, type LocalOverride, type LocalProblem, type LocalReport, type MergeResult, OWNED_SCALE_MARK, type PageContrast, type PageSurface, type PaletteOptions, type PrimitivePalette, type Provenance, SECTIONED_FORMATS, SHADE_PRESETS, type SavedConfig, type ScaleFormat, type ScaleOptions, type ScaleOverride, type ScaleTier, type ScaleTierId, type ScaleToken, type ScaleVerdict, type SeedFile, type SelectedTokens, type SemanticColorPair, type SemanticGamuts, type SemanticShadeOverrides, type SemanticTokens, type ShadeNumber, type SliceDiff, type SurfaceRef, type SurfaceShadeOverrides, type SurfaceTokens, TAILWIND_SHADES, TOKEN_SECTIONS, type TokenSection, type TokenSystem, type UsageReport, type UsageVerdict, type UtilityShadeOverrides, type UtilityTokens, VALID_SHADES, type VariantShadeOverrides, type WCAGContrastResult, WIDE_GAMUT_QUERY, adjustChroma, adjustLightness, aliasOf, applyScaleOverrides, checkLocalOverrides, checkRampChroma, checkSemanticContrast, checkSemanticContrastAPCA, checkSurfaceContrast, chromaShadeFor, classifyAPCALevel, computeAccessibilityScore, defaultScale, diffSlice, exportScale, exportToCss, exportToDtcg, exportToTailwindV3, exportToTailwindV4, exportTokens, externalReferences, familiesOf, familySeedShade, findContrastingColorAPCA, fingerprint, formatColorAs, formatColorShort, formatOklchInGamut, generateColorScale, generateColorScaleAPCA, generateGroundTokens, generatePrimitivePalette, generateSemanticTokens, generateSurfaceTokens, generateTokens, generateUtilityTokens, getAPCAContrast, getContrastRatio, getOklchString, getRelativeLuminance, getShade, groundTokenNames, isAPCAAvailable, isInGamut, isOwnedScale, meetsWCAG_AA, meetsWCAG_AAA, mergeSlice, modeSelectors, oklchToHex, ownedScaleHeader, parseProvenance, parseToOklch, provenanceComment, rangeOf, readDeclarations, reanchorFactors, reservedSurfaceNames, resolveShades, seedFingerprint, selectTokenSections, serialiseUsage, simulateCVD, snapShade, stableStringify, stepContract, suggestStep, tokenFamilies, usageReport, verifyScale, withJsonProvenance };
package/dist/index.js CHANGED
@@ -7,6 +7,8 @@ import {
7
7
  GROUND_BASE_TOKENS,
8
8
  GROUND_COLOR_PARTS,
9
9
  GROUND_SELECTOR,
10
+ LOCAL_TEMPLATE,
11
+ OWNED_SCALE_MARK,
10
12
  SECTIONED_FORMATS,
11
13
  SHADE_PRESETS,
12
14
  TAILWIND_SHADES,
@@ -17,6 +19,7 @@ import {
17
19
  adjustLightness,
18
20
  aliasOf,
19
21
  applyScaleOverrides,
22
+ checkLocalOverrides,
20
23
  checkRampChroma,
21
24
  checkSemanticContrast,
22
25
  checkSemanticContrastAPCA,
@@ -56,11 +59,13 @@ import {
56
59
  groundTokenNames,
57
60
  isAPCAAvailable,
58
61
  isInGamut,
62
+ isOwnedScale,
59
63
  meetsWCAG_AA,
60
64
  meetsWCAG_AAA,
61
65
  mergeSlice,
62
66
  modeSelectors,
63
67
  oklchToHex,
68
+ ownedScaleHeader,
64
69
  parseProvenance,
65
70
  parseToOklch,
66
71
  provenanceComment,
@@ -79,8 +84,9 @@ import {
79
84
  suggestStep,
80
85
  tokenFamilies,
81
86
  usageReport,
87
+ verifyScale,
82
88
  withJsonProvenance
83
- } from "./chunk-HK7ME2YV.js";
89
+ } from "./chunk-FY6LQL2A.js";
84
90
  export {
85
91
  ALIAS_PAIRS,
86
92
  APCAUnavailableError,
@@ -90,6 +96,8 @@ export {
90
96
  GROUND_BASE_TOKENS,
91
97
  GROUND_COLOR_PARTS,
92
98
  GROUND_SELECTOR,
99
+ LOCAL_TEMPLATE,
100
+ OWNED_SCALE_MARK,
93
101
  SECTIONED_FORMATS,
94
102
  SHADE_PRESETS,
95
103
  TAILWIND_SHADES,
@@ -100,6 +108,7 @@ export {
100
108
  adjustLightness,
101
109
  aliasOf,
102
110
  applyScaleOverrides,
111
+ checkLocalOverrides,
103
112
  checkRampChroma,
104
113
  checkSemanticContrast,
105
114
  checkSemanticContrastAPCA,
@@ -139,11 +148,13 @@ export {
139
148
  groundTokenNames,
140
149
  isAPCAAvailable,
141
150
  isInGamut,
151
+ isOwnedScale,
142
152
  meetsWCAG_AA,
143
153
  meetsWCAG_AAA,
144
154
  mergeSlice,
145
155
  modeSelectors,
146
156
  oklchToHex,
157
+ ownedScaleHeader,
147
158
  parseProvenance,
148
159
  parseToOklch,
149
160
  provenanceComment,
@@ -162,5 +173,6 @@ export {
162
173
  suggestStep,
163
174
  tokenFamilies,
164
175
  usageReport,
176
+ verifyScale,
165
177
  withJsonProvenance
166
178
  };
@@ -101,7 +101,9 @@ export function describeChanges(before, now) {
101
101
  if (!same(before.groundText, now.groundText))
102
102
  out.push(`every ground's text ${now.groundText ?? "page"}`);
103
103
  if (!same(before.groundTint, now.groundTint))
104
- out.push(`every ground's lines and panels ${now.groundTint ?? "own"}`);
104
+ out.push(`every ground's lines ${now.groundTint ?? "own"}`);
105
+ if (!same(before.groundPanels, now.groundPanels))
106
+ out.push(`every ground's panels ${now.groundPanels ?? "as its lines"}`);
105
107
  if (!same(before.groundAction, now.groundAction))
106
108
  out.push(`every ground's button ${now.groundAction ?? "as its lines"}`);
107
109
  const grounds = new Set([...Object.keys(before.grounds ?? {}), ...Object.keys(now.grounds ?? {})]);
@@ -120,7 +122,9 @@ export function describeChanges(before, now) {
120
122
  if (a.text !== b.text)
121
123
  out.push(`${name} ground's text ${b.text ?? "as every ground's"}`);
122
124
  if (a.tint !== b.tint)
123
- out.push(`${name} ground's lines and panels ${b.tint ?? "as every ground's"}`);
125
+ out.push(`${name} ground's lines ${b.tint ?? "as every ground's"}`);
126
+ if (a.panels !== b.panels)
127
+ out.push(`${name} ground's panels ${b.panels ?? "as every ground's"}`);
124
128
  if (a.action !== b.action)
125
129
  out.push(`${name} ground's button ${b.action ?? "as every ground's"}`);
126
130
  }
@@ -8,7 +8,7 @@ import { type ReactNode } from "react";
8
8
  import { type Edit } from "./colour-controls.js";
9
9
  /** A panel set into the page, rather than a popover: the same look as the bar's. */
10
10
  export declare const PANEL = "flex min-w-0 flex-col gap-3 rounded-xl border border-edge bg-page p-3.5 text-ink shadow-sm";
11
- /** The defaults every ground starts from: where its text, and its lines and panels, come from. */
11
+ /** The defaults every ground starts from: where its text, its lines and its panels come from. */
12
12
  export declare function GroundDefaults({ edit }: {
13
13
  edit: Edit;
14
14
  }): import("react").JSX.Element;
@@ -10,6 +10,7 @@ import { ColorInput, Field, Row, Segmented, Select, Switch } from "@designtools/
10
10
  import { Plus, RotateCcw, Trash2 } from "lucide-react";
11
11
  import { useState } from "react";
12
12
  import { ACTION, Hint, SystemShape } from "./colour-controls.js";
13
+ import { panelsFollowing } from "./seed.js";
13
14
  const SHADES = VALID_SHADES.map((s) => ({ value: String(s), label: String(s) }));
14
15
  const NAME = /^[a-z][a-z0-9-]*$/;
15
16
  const LABEL = "text-[10px] font-semibold tracking-wide text-ink3 uppercase";
@@ -25,14 +26,14 @@ function rampsOf(edit) {
25
26
  /* Where a ground's text and lines come from */
26
27
  const FILL_WORDS = { own: "Own", page: "Page", white: "White", black: "Black", step: "A step" };
27
28
  /**
28
- * One of a ground's two choices, text or lines and panels: its own ramp, the page's, white,
29
+ * One of a ground's choices, its text, its lines or its panels: its own ramp, the page's, white,
29
30
  * black, or one step of any ramp. Shown as what applies, the default included.
30
31
  */
31
- function FillPicker({ label, hint, value, fallback, ramps, onChange, }) {
32
+ function FillPicker({ label, hint, value, fallback, keepsChoice = false, ramps, onChange, }) {
32
33
  const shown = value ?? fallback;
33
34
  const step = /^([a-z][\w-]*)-(\d+)$/.exec(shown);
34
35
  const kind = step ? "step" : shown;
35
- const choose = (next) => onChange(next === fallback ? undefined : next);
36
+ const choose = (next) => onChange(next === fallback && !keepsChoice ? undefined : next);
36
37
  return (_jsx(Field, { label: label, actions: _jsx(Hint, { text: hint }), children: (id) => (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Segmented, { labelledBy: id, value: kind, onChange: (v) => choose(v === "step" ? `${ramps[0] ?? "neutral"}-500` : v), options: ["own", "page", "white", "black", "step"].map((v) => ({ value: v, label: FILL_WORDS[v] })) }), step && (_jsxs(Row, { children: [_jsx(Select, { label: `${label}: ramp`, value: step[1], options: ramps.map((r) => ({ value: r, label: r })), onChange: (r) => choose(`${r}-${step[2]}`) }), _jsx(Select, { label: `${label}: step`, value: step[2], options: SHADES, onChange: (s) => choose(`${step[1]}-${s}`) })] }))] })) }));
37
38
  }
38
39
  const ACTION_WORDS = { tint: "As the lines", page: "Page", own: "Own", colour: "A colour" };
@@ -52,12 +53,13 @@ function ActionPicker({ value, fallback, ramps, onChange, }) {
52
53
  return (_jsx(Field, { label: "Button", actions: _jsx(Hint, { text: ACTION_HINT }), children: (id) => (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Segmented, { labelledBy: id, value: kind, onChange: (v) => (v === "tint" ? choose(undefined) : v === "colour" ? colour("neutral-950") : choose(v)), options: ["tint", "page", "own", "colour"].map((v) => ({ value: v, label: ACTION_WORDS[v] })) }), step && (_jsxs(_Fragment, { children: [_jsxs(Row, { children: [_jsx(Select, { label: "Button: ramp", value: step[1], options: ramps.map((r) => ({ value: r, label: r })), onChange: (r) => colour(`${r}-${step[2]}`, label) }), _jsx(Select, { label: "Button: step", value: step[2], options: SHADES, onChange: (n) => colour(`${step[1]}-${n}`, label) })] }), _jsxs(Row, { children: [_jsx(Select, { label: "Button label: ramp", value: labelStep?.[1] ?? "measured", options: [{ value: "measured", label: "Label measured" }, ...ramps.map((r) => ({ value: r, label: `Label ${r}` }))], onChange: (r) => colour(fill, r === "measured" ? undefined : `${r}-${labelStep?.[2] ?? "400"}`) }), labelStep && _jsx(Select, { label: "Button label: step", value: labelStep[2], options: SHADES, onChange: (n) => colour(fill, `${labelStep[1]}-${n}`) })] })] }))] })) }));
53
54
  }
54
55
  const TEXT_HINT = "The text on it. Page: the page's own text, so every ground reads the same. Own: a step of the ground's ramp, its hue. Or one colour for all of it.";
55
- const TINT_HINT = "Lines, input edges, the focus ring, cards and the buttons (unless the button says otherwise). Own: steps of the ground's ramp, in its hue. Page: the page's own lines and panels. Or one colour for every line.";
56
- /** The defaults every ground starts from: where its text, and its lines and panels, come from. */
56
+ const TINT_HINT = "Borders, input edges, the focus ring and the buttons (unless the button says otherwise). Own: steps of the ground's ramp, in its hue. Page: the page's own lines. Or one colour for every line.";
57
+ const PANELS_HINT = "Cards and quiet panels. Unset, they follow the lines: the page's with the page's lines, else the ground's own. Own: a step off the ground on its ramp. Page: the page's cards. Or one colour for both.";
58
+ /** The defaults every ground starts from: where its text, its lines and its panels come from. */
57
59
  export function GroundDefaults({ edit }) {
58
60
  const { seed, set } = edit;
59
61
  const ramps = rampsOf(edit);
60
- return (_jsxs(_Fragment, { children: [_jsxs("p", { className: `flex items-center gap-1.5 ${LABEL}`, children: ["Every ground ", _jsx(Hint, { text: "What each ground starts from. A ground can choose otherwise for itself." })] }), _jsx(FillPicker, { label: "Text", hint: TEXT_HINT, value: seed.groundText, fallback: "page", ramps: ramps, onChange: (v) => set({ groundText: v }) }), _jsx(FillPicker, { label: "Lines and panels", hint: TINT_HINT, value: seed.groundTint, fallback: "own", ramps: ramps, onChange: (v) => set({ groundTint: v }) })] }));
62
+ return (_jsxs(_Fragment, { children: [_jsxs("p", { className: `flex items-center gap-1.5 ${LABEL}`, children: ["Every ground ", _jsx(Hint, { text: "What each ground starts from. A ground can choose otherwise for itself." })] }), _jsx(FillPicker, { label: "Text", hint: TEXT_HINT, value: seed.groundText, fallback: "page", ramps: ramps, onChange: (v) => set({ groundText: v }) }), _jsx(FillPicker, { label: "Lines", hint: TINT_HINT, value: seed.groundTint, fallback: "own", ramps: ramps, onChange: (v) => set({ groundTint: v }) }), _jsx(FillPicker, { label: "Panels", hint: PANELS_HINT, value: seed.groundPanels, fallback: panelsFollowing(seed.groundTint ?? "own"), keepsChoice: true, ramps: ramps, onChange: (v) => set({ groundPanels: v }) })] }));
61
63
  }
62
64
  /** One ground's settings, set into the page under its specimen: its colour and step, its text, its lines. */
63
65
  export function GroundControls({ name, edit }) {
@@ -69,7 +71,7 @@ export function GroundControls({ name, edit }) {
69
71
  return null;
70
72
  const write = (patch) => {
71
73
  const next = { ...spec, ...patch };
72
- for (const k of ["tint", "text", "action"])
74
+ for (const k of ["tint", "panels", "text", "action"])
73
75
  if (next[k] === undefined)
74
76
  delete next[k];
75
77
  set({ grounds: { ...grounds, [name]: next } });
@@ -79,7 +81,7 @@ export function GroundControls({ name, edit }) {
79
81
  set({ grounds: Object.keys(rest).length ? rest : undefined });
80
82
  };
81
83
  const made = system?.grounds?.[name];
82
- return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "grid grid-cols-[repeat(auto-fit,minmax(13rem,1fr))] gap-4", children: [_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(Field, { label: "Painted", actions: _jsx(Hint, { text: "The ramp and the step it's painted. The same in light and dark mode." }), children: (id) => (_jsxs(Row, { children: [_jsx(Select, { labelledBy: id, value: spec.ramp, options: ramps.map((r) => ({ value: r, label: r })), onChange: (ramp) => write({ ramp }) }), _jsx(Select, { label: "Step", value: String(spec.step), options: SHADES, onChange: (s) => write({ step: Number(s) }) })] })) }), _jsxs("button", { type: "button", onClick: remove, className: ACTION, children: [_jsx(Trash2, { "aria-hidden": true, width: 13, height: 13 }), " Remove ", name] })] }), _jsx(FillPicker, { label: "Text", hint: TEXT_HINT, value: spec.text, fallback: seed.groundText ?? "page", ramps: ramps, onChange: (text) => write({ text }) }), _jsx(FillPicker, { label: "Lines and panels", hint: TINT_HINT, value: spec.tint, fallback: seed.groundTint ?? "own", ramps: ramps, onChange: (tint) => write({ tint }) }), _jsx(ActionPicker, { value: spec.action, fallback: seed.groundAction, ramps: ramps, onChange: (action) => write({ action }) })] }), made?.notes.length ? (_jsx("ul", { className: "flex flex-col gap-0.5 border-t border-edge pt-2 text-[11px] leading-snug text-ink2", children: made.notes.map((n) => (_jsx("li", { children: n }, n))) })) : null] }));
84
+ return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "grid grid-cols-[repeat(auto-fit,minmax(13rem,1fr))] gap-4", children: [_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(Field, { label: "Painted", actions: _jsx(Hint, { text: "The ramp and the step it's painted. The same in light and dark mode." }), children: (id) => (_jsxs(Row, { children: [_jsx(Select, { labelledBy: id, value: spec.ramp, options: ramps.map((r) => ({ value: r, label: r })), onChange: (ramp) => write({ ramp }) }), _jsx(Select, { label: "Step", value: String(spec.step), options: SHADES, onChange: (s) => write({ step: Number(s) }) })] })) }), _jsxs("button", { type: "button", onClick: remove, className: ACTION, children: [_jsx(Trash2, { "aria-hidden": true, width: 13, height: 13 }), " Remove ", name] })] }), _jsx(FillPicker, { label: "Text", hint: TEXT_HINT, value: spec.text, fallback: seed.groundText ?? "page", ramps: ramps, onChange: (text) => write({ text }) }), _jsx(FillPicker, { label: "Lines", hint: TINT_HINT, value: spec.tint, fallback: seed.groundTint ?? "own", ramps: ramps, onChange: (tint) => write({ tint }) }), _jsx(FillPicker, { label: "Panels", hint: PANELS_HINT, value: spec.panels, fallback: seed.groundPanels ?? panelsFollowing(spec.tint ?? seed.groundTint ?? "own"), keepsChoice: !seed.groundPanels, ramps: ramps, onChange: (panels) => write({ panels }) }), _jsx(ActionPicker, { value: spec.action, fallback: seed.groundAction, ramps: ramps, onChange: (action) => write({ action }) })] }), made?.notes.length ? (_jsx("ul", { className: "flex flex-col gap-0.5 border-t border-edge pt-2 text-[11px] leading-snug text-ink2", children: made.notes.map((n) => (_jsx("li", { children: n }, n))) })) : null] }));
83
85
  }
84
86
  /** A new ground: a name, the ramp it's painted and the step. */
85
87
  export function AddGround({ edit }) {
@@ -1,4 +1,4 @@
1
1
  export type { ProjectSeed } from "./next.js";
2
- export { generateFromSeed, groundChoices, groundPreviewCss, mergeSeed, type OutputFlags, optionsFromSeed, type ParsedCommand, parseCommand, seedCommand, seedJson, splitCommand, studioCss } from "./seed.js";
2
+ export { generateFromSeed, groundChoices, groundPreviewCss, mergeSeed, panelsFollowing, type OutputFlags, optionsFromSeed, type ParsedCommand, parseCommand, seedCommand, seedJson, splitCommand, studioCss } from "./seed.js";
3
3
  export { ColourGenerator } from "./studio.js";
4
4
  export { TokenStudio } from "./studio.js";
@@ -1,3 +1,3 @@
1
- export { generateFromSeed, groundChoices, groundPreviewCss, mergeSeed, optionsFromSeed, parseCommand, seedCommand, seedJson, splitCommand, studioCss } from "./seed.js";
1
+ export { generateFromSeed, groundChoices, groundPreviewCss, mergeSeed, panelsFollowing, optionsFromSeed, parseCommand, seedCommand, seedJson, splitCommand, studioCss } from "./seed.js";
2
2
  export { ColourGenerator } from "./studio.js";
3
3
  export { TokenStudio } from "./studio.js";
@@ -44,14 +44,18 @@ export declare function generateFromSeed(seed: SeedFile): TokenSystem;
44
44
  */
45
45
  export declare function studioCss(seed: SeedFile, tokens?: TokenSystem): string;
46
46
  /**
47
- * Where a ground's text, its lines and panels, and its main button come from, as it stands: its own
48
- * choice, else every ground's, else the generator's (the button unset: it follows the tint)
47
+ * Where a ground's text, its lines, its panels and its main button come from, as it stands: its own
48
+ * choice, else every ground's, else the generator's (panels unset follow the lines, the page's or
49
+ * own; the button unset follows the lines)
49
50
  */
50
51
  export declare function groundChoices(seed: SeedFile): Record<string, {
51
52
  text: GroundFill;
52
53
  tint: GroundFill;
54
+ panels: GroundFill;
53
55
  action?: GroundAction;
54
56
  }>;
57
+ /** Where a ground's panels come from when nothing says: the page's with the page's lines, else its own */
58
+ export declare const panelsFollowing: (tint: GroundFill) => GroundFill;
55
59
  /**
56
60
  * One ground as it would be with other choices for its text and its lines, as a rule for
57
61
  * `selector` that writes every token it reads: a preview, generated for real, that leaves the
@@ -60,6 +64,7 @@ export declare function groundChoices(seed: SeedFile): Record<string, {
60
64
  export declare function groundPreviewCss(seed: SeedFile, name: string, choice: {
61
65
  text?: GroundFill;
62
66
  tint?: GroundFill;
67
+ panels?: GroundFill;
63
68
  action?: GroundAction;
64
69
  }, selector: string): string | null;
65
70
  /** The command that regenerates from a seed file, keeping how and where the output is written. */
@@ -55,7 +55,7 @@ export function parseCommand(command) {
55
55
  const surfaces = { light: {}, dark: {} };
56
56
  const grounds = {};
57
57
  const pageSurfaces = {};
58
- /** `--ground-tint name=…`, `--ground-text name=…` and `--ground-action name=…`, applied once every ground is known */
58
+ /** `--ground-tint name=…`, `--ground-panels name=…`, `--ground-text name=…` and `--ground-action name=…`, applied once every ground is known */
59
59
  const perGround = [];
60
60
  for (let i = 0; i < flags.length; i++) {
61
61
  const flag = flags[i];
@@ -119,12 +119,13 @@ export function parseCommand(command) {
119
119
  seed.wcagFloor = false;
120
120
  break;
121
121
  case "--ground-tint":
122
+ case "--ground-panels":
122
123
  case "--ground-text": {
123
- const key = name === "--ground-tint" ? "tint" : "text";
124
+ const key = name === "--ground-tint" ? "tint" : name === "--ground-panels" ? "panels" : "text";
124
125
  const entry = value();
125
126
  const at = entry.indexOf("=");
126
127
  if (at === -1)
127
- seed[key === "tint" ? "groundTint" : "groundText"] = entry;
128
+ seed[key === "tint" ? "groundTint" : key === "panels" ? "groundPanels" : "groundText"] = entry;
128
129
  else
129
130
  perGround.push({ name: entry.slice(0, at), key, fill: entry.slice(at + 1) });
130
131
  break;
@@ -262,6 +263,7 @@ export function optionsFromSeed(seed) {
262
263
  ...(seed.pageSurfaces ? { pageSurfaces: seed.pageSurfaces } : {}),
263
264
  ...(seed.grounds && Object.keys(seed.grounds).length ? { grounds: seed.grounds } : {}),
264
265
  ...(seed.groundTint && seed.groundTint !== "own" ? { groundTint: seed.groundTint } : {}),
266
+ ...(seed.groundPanels ? { groundPanels: seed.groundPanels } : {}),
265
267
  ...(seed.groundText && seed.groundText !== "page" ? { groundText: seed.groundText } : {}),
266
268
  ...(seed.groundAction ? { groundAction: seed.groundAction } : {}),
267
269
  seedShade: seed.seedShade,
@@ -299,15 +301,20 @@ export function studioCss(seed, tokens = generateFromSeed(seed)) {
299
301
  return exportTokens(grounds ? { ...tokens, grounds } : tokens, "css", { colorFormat: seed.colorFormat ?? "oklch", shadeOverrides: options.shadeOverrides, seedShade: options.seedShade, seedShades: options.seedShades });
300
302
  }
301
303
  /**
302
- * Where a ground's text, its lines and panels, and its main button come from, as it stands: its own
303
- * choice, else every ground's, else the generator's (the button unset: it follows the tint)
304
+ * Where a ground's text, its lines, its panels and its main button come from, as it stands: its own
305
+ * choice, else every ground's, else the generator's (panels unset follow the lines, the page's or
306
+ * own; the button unset follows the lines)
304
307
  */
305
308
  export function groundChoices(seed) {
306
309
  return Object.fromEntries(Object.entries(seed.grounds ?? {}).map(([name, g]) => {
307
310
  const action = g.action ?? seed.groundAction;
308
- return [name, { text: g.text ?? seed.groundText ?? "page", tint: g.tint ?? seed.groundTint ?? "own", ...(action ? { action } : {}) }];
311
+ const tint = g.tint ?? seed.groundTint ?? "own";
312
+ const panels = g.panels ?? seed.groundPanels ?? panelsFollowing(tint);
313
+ return [name, { text: g.text ?? seed.groundText ?? "page", tint, panels, ...(action ? { action } : {}) }];
309
314
  }));
310
315
  }
316
+ /** Where a ground's panels come from when nothing says: the page's with the page's lines, else its own */
317
+ export const panelsFollowing = (tint) => (tint === "page" ? "page" : "own");
311
318
  /**
312
319
  * One ground as it would be with other choices for its text and its lines, as a rule for
313
320
  * `selector` that writes every token it reads: a preview, generated for real, that leaves the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@designtools/tokens",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "Turn one brand colour into a complete design-token system: perceptual OKLCH ramps, contrast-checked semantic tokens (WCAG or APCA), light and dark, as CSS custom properties, Tailwind v4/v3 or DTCG. Deterministic CLI, safe for agents.",
5
5
  "type": "module",
6
6
  "license": "MIT",