@designtools/tokens 0.12.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 +13 -0
- package/README.md +25 -10
- package/dist/{chunk-TRGCDLOM.js → chunk-7PQDEFU6.js} +66 -32
- package/dist/cli.js +51 -12
- package/dist/index.d.ts +40 -13
- package/dist/index.js +1 -1
- package/dist/studio/changes.js +10 -2
- package/dist/studio/ground-controls.d.ts +1 -1
- package/dist/studio/ground-controls.js +26 -8
- package/dist/studio/index.d.ts +1 -1
- package/dist/studio/index.js +1 -1
- package/dist/studio/seed.d.ts +12 -2
- package/dist/studio/seed.js +28 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
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
|
+
|
|
12
|
+
## 0.13.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- 8fed30f: `--ground-action` says where a ground's main button comes from, when the tint's answer is wrong: `page` keeps the page's button as it is (a pale brand colour its label carries, lime on a mist band as on the page), `own` takes the ground's own colour turned over, and a colour sets the fill, its label measured on it or given after a slash (`--ground-action yellow=neutral-950/primary-400`, ink with a yellow label on a yellow band). Unset, the button follows the tint as before. In a seed, `"action"` on a ground or `"groundAction"`; the report, `--check`, the seed round trip and the colour editor (a Button control on each ground) carry it.
|
|
17
|
+
|
|
5
18
|
## 0.12.0
|
|
6
19
|
|
|
7
20
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -59,6 +59,9 @@ 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` |
|
|
63
|
+
| the page's pale brand button kept as it is on a band | `--ground-action <name>=page` |
|
|
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 |
|
|
62
65
|
| a card inside a band that reads as the page again | `data-surface="canvas"` on the card |
|
|
63
66
|
|
|
64
67
|
## What it generates
|
|
@@ -182,18 +185,28 @@ A **ground** is a section painted one step of a ramp: a deep green band, a lime
|
|
|
182
185
|
}
|
|
183
186
|
```
|
|
184
187
|
|
|
185
|
-
**
|
|
188
|
+
**Three choices per ground say where its tokens come from**: its text, its lines (its tint, which the buttons follow) and its panels:
|
|
186
189
|
|
|
187
|
-
| Value | Text (`--ground-text`: body and secondary text) |
|
|
188
|
-
| --- | --- | --- |
|
|
189
|
-
| `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,
|
|
190
|
-
| `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 |
|
|
191
|
-
| 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,
|
|
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 |
|
|
192
195
|
|
|
193
|
-
Defaults: `text page`, `tint own
|
|
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"`.
|
|
194
197
|
|
|
195
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.
|
|
196
199
|
|
|
200
|
+
**Where the main button comes from, when the tint's answer is wrong: `--ground-action`.** Unset, the primary button follows the tint, as above. Three values change it, for `--primary`, its label, hover and pressed:
|
|
201
|
+
|
|
202
|
+
| Value | The button |
|
|
203
|
+
| --- | --- |
|
|
204
|
+
| `page` | the page's, as it is, wherever it lands. For a pale brand colour that its label carries on the page (lime at 1.1:1 on cream), so a band doesn't turn it into another colour. The report notes the ratio. |
|
|
205
|
+
| `own` | the ground's own colour: kept where it stands out, turned over on its ramp where it doesn't, under any tint |
|
|
206
|
+
| one colour: `white`, `black`, a step (`neutral-950`) | that fill, its label measured on it, or given after a slash (`neutral-950/primary-400`). Hover and pressed step along the fill's ramp. The report notes a fill under 3:1 or a label under the text floor. |
|
|
207
|
+
|
|
208
|
+
Only the main button: the secondary and status buttons are searched as before. As the others, a bare value sets every ground and `<name>=<value>` one; in a seed, `"action"` on the ground or `"groundAction"`.
|
|
209
|
+
|
|
197
210
|
**Resetting inside a ground.** `data-surface="canvas"` on a card or a nested section gives it the page's tokens as they are in the current mode, with nothing extra generated: the page's mode blocks match it.
|
|
198
211
|
|
|
199
212
|
**Banners aren't grounds.** A success, warning or error banner is the page's `-subdued` pair. Its text always reads (it is measured on the page), and `--report` lists where a filled button blends into a tint, so the banner can use the outline button there.
|
|
@@ -587,8 +600,10 @@ A seed file:
|
|
|
587
600
|
| `--canvas`, `--surface`, `--overlay` | `<colour>[/<dark>]` | neutral steps | The page, card and overlay as exact colours, light then dark; text on each is measured. |
|
|
588
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. |
|
|
589
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. |
|
|
590
|
-
| `--ground-tint` | `own` · `page` · `white` · `black` · `<ramp>-<step>`, or `<name>=<value>` | `own` | Where a ground's lines
|
|
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. |
|
|
591
605
|
| `--ground-text` | as `--ground-tint` | `page` | Where a ground's body and secondary text come from. Repeatable; a named value wins. |
|
|
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. |
|
|
592
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. |
|
|
593
608
|
| `--seed-shade` | `25`…`950` | `500` | Which step your primary lands on. |
|
|
594
609
|
| `--neutral-seed-shade` | `25`…`950` | `500` | Which step your neutral lands on. |
|
|
@@ -614,7 +629,7 @@ Everything is derived from the headroom above and below the seed, so where it si
|
|
|
614
629
|
generate-tokens --primary "#1e3a5f" --seed-shade 600 # a deep navy, one step down for more headroom
|
|
615
630
|
```
|
|
616
631
|
|
|
617
|
-
Your colour is still reproduced exactly, just at the step you name. The ramp
|
|
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.
|
|
618
633
|
|
|
619
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:
|
|
620
635
|
|
|
@@ -827,7 +842,7 @@ Two consequences, both of which have cost real projects real time:
|
|
|
827
842
|
|
|
828
843
|
Then check **both** colour schemes, not whichever your tool defaults to.
|
|
829
844
|
|
|
830
|
-
**A token on one ground** is overridden on its scope, `[data-surface="pine"] { --border: var(--color-pine-600); }`, after the generated file and unlayered. A ground has no modes, so one selector is the whole of it. Better still, say it in the generator: `--ground-tint pine=pine-600`.
|
|
845
|
+
**A token on one ground** is overridden on its scope, `[data-surface="pine"] { --border: var(--color-pine-600); }`, after the generated file and unlayered. A ground has no modes, so one selector is the whole of it. Better still, say it in the generator: `--ground-tint pine=pine-600`, or for the button `--ground-action pine=neutral-950`.
|
|
831
846
|
|
|
832
847
|
**Change a ramp step through its seed, not by overriding it.** Tailwind v4 utilities do read ramp steps through `var()` (checked against a Tailwind 4.3 compile), which is what lets the `--gamut p3` layer work. The one exception is an opacity modifier: `bg-primary-500/50` also emits the step's literal value as a fallback for browsers without `color-mix()`, and an override cannot reach that. But a hand-overridden step is a fork of the palette that the contrast search never saw and `--check` cannot detect. If you need a ramp step to change, change the seed and regenerate, or point the call sites at a token you do own.
|
|
833
848
|
|
|
@@ -64,27 +64,17 @@ function snapShade(shade2, active) {
|
|
|
64
64
|
}
|
|
65
65
|
return best;
|
|
66
66
|
}
|
|
67
|
-
|
|
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
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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);
|
|
@@ -1270,18 +1260,17 @@ function searchGround(spec, base, baseCanvas, colors, views, mode, options, acti
|
|
|
1270
1260
|
refs.ring = inHue(base.ring) && cr(base.ring, ground) >= FILL_FLOOR ? base.ring : nearest(ringFamily, ringFrom, ground, FILL_FLOOR) ?? bestEnd(ground);
|
|
1271
1261
|
for (const name of colors) {
|
|
1272
1262
|
const src = tinted && (name === "primary" || name === "neutral") ? spec.family : name;
|
|
1273
|
-
const
|
|
1274
|
-
const fillShade =
|
|
1275
|
-
const scaleIn = (v) => v.palette[src];
|
|
1263
|
+
const pageFill = base[src];
|
|
1264
|
+
const fillShade = pageFill.shade;
|
|
1276
1265
|
const neutralIn = (v) => v.palette.neutral;
|
|
1277
|
-
const labelOn = (bg, role2, pageGrounds = []) => {
|
|
1266
|
+
const labelOn = (bg, role2, pageGrounds = [], from = src) => {
|
|
1278
1267
|
const found = findBestForeground(
|
|
1279
|
-
views.map((v) => ({ background: valueOf(bg, v.palette), scale:
|
|
1268
|
+
views.map((v) => ({ background: valueOf(bg, v.palette), scale: v.palette[from], neutral: neutralIn(v), gamut: v.gamut })),
|
|
1280
1269
|
srgb.white,
|
|
1281
1270
|
srgb.black,
|
|
1282
1271
|
algorithm,
|
|
1283
1272
|
target,
|
|
1284
|
-
|
|
1273
|
+
from,
|
|
1285
1274
|
active,
|
|
1286
1275
|
role2,
|
|
1287
1276
|
options?.foreground ?? "balanced",
|
|
@@ -1296,15 +1285,40 @@ function searchGround(spec, base, baseCanvas, colors, views, mode, options, acti
|
|
|
1296
1285
|
refs[`${name}-hover`] = { type: "value", value: stateOf(f, l, HOVER_SHIFT, views[0].gamut) };
|
|
1297
1286
|
refs[`${name}-active`] = { type: "value", value: stateOf(f, l, ACTIVE_SHIFT, views[0].gamut) };
|
|
1298
1287
|
};
|
|
1299
|
-
|
|
1288
|
+
const action = name === "primary" ? spec.action : void 0;
|
|
1289
|
+
if (action === "page") {
|
|
1290
|
+
refs[name] = base[name];
|
|
1291
|
+
refs[`${name}-foreground`] = base[`${name}-foreground`];
|
|
1292
|
+
refs[`${name}-hover`] = base[`${name}-hover`];
|
|
1293
|
+
refs[`${name}-active`] = base[`${name}-active`];
|
|
1294
|
+
if (cr(base[name], ground) < FILL_FLOOR) notes.push(`${name}: the page's, ${cr(base[name], ground).toFixed(2)}:1 against the ground (action page), carried by its label`);
|
|
1295
|
+
} else if (action === "own") {
|
|
1296
|
+
const own2 = base[spec.ramp];
|
|
1297
|
+
const ramp = steps(spec.ramp);
|
|
1298
|
+
const fill = cr(own2, ground) >= FILL_FLOOR ? own2 : light ? ramp[ramp.length - 1] : ramp[0];
|
|
1299
|
+
const label = sameRef(fill, own2) ? base[`${spec.ramp}-foreground`] : labelOn(fill, "tint", [], spec.ramp);
|
|
1300
|
+
refs[name] = fill;
|
|
1301
|
+
refs[`${name}-foreground`] = label;
|
|
1302
|
+
setStates(fill, label);
|
|
1303
|
+
if (cr(fill, ground) < FILL_FLOOR) notes.push(`${name}: no step of ${spec.ramp} stands out from the ground at ${FILL_FLOOR}:1 (action own)`);
|
|
1304
|
+
} else if (action) {
|
|
1305
|
+
const [fillName, labelName] = action.split("/");
|
|
1306
|
+
const fill = fillRef(fillName, srgb);
|
|
1307
|
+
const label = labelName ? fillRef(labelName, srgb) : labelOn(fill, "fill");
|
|
1308
|
+
refs[name] = fill;
|
|
1309
|
+
refs[`${name}-foreground`] = label;
|
|
1310
|
+
setStates(fill, label);
|
|
1311
|
+
if (cr(fill, ground) < FILL_FLOOR) notes.push(`${name}: ${fillName} is ${cr(fill, ground).toFixed(2)}:1 against the ground, under ${FILL_FLOOR}:1`);
|
|
1312
|
+
if (cr(label, fill) < textFloor) notes.push(`${name}-foreground: ${labelName ?? "the label"} is ${cr(label, fill).toFixed(2)}:1 on ${fillName}, under ${textFloor}:1`);
|
|
1313
|
+
} else if (tinted && name === "neutral") {
|
|
1300
1314
|
const tonal = panelCandidates(steps(src), 1.6).map((fill2) => ({ fill: fill2, label: labelOn(fill2, "tint") })).find((t2) => cr(t2.label, t2.fill) >= textFloor);
|
|
1301
1315
|
const fill = tonal?.fill ?? steps(src).filter(farSide)[0] ?? bestEnd(ground);
|
|
1302
1316
|
const label = tonal?.label ?? labelOn(fill, "fill");
|
|
1303
1317
|
refs[name] = fill;
|
|
1304
1318
|
refs[`${name}-foreground`] = label;
|
|
1305
1319
|
setStates(fill, label);
|
|
1306
|
-
} else if (inHue(
|
|
1307
|
-
refs[name] =
|
|
1320
|
+
} else if (inHue(pageFill) && cr(pageFill, ground) >= FILL_FLOOR) {
|
|
1321
|
+
refs[name] = pageFill;
|
|
1308
1322
|
refs[`${name}-foreground`] = base[`${src}-foreground`];
|
|
1309
1323
|
refs[`${name}-hover`] = base[`${src}-hover`];
|
|
1310
1324
|
refs[`${name}-active`] = base[`${src}-active`];
|
|
@@ -1360,7 +1374,9 @@ function buildGround(name, given, tiers, views, options) {
|
|
|
1360
1374
|
const light = cr(ground, { type: "black" }) > cr(ground, { type: "white" });
|
|
1361
1375
|
const polarity = light ? "light" : "dark";
|
|
1362
1376
|
const tint = given.tint ?? options?.groundTint ?? "own";
|
|
1377
|
+
const panels = given.panels ?? options?.groundPanels ?? (tint === "page" ? "page" : "own");
|
|
1363
1378
|
const text = given.text ?? options?.groundText ?? "page";
|
|
1379
|
+
const action = given.action ?? options?.groundAction;
|
|
1364
1380
|
const notes = [];
|
|
1365
1381
|
const bestEnd = (on) => cr({ type: "white" }, on) >= cr({ type: "black" }, on) ? { type: "white" } : { type: "black" };
|
|
1366
1382
|
const tier = { semantic: tiers.semantic[polarity], surface: tiers.surface[polarity], utility: tiers.utility[polarity] };
|
|
@@ -1378,8 +1394,8 @@ function buildGround(name, given, tiers, views, options) {
|
|
|
1378
1394
|
body = fillRef(text, srgb);
|
|
1379
1395
|
}
|
|
1380
1396
|
if (cr(body, ground) < textFloor) notes.push(`canvas-foreground: ${cr(body, ground).toFixed(2)}:1, under ${textFloor}:1`);
|
|
1381
|
-
const
|
|
1382
|
-
{ name, canvas: ground, foreground: body, family:
|
|
1397
|
+
const search = (family) => searchGround(
|
|
1398
|
+
{ name, canvas: ground, foreground: body, family, textFamily: text === "own" ? given.ramp : "neutral", ramp: given.ramp, ...action ? { action } : {} },
|
|
1383
1399
|
base,
|
|
1384
1400
|
page.canvas,
|
|
1385
1401
|
colors,
|
|
@@ -1388,10 +1404,11 @@ function buildGround(name, given, tiers, views, options) {
|
|
|
1388
1404
|
options,
|
|
1389
1405
|
active
|
|
1390
1406
|
);
|
|
1407
|
+
const searched = search(tint === "page" ? "neutral" : given.ramp);
|
|
1391
1408
|
const refs = searched.refs;
|
|
1392
1409
|
notes.push(...searched.notes);
|
|
1393
1410
|
if (tint === "page") {
|
|
1394
|
-
for (const token of ["
|
|
1411
|
+
for (const token of ["border", "input", "ring"]) refs[token] = page[token];
|
|
1395
1412
|
} else if (tint !== "own") {
|
|
1396
1413
|
const one = fillRef(tint, srgb);
|
|
1397
1414
|
refs.border = one;
|
|
@@ -1403,15 +1420,30 @@ function buildGround(name, given, tiers, views, options) {
|
|
|
1403
1420
|
if (cr(refs[token], ground) < FILL_FLOOR) notes.push(`${token}: ${cr(refs[token], ground).toFixed(2)}:1, under ${FILL_FLOOR}:1`);
|
|
1404
1421
|
}
|
|
1405
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
|
+
}
|
|
1406
1435
|
const pageCardVis = Math.max(cr(page.surface, page.canvas), PANEL_FLOOR);
|
|
1407
|
-
if (
|
|
1436
|
+
if (panels === "own") {
|
|
1408
1437
|
const groundL = parseToOklch(valueOf(ground, srgb)).l;
|
|
1409
1438
|
const lighter = (r) => parseToOklch(valueOf(r, srgb)).l > groundL;
|
|
1410
1439
|
const cards = rampSteps.filter((r) => cr(r, ground) >= PANEL_FLOOR);
|
|
1411
1440
|
const byVis = (a, b) => Math.abs(cr(a, ground) - pageCardVis) - Math.abs(cr(b, ground) - pageCardVis);
|
|
1412
1441
|
refs.surface = [...cards.filter(lighter).sort(byVis), ...cards.filter((r) => !lighter(r)).sort(byVis)][0] ?? page.surface;
|
|
1413
|
-
} else {
|
|
1442
|
+
} else if (panels === "page") {
|
|
1414
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`);
|
|
1415
1447
|
}
|
|
1416
1448
|
refs.canvas = ground;
|
|
1417
1449
|
refs["canvas-foreground"] = body;
|
|
@@ -1453,7 +1485,9 @@ function buildGround(name, given, tiers, views, options) {
|
|
|
1453
1485
|
step,
|
|
1454
1486
|
polarity,
|
|
1455
1487
|
tint,
|
|
1488
|
+
panels,
|
|
1456
1489
|
text,
|
|
1490
|
+
...action ? { action } : {},
|
|
1457
1491
|
tokens: Object.fromEntries(order.map((k) => [k, valueOf(_refs[k], srgb)])),
|
|
1458
1492
|
_refs,
|
|
1459
1493
|
// the ground itself always; the rest where they differ from the page of the ground's polarity
|
package/dist/cli.js
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
tokenFamilies,
|
|
41
41
|
usageReport,
|
|
42
42
|
withJsonProvenance
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-7PQDEFU6.js";
|
|
44
44
|
|
|
45
45
|
// src/cli.ts
|
|
46
46
|
import { parseArgs as parseArgs2 } from "util";
|
|
@@ -194,20 +194,34 @@ 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
|
|
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
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
|
209
215
|
where it doesn't. own: steps on its ramp. Or one
|
|
210
216
|
colour for both. Repeatable, as --ground-tint.
|
|
217
|
+
--ground-action <action> or <name>=<action>
|
|
218
|
+
Where a ground's main button (--primary, its label and
|
|
219
|
+
states) comes from. Unset, it follows the tint. page:
|
|
220
|
+
the page's button as it is, wherever it lands (a pale
|
|
221
|
+
brand colour its label carries). own: the ground's own
|
|
222
|
+
colour, turned over on its ramp. Or a colour, with its
|
|
223
|
+
label measured on it or after a slash:
|
|
224
|
+
neutral-950/primary-400. Repeatable, as --ground-tint.
|
|
211
225
|
--usage <file.json> Also write where each colour can go: every fill, status
|
|
212
226
|
text tone and secondary text on every background, per mode,
|
|
213
227
|
as text, shape or neither. @designtools/manifest reads it
|
|
@@ -397,7 +411,9 @@ try {
|
|
|
397
411
|
ground: { type: "string", multiple: true },
|
|
398
412
|
"page-surface": { type: "string", multiple: true },
|
|
399
413
|
"ground-tint": { type: "string", multiple: true },
|
|
414
|
+
"ground-panels": { type: "string", multiple: true },
|
|
400
415
|
"ground-text": { type: "string", multiple: true },
|
|
416
|
+
"ground-action": { type: "string", multiple: true },
|
|
401
417
|
gamut: { type: "string" },
|
|
402
418
|
"seed-shade": { type: "string" },
|
|
403
419
|
"neutral-seed-shade": { type: "string" },
|
|
@@ -554,6 +570,13 @@ function validateFill(flag, raw) {
|
|
|
554
570
|
if (v === "page" || v === "own" || v === "white" || v === "black" || /^[a-z][a-z0-9-]*-\d+$/.test(v)) return v;
|
|
555
571
|
fail(`--${flag} must be page, own, white, black or a step such as sage-100 (got "${raw}")`);
|
|
556
572
|
}
|
|
573
|
+
function validateAction(flag, raw) {
|
|
574
|
+
const v = raw.trim();
|
|
575
|
+
const colour = (c) => c === "white" || c === "black" || /^[a-z][a-z0-9-]*-\d+$/.test(c);
|
|
576
|
+
const [fill, label, extra] = v.split("/");
|
|
577
|
+
if (v === "page" || v === "own" || colour(fill) && (label === void 0 || colour(label)) && extra === void 0) return v;
|
|
578
|
+
fail(`--${flag} must be page, own, or a colour such as neutral-950, with its label after a slash if you name it (neutral-950/primary-400) (got "${raw}")`);
|
|
579
|
+
}
|
|
557
580
|
function rampStep(flag, raw) {
|
|
558
581
|
const m = /^([a-z][a-z0-9-]*)@(\d+)$/.exec(raw.trim());
|
|
559
582
|
if (!m || !VALID_SHADES.includes(Number(m[2]))) fail(`${flag} expects <ramp>@<step>, with a step of ${VALID_SHADES.join(", ")} (got "${raw}")`);
|
|
@@ -577,8 +600,8 @@ for (const entry of values.ground ?? []) {
|
|
|
577
600
|
if (eq === -1) fail(`--ground expects name=<ramp>@<step> (got "${entry}")`);
|
|
578
601
|
const name = entry.slice(0, eq).trim();
|
|
579
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}")`);
|
|
580
|
-
const { tint, text } = grounds[name] ?? {};
|
|
581
|
-
grounds[name] = { ...rampStep(`--ground ${name}`, entry.slice(eq + 1)), ...tint ? { tint } : {}, ...text ? { text } : {} };
|
|
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 } : {} };
|
|
582
605
|
}
|
|
583
606
|
function fills(flag, key, seeded, fallback) {
|
|
584
607
|
let all = seeded ?? fallback;
|
|
@@ -595,7 +618,19 @@ function fills(flag, key, seeded, fallback) {
|
|
|
595
618
|
return all;
|
|
596
619
|
}
|
|
597
620
|
var groundTint = fills("ground-tint", "tint", seed.groundTint, "own");
|
|
621
|
+
var groundPanels = fills("ground-panels", "panels", seed.groundPanels);
|
|
598
622
|
var groundText = fills("ground-text", "text", seed.groundText, "page");
|
|
623
|
+
var groundAction = seed.groundAction;
|
|
624
|
+
for (const entry of values["ground-action"] ?? []) {
|
|
625
|
+
const eq = entry.indexOf("=");
|
|
626
|
+
if (eq === -1) {
|
|
627
|
+
groundAction = validateAction("ground-action", entry);
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
const name = entry.slice(0, eq).trim();
|
|
631
|
+
if (!grounds[name]) fail(`--ground-action names no ground: ${name} (grounds: ${Object.keys(grounds).join(", ") || "none"})`);
|
|
632
|
+
grounds[name] = { ...grounds[name], action: validateAction(`ground-action ${name}`, entry.slice(eq + 1)) };
|
|
633
|
+
}
|
|
599
634
|
var hasSurfaceColors = Object.keys(surfaceColors.light).length + Object.keys(surfaceColors.dark).length > 0;
|
|
600
635
|
var gamut = validateChoice("gamut", values.gamut ?? seed.gamut, ["srgb", "p3"], "srgb");
|
|
601
636
|
var format = validateChoice(
|
|
@@ -737,7 +772,9 @@ var options = {
|
|
|
737
772
|
...Object.keys(pageSurfaces).length ? { pageSurfaces } : {},
|
|
738
773
|
...Object.keys(grounds).length ? { grounds } : {},
|
|
739
774
|
...groundTint !== "own" ? { groundTint } : {},
|
|
775
|
+
...groundPanels ? { groundPanels } : {},
|
|
740
776
|
...groundText !== "page" ? { groundText } : {},
|
|
777
|
+
...groundAction ? { groundAction } : {},
|
|
741
778
|
seedShade,
|
|
742
779
|
...Object.keys(seedShades).length > 0 ? { seedShades } : {},
|
|
743
780
|
...lightnessRange ? { lightnessRange: { ...lightnessRange.light !== void 0 ? { light: lightnessRange.light / 100 } : {}, ...lightnessRange.dark !== void 0 ? { dark: lightnessRange.dark / 100 } : {} } } : {},
|
|
@@ -851,7 +888,9 @@ var resolvedSeed = {
|
|
|
851
888
|
...Object.keys(pageSurfaces).length ? { pageSurfaces } : {},
|
|
852
889
|
...Object.keys(grounds).length ? { grounds } : {},
|
|
853
890
|
...groundTint !== "own" ? { groundTint } : {},
|
|
891
|
+
...groundPanels ? { groundPanels } : {},
|
|
854
892
|
...groundText !== "page" ? { groundText } : {},
|
|
893
|
+
...groundAction ? { groundAction } : {},
|
|
855
894
|
seedShade,
|
|
856
895
|
neutralSeedShade,
|
|
857
896
|
// left out when unset, so a seed without them keeps the fingerprint it always had
|
|
@@ -1105,7 +1144,7 @@ function reportGrounds() {
|
|
|
1105
1144
|
grounds: what data-surface="<ground>" writes (ratio against the ground; a label's against its fill)
|
|
1106
1145
|
`);
|
|
1107
1146
|
for (const [name, g] of grounds2) {
|
|
1108
|
-
process.stderr.write(` ${name.padEnd(14)}${g.ramp}@${g.step}, ${g.polarity}, text ${g.text},
|
|
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}` : ""}
|
|
1109
1148
|
`);
|
|
1110
1149
|
const shown = g.own.filter((t) => t !== "canvas" && !t.endsWith("-hover") && !t.endsWith("-active"));
|
|
1111
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,20 +192,35 @@ interface TokenSystem {
|
|
|
192
192
|
p3?: GamutTokens;
|
|
193
193
|
}
|
|
194
194
|
/**
|
|
195
|
-
* Where a ground's tokens come from
|
|
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`).
|
|
199
199
|
*/
|
|
200
200
|
type GroundFill = "page" | "own" | "white" | "black" | `${string}-${number}`;
|
|
201
|
+
/** A colour a ground's button can be: `white`, `black`, or a step written `<ramp>-<step>` */
|
|
202
|
+
type GroundColour = "white" | "black" | `${string}-${number}`;
|
|
203
|
+
/**
|
|
204
|
+
* Where a ground's main button (`--primary`, its label and states) comes from. Unset, it follows
|
|
205
|
+
* the tint: from the ground's ramp under `own` or one colour, the page's under `page` where it
|
|
206
|
+
* stands out and searched along its ramp where it doesn't. `page`: the page's button as it is,
|
|
207
|
+
* wherever it lands (a pale brand colour its label carries on the page, kept on a band too).
|
|
208
|
+
* `own`: the ground's own colour, turned over on its own ramp. Or a colour: that fill, with its
|
|
209
|
+
* label measured on it, or given after a slash (`neutral-950/primary-400`).
|
|
210
|
+
*/
|
|
211
|
+
type GroundAction = "page" | "own" | GroundColour | `${GroundColour}/${GroundColour}`;
|
|
201
212
|
/** A ground as declared: the ramp and step it is painted, and where its tokens come from */
|
|
202
213
|
interface GroundSpec {
|
|
203
214
|
ramp: string;
|
|
204
215
|
step: ShadeNumber;
|
|
205
|
-
/** Lines
|
|
216
|
+
/** Lines: borders, the input edge, the ring, and the buttons with them. Default: `own` */
|
|
206
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;
|
|
207
220
|
/** Body and secondary text. Default: `page` */
|
|
208
221
|
text?: GroundFill;
|
|
222
|
+
/** The main button. Default: unset, following the tint */
|
|
223
|
+
action?: GroundAction;
|
|
209
224
|
}
|
|
210
225
|
/** Where a ground token comes from: a ramp step, black or white (a page surface given as a colour stays a value) */
|
|
211
226
|
type GroundRef = ForegroundRef | {
|
|
@@ -227,7 +242,10 @@ interface GroundTokens {
|
|
|
227
242
|
/** Whether the ground reads as light (dark text) or dark (light text): which page mode it borrows */
|
|
228
243
|
polarity: "light" | "dark";
|
|
229
244
|
tint: GroundFill;
|
|
245
|
+
panels: GroundFill;
|
|
230
246
|
text: GroundFill;
|
|
247
|
+
/** Where its main button comes from, when it doesn't follow the tint */
|
|
248
|
+
action?: GroundAction;
|
|
231
249
|
tokens: Record<string, string>;
|
|
232
250
|
_refs: Record<string, GroundRef>;
|
|
233
251
|
/** The tokens this ground writes, in order: those that differ from the page's of its polarity */
|
|
@@ -431,10 +449,14 @@ interface GenerationOptions {
|
|
|
431
449
|
* decorative, or `primary` for a brand band.
|
|
432
450
|
*/
|
|
433
451
|
grounds?: Record<string, GroundSpec>;
|
|
434
|
-
/** Where every ground's
|
|
452
|
+
/** Where every ground's lines come from, unless it says otherwise. Default `own` */
|
|
435
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;
|
|
436
456
|
/** Where every ground's text comes from, unless it says otherwise. Default `page` */
|
|
437
457
|
groundText?: GroundFill;
|
|
458
|
+
/** Where every ground's main button comes from, unless it says otherwise. Default: the tint's */
|
|
459
|
+
groundAction?: GroundAction;
|
|
438
460
|
/**
|
|
439
461
|
* Which steps to emit. Default: all twelve (25–950).
|
|
440
462
|
* Tokens naming a dropped step are snapped to the nearest emitted one.
|
|
@@ -510,7 +532,9 @@ interface SavedConfig {
|
|
|
510
532
|
pageSurfaces?: GenerationOptions["pageSurfaces"];
|
|
511
533
|
grounds?: GenerationOptions["grounds"];
|
|
512
534
|
groundTint?: GroundFill;
|
|
535
|
+
groundPanels?: GroundFill;
|
|
513
536
|
groundText?: GroundFill;
|
|
537
|
+
groundAction?: GroundAction;
|
|
514
538
|
shadeOverrides: SemanticShadeOverrides;
|
|
515
539
|
surfaceShadeOverrides?: GenerationOptions["surfaceShadeOverrides"];
|
|
516
540
|
utilityShadeOverrides?: GenerationOptions["utilityShadeOverrides"];
|
|
@@ -1055,14 +1079,15 @@ declare function snapShade(shade: ShadeNumber, active: readonly ShadeNumber[]):
|
|
|
1055
1079
|
* Re-anchor a lightness-factor table so the seed lands on `seedShade`.
|
|
1056
1080
|
*
|
|
1057
1081
|
* The table is signed: positive entries are a fraction of the headroom above the
|
|
1058
|
-
* seed, negative a fraction of the headroom below, and the anchor is 0.
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
1061
|
-
*
|
|
1062
|
-
*
|
|
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.
|
|
1063
1088
|
*
|
|
1064
|
-
*
|
|
1065
|
-
*
|
|
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.
|
|
1066
1091
|
*/
|
|
1067
1092
|
declare function reanchorFactors(base: readonly number[], seedShade: ShadeNumber): number[];
|
|
1068
1093
|
/**
|
|
@@ -1144,8 +1169,10 @@ declare function isAPCAAvailable(): boolean;
|
|
|
1144
1169
|
* a ground doesn't change is already right inside it in either mode. The ground's own scope then
|
|
1145
1170
|
* writes only what differs, every value a ramp step (or white or black), never a computed colour.
|
|
1146
1171
|
*
|
|
1147
|
-
* What differs comes from
|
|
1148
|
-
* - tint, for lines
|
|
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;
|
|
1149
1176
|
* - text, for body and secondary text.
|
|
1150
1177
|
* Each is `page` (the page's tokens, where they read), `own` (steps on the ground's ramp, each
|
|
1151
1178
|
* searched to its floor) or one colour (`white`, `black`, `sage-100`). Any other colour (accent,
|
|
@@ -1279,4 +1306,4 @@ declare function applyScaleOverrides(tiers: ScaleTier[], overrides: Record<strin
|
|
|
1279
1306
|
type ScaleFormat = "css" | "tailwind-v4" | "tailwind-v3" | "dtcg" | "json";
|
|
1280
1307
|
declare function exportScale(tiers: ScaleTier[], format: ScaleFormat, header?: string): string;
|
|
1281
1308
|
|
|
1282
|
-
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 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 };
|
|
1309
|
+
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 };
|
package/dist/index.js
CHANGED
package/dist/studio/changes.js
CHANGED
|
@@ -101,7 +101,11 @@ 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
|
|
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"}`);
|
|
107
|
+
if (!same(before.groundAction, now.groundAction))
|
|
108
|
+
out.push(`every ground's button ${now.groundAction ?? "as its lines"}`);
|
|
105
109
|
const grounds = new Set([...Object.keys(before.grounds ?? {}), ...Object.keys(now.grounds ?? {})]);
|
|
106
110
|
for (const name of grounds) {
|
|
107
111
|
const a = before.grounds?.[name];
|
|
@@ -118,7 +122,11 @@ export function describeChanges(before, now) {
|
|
|
118
122
|
if (a.text !== b.text)
|
|
119
123
|
out.push(`${name} ground's text ${b.text ?? "as every ground's"}`);
|
|
120
124
|
if (a.tint !== b.tint)
|
|
121
|
-
out.push(`${name} ground's lines
|
|
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"}`);
|
|
128
|
+
if (a.action !== b.action)
|
|
129
|
+
out.push(`${name} ground's button ${b.action ?? "as every ground's"}`);
|
|
122
130
|
}
|
|
123
131
|
}
|
|
124
132
|
if (!same(before.aliases, now.aliases))
|
|
@@ -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,
|
|
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,23 +26,40 @@ 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
|
|
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
|
}
|
|
39
|
+
const ACTION_WORDS = { tint: "As the lines", page: "Page", own: "Own", colour: "A colour" };
|
|
40
|
+
const ACTION_HINT = "The main button. As the lines: it follows them. Page: the page's button as it is, a pale brand colour its label carries. Own: the ground's colour, turned over. Or one colour, with a label measured on it or chosen.";
|
|
41
|
+
/**
|
|
42
|
+
* Where a ground's main button comes from: unset (as the lines and panels), the page's, its own
|
|
43
|
+
* colour, or one colour with its label measured on it or chosen. Shown as what applies.
|
|
44
|
+
*/
|
|
45
|
+
function ActionPicker({ value, fallback, ramps, onChange, }) {
|
|
46
|
+
const shown = value ?? fallback;
|
|
47
|
+
const [fill, label] = (shown ?? "").split("/");
|
|
48
|
+
const step = /^([a-z][\w-]*)-(\d+)$/.exec(fill);
|
|
49
|
+
const labelStep = label ? /^([a-z][\w-]*)-(\d+)$/.exec(label) : null;
|
|
50
|
+
const kind = !shown ? "tint" : shown === "page" || shown === "own" ? shown : "colour";
|
|
51
|
+
const choose = (next) => onChange(next === fallback ? undefined : next);
|
|
52
|
+
const colour = (f, l) => choose((l ? `${f}/${l}` : f));
|
|
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}`) })] })] }))] })) }));
|
|
54
|
+
}
|
|
38
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.";
|
|
39
|
-
const TINT_HINT = "
|
|
40
|
-
|
|
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. */
|
|
41
59
|
export function GroundDefaults({ edit }) {
|
|
42
60
|
const { seed, set } = edit;
|
|
43
61
|
const ramps = rampsOf(edit);
|
|
44
|
-
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
|
|
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 }) })] }));
|
|
45
63
|
}
|
|
46
64
|
/** One ground's settings, set into the page under its specimen: its colour and step, its text, its lines. */
|
|
47
65
|
export function GroundControls({ name, edit }) {
|
|
@@ -53,7 +71,7 @@ export function GroundControls({ name, edit }) {
|
|
|
53
71
|
return null;
|
|
54
72
|
const write = (patch) => {
|
|
55
73
|
const next = { ...spec, ...patch };
|
|
56
|
-
for (const k of ["tint", "text"])
|
|
74
|
+
for (const k of ["tint", "panels", "text", "action"])
|
|
57
75
|
if (next[k] === undefined)
|
|
58
76
|
delete next[k];
|
|
59
77
|
set({ grounds: { ...grounds, [name]: next } });
|
|
@@ -63,7 +81,7 @@ export function GroundControls({ name, edit }) {
|
|
|
63
81
|
set({ grounds: Object.keys(rest).length ? rest : undefined });
|
|
64
82
|
};
|
|
65
83
|
const made = system?.grounds?.[name];
|
|
66
|
-
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
|
|
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] }));
|
|
67
85
|
}
|
|
68
86
|
/** A new ground: a name, the ramp it's painted and the step. */
|
|
69
87
|
export function AddGround({ edit }) {
|
package/dist/studio/index.d.ts
CHANGED
|
@@ -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";
|
package/dist/studio/index.js
CHANGED
|
@@ -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";
|
package/dist/studio/seed.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The studio's plain logic, browser-safe: a project's generate-tokens command read into a seed, a
|
|
3
3
|
* seed turned into the generator's inputs, and the command that regenerates from a seed.
|
|
4
4
|
*/
|
|
5
|
-
import { type BrandColors, type GenerationOptions, type GroundFill, type SeedFile, type TokenSystem } from "@designtools/tokens";
|
|
5
|
+
import { type BrandColors, type GenerationOptions, type GroundAction, type GroundFill, type SeedFile, type TokenSystem } from "@designtools/tokens";
|
|
6
6
|
/** Flags that say where and how the output is written, kept when the colour moves into a seed. */
|
|
7
7
|
export interface OutputFlags {
|
|
8
8
|
format?: string;
|
|
@@ -43,11 +43,19 @@ export declare function generateFromSeed(seed: SeedFile): TokenSystem;
|
|
|
43
43
|
* tokens file uses, so added after it, it re-themes the page.
|
|
44
44
|
*/
|
|
45
45
|
export declare function studioCss(seed: SeedFile, tokens?: TokenSystem): string;
|
|
46
|
-
/**
|
|
46
|
+
/**
|
|
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)
|
|
50
|
+
*/
|
|
47
51
|
export declare function groundChoices(seed: SeedFile): Record<string, {
|
|
48
52
|
text: GroundFill;
|
|
49
53
|
tint: GroundFill;
|
|
54
|
+
panels: GroundFill;
|
|
55
|
+
action?: GroundAction;
|
|
50
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;
|
|
51
59
|
/**
|
|
52
60
|
* One ground as it would be with other choices for its text and its lines, as a rule for
|
|
53
61
|
* `selector` that writes every token it reads: a preview, generated for real, that leaves the
|
|
@@ -56,6 +64,8 @@ export declare function groundChoices(seed: SeedFile): Record<string, {
|
|
|
56
64
|
export declare function groundPreviewCss(seed: SeedFile, name: string, choice: {
|
|
57
65
|
text?: GroundFill;
|
|
58
66
|
tint?: GroundFill;
|
|
67
|
+
panels?: GroundFill;
|
|
68
|
+
action?: GroundAction;
|
|
59
69
|
}, selector: string): string | null;
|
|
60
70
|
/** The command that regenerates from a seed file, keeping how and where the output is written. */
|
|
61
71
|
export declare function seedCommand({ seedPath, output, version }: {
|
package/dist/studio/seed.js
CHANGED
|
@@ -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=…` and `--ground-
|
|
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,16 +119,26 @@ 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;
|
|
131
132
|
}
|
|
133
|
+
case "--ground-action": {
|
|
134
|
+
const entry = value();
|
|
135
|
+
const at = entry.indexOf("=");
|
|
136
|
+
if (at === -1)
|
|
137
|
+
seed.groundAction = entry;
|
|
138
|
+
else
|
|
139
|
+
perGround.push({ name: entry.slice(0, at), key: "action", fill: entry.slice(at + 1) });
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
132
142
|
case "--gamut":
|
|
133
143
|
seed.gamut = value();
|
|
134
144
|
break;
|
|
@@ -253,7 +263,9 @@ export function optionsFromSeed(seed) {
|
|
|
253
263
|
...(seed.pageSurfaces ? { pageSurfaces: seed.pageSurfaces } : {}),
|
|
254
264
|
...(seed.grounds && Object.keys(seed.grounds).length ? { grounds: seed.grounds } : {}),
|
|
255
265
|
...(seed.groundTint && seed.groundTint !== "own" ? { groundTint: seed.groundTint } : {}),
|
|
266
|
+
...(seed.groundPanels ? { groundPanels: seed.groundPanels } : {}),
|
|
256
267
|
...(seed.groundText && seed.groundText !== "page" ? { groundText: seed.groundText } : {}),
|
|
268
|
+
...(seed.groundAction ? { groundAction: seed.groundAction } : {}),
|
|
257
269
|
seedShade: seed.seedShade,
|
|
258
270
|
...(Object.keys(seedShades).length ? { seedShades } : {}),
|
|
259
271
|
...(rangeOf(seed) ? { lightnessRange: rangeOf(seed) } : {}),
|
|
@@ -288,10 +300,21 @@ export function studioCss(seed, tokens = generateFromSeed(seed)) {
|
|
|
288
300
|
const grounds = tokens.grounds && Object.fromEntries(Object.entries(tokens.grounds).map(([name, g]) => [name, { ...g, own: Object.keys(g._refs) }]));
|
|
289
301
|
return exportTokens(grounds ? { ...tokens, grounds } : tokens, "css", { colorFormat: seed.colorFormat ?? "oklch", shadeOverrides: options.shadeOverrides, seedShade: options.seedShade, seedShades: options.seedShades });
|
|
290
302
|
}
|
|
291
|
-
/**
|
|
303
|
+
/**
|
|
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)
|
|
307
|
+
*/
|
|
292
308
|
export function groundChoices(seed) {
|
|
293
|
-
return Object.fromEntries(Object.entries(seed.grounds ?? {}).map(([name, g]) =>
|
|
309
|
+
return Object.fromEntries(Object.entries(seed.grounds ?? {}).map(([name, g]) => {
|
|
310
|
+
const action = g.action ?? seed.groundAction;
|
|
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 } : {}) }];
|
|
314
|
+
}));
|
|
294
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");
|
|
295
318
|
/**
|
|
296
319
|
* One ground as it would be with other choices for its text and its lines, as a rule for
|
|
297
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.
|
|
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",
|