@designtools/tokens 0.13.0 → 0.14.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  Notable changes to `@designtools/tokens`. Dates are release dates; versions follow semver, with breaking changes in the minor slot while the package is pre-1.0.
4
4
 
5
+ ## 0.14.0
6
+
7
+ ### Minor Changes
8
+
9
+ - 7cb5385: Grounds choose their panels apart from their lines: `--ground-panels` (or `panels` on a ground, `groundPanels` in a seed) sets where the card (`--surface`) and the quiet panel (`--neutral-subdued`) come from: `own`, `page`, or one colour. Unset, panels follow the lines as before, so generated output is unchanged. The studio's "Lines and panels" control is now two, Lines and Panels.
10
+ - ea9c73d: A colour seeded away from 500 keeps the spacing a typical ramp has around its step. Before, the 500 curve was stretched over the new steps, so the step next to a deep seed always sat 38% of the way to white: `#0e2436` at 900 had an 800 at lightness 53 against its own 25. Now its 800 is 35. Ramps seeded on 500 are unchanged; every other ramp shifts on regeneration, most near the seed, and the palest and deepest steps still reach the lightness range.
11
+
5
12
  ## 0.13.0
6
13
 
7
14
  ### Minor Changes
package/README.md CHANGED
@@ -59,6 +59,7 @@ Two pairs of words look alike and aren't:
59
59
  | a success, warning or error banner | the page's `-subdued` tokens (`bg-success-subdued text-success-subdued-foreground`); no ground |
60
60
  | white lines, edges and focus ring on a dark band, text as usual | a ground with `--ground-tint white` (text on a dark ground is white anyway) |
61
61
  | lines and panels in a band's own hue, text in the page's | a ground, as it comes (`tint own`, `text page`) |
62
+ | the page's white cards on a coloured band, its lines in the band's hue | `--ground-panels <name>=page` |
62
63
  | the page's pale brand button kept as it is on a band | `--ground-action <name>=page` |
63
64
  | a band's button in another colour (ink on a yellow band) | `--ground-action <name>=neutral-950`, its label after a slash if you name it |
64
65
  | a card inside a band that reads as the page again | `data-surface="canvas"` on the card |
@@ -184,15 +185,15 @@ A **ground** is a section painted one step of a ramp: a deep green band, a lime
184
185
  }
185
186
  ```
186
187
 
187
- **Two choices per ground say where its tokens come from**, one for its text and one for everything else, its tint:
188
+ **Three choices per ground say where its tokens come from**: its text, its lines (its tint, which the buttons follow) and its panels:
188
189
 
189
- | Value | Text (`--ground-text`: body and secondary text) | Tint (`--ground-tint`: lines, panels, card, input, ring, buttons) |
190
- | --- | --- | --- |
191
- | `page` | the page's text wherever it reads on the ground; white or black where it doesn't. Muted text the page's, or the neutral's nearest that reads | the page's own lines, panels, input and ring |
192
- | `own` | steps from the ground's ramp, searched to the text floors | steps from the ground's ramp, each searched to its floor: a deeper green line on green |
193
- | one colour: `white`, `black`, or a step (`sage-100`) | that colour for body and secondary text both (the report says secondary text is then no quieter) | as `own`, with that colour for every line, edge and ring: white lines on deep green, its panels and card still green |
190
+ | Value | Text (`--ground-text`: body and secondary text) | Lines (`--ground-tint`: border, input edge, ring, buttons) | Panels (`--ground-panels`: the card, `--surface`, and the quiet panel, `--neutral-subdued`) |
191
+ | --- | --- | --- | --- |
192
+ | `page` | the page's text wherever it reads on the ground; white or black where it doesn't. Muted text the page's, or the neutral's nearest that reads | the page's own lines, input and ring | the page's card and quiet panel |
193
+ | `own` | steps from the ground's ramp, searched to the text floors | steps from the ground's ramp, each searched to its floor: a deeper green line on green | a step off the ground on its ramp, as far from it as the page's card is from the page: a lighter green card on deep green |
194
+ | one colour: `white`, `black`, or a step (`sage-100`) | that colour for body and secondary text both (the report says secondary text is then no quieter) | as `own`, with that colour for every line, edge and ring: white lines on deep green | that colour for the card and the quiet panel, their text the ground's where it reads and white or black where it doesn't. The report notes a card that doesn't draw against the ground |
194
195
 
195
- Defaults: `text page`, `tint own`. So text is one standard set across a site, and lines and panels take each ground's hue. A bare value sets every ground; `<name>=<value>` sets one and wins: `--ground-tint own --ground-tint pine=white`. In a seed: `"grounds": { "pine": { "ramp": "pine", "step": 800, "tint": "white" } }`, `"groundTint"`, `"groundText"`.
196
+ Defaults: `text page`, `tint own`, and panels unset, which follow the lines: the page's under `tint page`, the ground's own otherwise. So text is one standard set across a site, and lines and panels take each ground's hue. A bare value sets every ground; `<name>=<value>` sets one and wins: `--ground-tint own --ground-tint pine=white`. In a seed: `"grounds": { "pine": { "ramp": "pine", "step": 800, "tint": "white", "panels": "page" } }`, `"groundTint"`, `"groundPanels"`, `"groundText"`.
196
197
 
197
198
  **Buttons and other colours keep the page's value unless it fails.** The primary and secondary buttons, accent, success, error and warning are the page's wherever they stand out from the ground (3:1 for a fill, with a label that reads on it). One that doesn't is searched along its own ramp: a navy button on deep green moves to a step that shows. Under `tint own` (and one colour) the primary button is drawn from the ground's ramp (on its own colour it turns over: the deepest step with the ground's colour in its label), and the secondary button is tonal: a tint of the ground's hue whose label carries it.
198
199
 
@@ -599,7 +600,8 @@ A seed file:
599
600
  | `--canvas`, `--surface`, `--overlay` | `<colour>[/<dark>]` | neutral steps | The page, card and overlay as exact colours, light then dark; text on each is measured. |
600
601
  | `--page-surface` | `<name>=<ramp>@<step>[/<ramp>@<step>]`, or colours | — | Another [page surface](#page-surfaces) beside canvas, surface and overlay, which follows the mode. Dark defaults to the light step's mirror. Repeatable. |
601
602
  | `--ground` | `<name>=<ramp>@<step>` | — | A [ground](#grounds): a section painted that step, the same in both modes, with tokens that work on it inside `data-surface="<name>"`. Repeatable. |
602
- | `--ground-tint` | `own` · `page` · `white` · `black` · `<ramp>-<step>`, or `<name>=<value>` | `own` | Where a ground's lines, panels, card, input, ring and buttons come from. Repeatable; a named value wins. |
603
+ | `--ground-tint` | `own` · `page` · `white` · `black` · `<ramp>-<step>`, or `<name>=<value>` | `own` | Where a ground's lines (border, input edge, ring) and buttons come from. Repeatable; a named value wins. |
604
+ | `--ground-panels` | as `--ground-tint` | unset: follows the lines | Where a ground's card (`--surface`) and quiet panel (`--neutral-subdued`) come from. Repeatable; a named value wins. |
603
605
  | `--ground-text` | as `--ground-tint` | `page` | Where a ground's body and secondary text come from. Repeatable; a named value wins. |
604
606
  | `--ground-action` | `page` · `own` · `white` · `black` · `<ramp>-<step>`, optionally `/<label>`, or `<name>=<value>` | unset: follows the tint | Where a ground's main button and its label come from. Repeatable; a named value wins. |
605
607
  | `--usage <file.json>` | — | — | Also write where each colour can go: every fill, status text tone and secondary text on every background, per mode, as text, shape or neither (`designtools.usage/1`). `@designtools/manifest` turns the failures into measured usage rules. `--check` compares it too. |
@@ -627,7 +629,7 @@ Everything is derived from the headroom above and below the seed, so where it si
627
629
  generate-tokens --primary "#1e3a5f" --seed-shade 600 # a deep navy, one step down for more headroom
628
630
  ```
629
631
 
630
- Your colour is still reproduced exactly, just at the step you name. The ramp keeps its shape — gentle at the light end, larger jumps at the dark end for text contrast — and peak chroma follows the seed.
632
+ Your colour is still reproduced exactly, just at the step you name. The steps either side keep the spacing a typical ramp has around that step: a deep navy at 900 gets an 800 about ten points lighter, as a 900's neighbour is, rather than a 500's 400, a third of the way to white. A seed on 500 makes the same ramp it always did, and peak chroma follows the seed. Before 0.14.0 the 500 curve was stretched over the new steps, so the step next to a deep seed jumped about 28 points whichever step it was on.
631
633
 
632
634
  **Each colour has its own anchor.** `--seed-shade` moves the primary only. The neutral takes `--neutral-seed-shade`, an added colour takes `@<shade>` on `--color`, and the derived status colours, which are built at mid lightness, stay on 500:
633
635
 
@@ -64,27 +64,17 @@ function snapShade(shade2, active) {
64
64
  }
65
65
  return best;
66
66
  }
67
- function sampleCurve(curve, t2) {
68
- if (curve.length === 1) return curve[0];
69
- const pos = t2 * (curve.length - 1);
70
- const i = Math.min(Math.floor(pos), curve.length - 2);
71
- return curve[i] + (curve[i + 1] - curve[i]) * (pos - i);
72
- }
67
+ var TYPICAL = { seed: 0.55, light: 0.98, dark: 0.15 };
73
68
  function reanchorFactors(base, seedShade) {
74
69
  const anchor = VALID_SHADES.indexOf(seedShade);
75
70
  if (anchor === DEFAULT_ANCHOR_INDEX) return [...base];
76
- const lighter = base.slice(0, DEFAULT_ANCHOR_INDEX);
77
- const darker = base.slice(DEFAULT_ANCHOR_INDEX + 1);
78
- const out = new Array(base.length).fill(0);
79
- for (let i = 0; i < anchor; i++) {
80
- out[i] = sampleCurve(lighter, anchor > 1 ? i / (anchor - 1) : 0);
81
- }
82
- out[anchor] = 0;
83
- const below = base.length - 1 - anchor;
84
- for (let j = 0; j < below; j++) {
85
- out[anchor + 1 + j] = sampleCurve(darker, below > 1 ? j / (below - 1) : 1);
86
- }
87
- return out;
71
+ const { seed, light, dark } = TYPICAL;
72
+ const typical = base.map((f) => f >= 0 ? seed + (light - seed) * f : seed + (seed - dark) * f);
73
+ const last = base.length - 1;
74
+ return typical.map((l, i) => {
75
+ if (i === anchor) return 0;
76
+ return i < anchor ? base[0] * ((l - typical[anchor]) / (typical[0] - typical[anchor])) : base[last] * ((typical[anchor] - l) / (typical[anchor] - typical[last]));
77
+ });
88
78
  }
89
79
  function chromaShadeFor(index, seedShade) {
90
80
  const anchor = VALID_SHADES.indexOf(seedShade);
@@ -1384,6 +1374,7 @@ function buildGround(name, given, tiers, views, options) {
1384
1374
  const light = cr(ground, { type: "black" }) > cr(ground, { type: "white" });
1385
1375
  const polarity = light ? "light" : "dark";
1386
1376
  const tint = given.tint ?? options?.groundTint ?? "own";
1377
+ const panels = given.panels ?? options?.groundPanels ?? (tint === "page" ? "page" : "own");
1387
1378
  const text = given.text ?? options?.groundText ?? "page";
1388
1379
  const action = given.action ?? options?.groundAction;
1389
1380
  const notes = [];
@@ -1403,8 +1394,8 @@ function buildGround(name, given, tiers, views, options) {
1403
1394
  body = fillRef(text, srgb);
1404
1395
  }
1405
1396
  if (cr(body, ground) < textFloor) notes.push(`canvas-foreground: ${cr(body, ground).toFixed(2)}:1, under ${textFloor}:1`);
1406
- const searched = searchGround(
1407
- { name, canvas: ground, foreground: body, family: tint === "page" ? "neutral" : given.ramp, textFamily: text === "own" ? given.ramp : "neutral", ramp: given.ramp, ...action ? { action } : {} },
1397
+ const search = (family) => searchGround(
1398
+ { name, canvas: ground, foreground: body, family, textFamily: text === "own" ? given.ramp : "neutral", ramp: given.ramp, ...action ? { action } : {} },
1408
1399
  base,
1409
1400
  page.canvas,
1410
1401
  colors,
@@ -1413,10 +1404,11 @@ function buildGround(name, given, tiers, views, options) {
1413
1404
  options,
1414
1405
  active
1415
1406
  );
1407
+ const searched = search(tint === "page" ? "neutral" : given.ramp);
1416
1408
  const refs = searched.refs;
1417
1409
  notes.push(...searched.notes);
1418
1410
  if (tint === "page") {
1419
- for (const token of ["neutral-subdued", "neutral-subdued-foreground", "border", "input", "ring"]) refs[token] = page[token];
1411
+ for (const token of ["border", "input", "ring"]) refs[token] = page[token];
1420
1412
  } else if (tint !== "own") {
1421
1413
  const one = fillRef(tint, srgb);
1422
1414
  refs.border = one;
@@ -1428,15 +1420,30 @@ function buildGround(name, given, tiers, views, options) {
1428
1420
  if (cr(refs[token], ground) < FILL_FLOOR) notes.push(`${token}: ${cr(refs[token], ground).toFixed(2)}:1, under ${FILL_FLOOR}:1`);
1429
1421
  }
1430
1422
  }
1423
+ if (panels === "page") {
1424
+ for (const token of ["neutral-subdued", "neutral-subdued-foreground"]) refs[token] = page[token];
1425
+ } else if (panels === "own") {
1426
+ if (tint === "page") {
1427
+ const own = search(given.ramp).refs;
1428
+ for (const token of ["neutral-subdued", "neutral-subdued-foreground"]) refs[token] = own[token];
1429
+ }
1430
+ } else {
1431
+ const one = fillRef(panels, srgb);
1432
+ refs["neutral-subdued"] = one;
1433
+ refs["neutral-subdued-foreground"] = cr(body, one) >= textFloor ? body : bestEnd(one);
1434
+ }
1431
1435
  const pageCardVis = Math.max(cr(page.surface, page.canvas), PANEL_FLOOR);
1432
- if (tint !== "page") {
1436
+ if (panels === "own") {
1433
1437
  const groundL = parseToOklch(valueOf(ground, srgb)).l;
1434
1438
  const lighter = (r) => parseToOklch(valueOf(r, srgb)).l > groundL;
1435
1439
  const cards = rampSteps.filter((r) => cr(r, ground) >= PANEL_FLOOR);
1436
1440
  const byVis = (a, b) => Math.abs(cr(a, ground) - pageCardVis) - Math.abs(cr(b, ground) - pageCardVis);
1437
1441
  refs.surface = [...cards.filter(lighter).sort(byVis), ...cards.filter((r) => !lighter(r)).sort(byVis)][0] ?? page.surface;
1438
- } else {
1442
+ } else if (panels === "page") {
1439
1443
  refs.surface = page.surface;
1444
+ } else {
1445
+ refs.surface = fillRef(panels, srgb);
1446
+ if (cr(refs.surface, ground) < PANEL_FLOOR) notes.push(`surface: ${cr(refs.surface, ground).toFixed(2)}:1 against the ground, so the card doesn't draw`);
1440
1447
  }
1441
1448
  refs.canvas = ground;
1442
1449
  refs["canvas-foreground"] = body;
@@ -1478,6 +1485,7 @@ function buildGround(name, given, tiers, views, options) {
1478
1485
  step,
1479
1486
  polarity,
1480
1487
  tint,
1488
+ panels,
1481
1489
  text,
1482
1490
  ...action ? { action } : {},
1483
1491
  tokens: Object.fromEntries(order.map((k) => [k, valueOf(_refs[k], srgb)])),
package/dist/cli.js CHANGED
@@ -40,7 +40,7 @@ import {
40
40
  tokenFamilies,
41
41
  usageReport,
42
42
  withJsonProvenance
43
- } from "./chunk-HK7ME2YV.js";
43
+ } from "./chunk-7PQDEFU6.js";
44
44
 
45
45
  // src/cli.ts
46
46
  import { parseArgs as parseArgs2 } from "util";
@@ -194,15 +194,21 @@ Seeds:
194
194
  --decorative, or primary for a brand band), the same in
195
195
  light and dark mode. Inside data-surface="<name>",
196
196
  content reads tokens that work on it: the page's of the
197
- ground's polarity, and what --ground-tint and
198
- --ground-text change. Repeatable.
197
+ ground's polarity, and what --ground-tint,
198
+ --ground-panels and --ground-text change. Repeatable.
199
199
  --ground-tint <fill> or <name>=<fill>
200
- Where a ground's lines, panels, card, input edge, ring
201
- and buttons come from. own (default): steps on its
202
- ramp, each searched to its floor. page: the page's.
203
- Or one colour for every line, edge and ring: white,
204
- black, or a step (sage-100). A bare value sets every
205
- ground; name=value one, and wins. Repeatable.
200
+ Where a ground's lines (borders, input edge, ring) and
201
+ buttons come from. own (default): steps on its ramp,
202
+ each searched to its floor. page: the page's. Or one
203
+ colour for every line, edge and ring: white, black, or
204
+ a step (sage-100). A bare value sets every ground;
205
+ name=value one, and wins. Repeatable.
206
+ --ground-panels <fill> or <name>=<fill>
207
+ Where a ground's card (--surface) and quiet panel
208
+ (--neutral-subdued) come from. Unset: the page's with
209
+ page lines, else own. own: a step off the ground on
210
+ its ramp. page: the page's. Or one colour for both.
211
+ Repeatable, as --ground-tint.
206
212
  --ground-text <fill> or <name>=<fill>
207
213
  Where a ground's body and secondary text come from. page
208
214
  (default): the page's, where it reads; white or black
@@ -405,6 +411,7 @@ try {
405
411
  ground: { type: "string", multiple: true },
406
412
  "page-surface": { type: "string", multiple: true },
407
413
  "ground-tint": { type: "string", multiple: true },
414
+ "ground-panels": { type: "string", multiple: true },
408
415
  "ground-text": { type: "string", multiple: true },
409
416
  "ground-action": { type: "string", multiple: true },
410
417
  gamut: { type: "string" },
@@ -593,8 +600,8 @@ for (const entry of values.ground ?? []) {
593
600
  if (eq === -1) fail(`--ground expects name=<ramp>@<step> (got "${entry}")`);
594
601
  const name = entry.slice(0, eq).trim();
595
602
  if (!/^[a-z][a-z0-9-]*$/.test(name) || name === "canvas") fail(`--ground name must be lower-case kebab-case, and not "canvas" (got "${name}")`);
596
- const { tint, text, action } = grounds[name] ?? {};
597
- grounds[name] = { ...rampStep(`--ground ${name}`, entry.slice(eq + 1)), ...tint ? { tint } : {}, ...text ? { text } : {}, ...action ? { action } : {} };
603
+ const { tint, panels, text, action } = grounds[name] ?? {};
604
+ grounds[name] = { ...rampStep(`--ground ${name}`, entry.slice(eq + 1)), ...tint ? { tint } : {}, ...panels ? { panels } : {}, ...text ? { text } : {}, ...action ? { action } : {} };
598
605
  }
599
606
  function fills(flag, key, seeded, fallback) {
600
607
  let all = seeded ?? fallback;
@@ -611,6 +618,7 @@ function fills(flag, key, seeded, fallback) {
611
618
  return all;
612
619
  }
613
620
  var groundTint = fills("ground-tint", "tint", seed.groundTint, "own");
621
+ var groundPanels = fills("ground-panels", "panels", seed.groundPanels);
614
622
  var groundText = fills("ground-text", "text", seed.groundText, "page");
615
623
  var groundAction = seed.groundAction;
616
624
  for (const entry of values["ground-action"] ?? []) {
@@ -764,6 +772,7 @@ var options = {
764
772
  ...Object.keys(pageSurfaces).length ? { pageSurfaces } : {},
765
773
  ...Object.keys(grounds).length ? { grounds } : {},
766
774
  ...groundTint !== "own" ? { groundTint } : {},
775
+ ...groundPanels ? { groundPanels } : {},
767
776
  ...groundText !== "page" ? { groundText } : {},
768
777
  ...groundAction ? { groundAction } : {},
769
778
  seedShade,
@@ -879,6 +888,7 @@ var resolvedSeed = {
879
888
  ...Object.keys(pageSurfaces).length ? { pageSurfaces } : {},
880
889
  ...Object.keys(grounds).length ? { grounds } : {},
881
890
  ...groundTint !== "own" ? { groundTint } : {},
891
+ ...groundPanels ? { groundPanels } : {},
882
892
  ...groundText !== "page" ? { groundText } : {},
883
893
  ...groundAction ? { groundAction } : {},
884
894
  seedShade,
@@ -1134,7 +1144,7 @@ function reportGrounds() {
1134
1144
  grounds: what data-surface="<ground>" writes (ratio against the ground; a label's against its fill)
1135
1145
  `);
1136
1146
  for (const [name, g] of grounds2) {
1137
- process.stderr.write(` ${name.padEnd(14)}${g.ramp}@${g.step}, ${g.polarity}, text ${g.text}, tint ${g.tint}${g.action ? `, action ${g.action}` : ""}
1147
+ process.stderr.write(` ${name.padEnd(14)}${g.ramp}@${g.step}, ${g.polarity}, text ${g.text}, lines ${g.tint}, panels ${g.panels}${g.action ? `, action ${g.action}` : ""}
1138
1148
  `);
1139
1149
  const shown = g.own.filter((t) => t !== "canvas" && !t.endsWith("-hover") && !t.endsWith("-active"));
1140
1150
  const items = shown.map((t) => `${t} ${step(g._refs[t])} ${getContrastRatio(g.tokens[t], g.tokens[under(t)]).toFixed(1)}`);
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,
package/dist/index.js CHANGED
@@ -80,7 +80,7 @@ import {
80
80
  tokenFamilies,
81
81
  usageReport,
82
82
  withJsonProvenance
83
- } from "./chunk-HK7ME2YV.js";
83
+ } from "./chunk-7PQDEFU6.js";
84
84
  export {
85
85
  ALIAS_PAIRS,
86
86
  APCAUnavailableError,
@@ -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.14.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",