@designtools/tokens 0.11.1 → 0.13.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 +35 -0
- package/README.md +206 -77
- package/dist/{chunk-2UR5FIHQ.js → chunk-HK7ME2YV.js} +757 -339
- package/dist/cli.js +322 -82
- package/dist/index.d.ts +190 -77
- package/dist/index.js +13 -5
- package/dist/studio/changes.js +60 -0
- package/dist/studio/colour-editor.js +103 -31
- package/dist/studio/css.js +1 -1
- package/dist/studio/ground-controls.d.ts +49 -0
- package/dist/studio/ground-controls.js +267 -0
- package/dist/studio/index.d.ts +1 -1
- package/dist/studio/index.js +1 -1
- package/dist/studio/seed.d.ts +20 -1
- package/dist/studio/seed.js +78 -12
- package/dist/studio/studio.js +39 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -26,7 +26,6 @@ interface SemanticTokens {
|
|
|
26
26
|
success: ExtendedSemanticColor;
|
|
27
27
|
destructive: ExtendedSemanticColor;
|
|
28
28
|
warning: ExtendedSemanticColor;
|
|
29
|
-
muted: SemanticColorPair;
|
|
30
29
|
[key: string]: ExtendedSemanticColor | SemanticColorPair;
|
|
31
30
|
}
|
|
32
31
|
interface ExtendedSemanticColor {
|
|
@@ -61,27 +60,31 @@ interface SemanticColorPair {
|
|
|
61
60
|
foreground: ShadeNumber;
|
|
62
61
|
};
|
|
63
62
|
}
|
|
64
|
-
/** Tracks which
|
|
63
|
+
/** Tracks which primitive a surface value references: the neutral's step unless `colorName` says otherwise */
|
|
65
64
|
type SurfaceRef = {
|
|
66
65
|
type: "shade";
|
|
67
66
|
shade: ShadeNumber;
|
|
67
|
+
colorName?: string;
|
|
68
68
|
} | {
|
|
69
69
|
type: "white";
|
|
70
70
|
} | {
|
|
71
71
|
type: "black";
|
|
72
72
|
}
|
|
73
|
-
/** A colour passed in as it is (
|
|
73
|
+
/** A colour passed in as it is (`--canvas "#F2F2F0"`), emitted as a literal */
|
|
74
74
|
| {
|
|
75
75
|
type: "value";
|
|
76
76
|
value: string;
|
|
77
77
|
};
|
|
78
|
-
/** A
|
|
79
|
-
interface
|
|
78
|
+
/** A page surface a project adds (`--page-surface sunken=neutral@100/neutral@900`), with its measured text */
|
|
79
|
+
interface PageSurface {
|
|
80
80
|
DEFAULT: string;
|
|
81
81
|
foreground: string;
|
|
82
|
+
/** Secondary text on it: captions, dates, hints, quieter than its foreground and still reading */
|
|
83
|
+
"foreground-secondary": string;
|
|
82
84
|
_refs: {
|
|
83
85
|
DEFAULT: SurfaceRef;
|
|
84
86
|
foreground: SurfaceRef;
|
|
87
|
+
"foreground-secondary": SurfaceRef;
|
|
85
88
|
};
|
|
86
89
|
}
|
|
87
90
|
/** Each colour's WCAG ratio against each background, by mode: what can sit on the page, and where */
|
|
@@ -89,21 +92,28 @@ type PageContrast = Record<string, Record<string, number>>;
|
|
|
89
92
|
interface SurfaceTokens {
|
|
90
93
|
canvas: string;
|
|
91
94
|
"canvas-foreground": string;
|
|
95
|
+
/** Secondary text on the page: captions, dates, hints. Each surface has its own, searched to read on it */
|
|
96
|
+
"canvas-foreground-secondary": string;
|
|
92
97
|
surface: string;
|
|
93
98
|
"surface-foreground": string;
|
|
99
|
+
"surface-foreground-secondary": string;
|
|
94
100
|
overlay: string;
|
|
95
101
|
"overlay-foreground": string;
|
|
102
|
+
"overlay-foreground-secondary": string;
|
|
96
103
|
/** Primitive references for surface values (used by export layer) */
|
|
97
104
|
_refs?: {
|
|
98
105
|
canvas: SurfaceRef;
|
|
99
106
|
"canvas-foreground": SurfaceRef;
|
|
107
|
+
"canvas-foreground-secondary": SurfaceRef;
|
|
100
108
|
surface: SurfaceRef;
|
|
101
109
|
"surface-foreground": SurfaceRef;
|
|
110
|
+
"surface-foreground-secondary": SurfaceRef;
|
|
102
111
|
overlay: SurfaceRef;
|
|
103
112
|
"overlay-foreground": SurfaceRef;
|
|
113
|
+
"overlay-foreground-secondary": SurfaceRef;
|
|
104
114
|
};
|
|
105
|
-
/**
|
|
106
|
-
|
|
115
|
+
/** Page surfaces a project adds, by name, each with measured text: they follow the mode like the three above */
|
|
116
|
+
pageSurfaces?: Record<string, PageSurface>;
|
|
107
117
|
}
|
|
108
118
|
interface UtilityTokens {
|
|
109
119
|
border: string;
|
|
@@ -151,9 +161,9 @@ interface TokenSystem {
|
|
|
151
161
|
dark: UtilityTokens;
|
|
152
162
|
};
|
|
153
163
|
/**
|
|
154
|
-
* Every semantic fill, and
|
|
155
|
-
* (canvas, surface, overlay and each
|
|
156
|
-
* their own fills; this is the rest: red text on the page, a button on a dark
|
|
164
|
+
* Every semantic fill, and each surface's secondary text, measured as WCAG ratios against every background
|
|
165
|
+
* (canvas, surface, overlay, each page surface and each ground), per mode. Labels are checked
|
|
166
|
+
* against their own fills; this is the rest: red text on the page, a button on a dark band.
|
|
157
167
|
*/
|
|
158
168
|
pageContrast?: {
|
|
159
169
|
light: PageContrast;
|
|
@@ -173,42 +183,71 @@ interface TokenSystem {
|
|
|
173
183
|
dark: Record<string, string>;
|
|
174
184
|
};
|
|
175
185
|
/**
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* the everyday names (`--primary`, `--muted-foreground`) at them. See `grounds.ts`.
|
|
186
|
+
* Each ground: a section painted one step of a ramp, the same in either mode, with the tokens
|
|
187
|
+
* content needs on it. Emitted as a `[data-surface="<ground>"]` scope that writes what differs
|
|
188
|
+
* from the page's tokens of the ground's polarity. See `grounds.ts`.
|
|
180
189
|
*/
|
|
181
|
-
grounds?:
|
|
182
|
-
light: Record<string, GroundTokens>;
|
|
183
|
-
dark: Record<string, GroundTokens>;
|
|
184
|
-
};
|
|
190
|
+
grounds?: Record<string, GroundTokens>;
|
|
185
191
|
/** The same system on wide-gamut ramps. Present only with `gamut: "p3"`. */
|
|
186
192
|
p3?: GamutTokens;
|
|
187
193
|
}
|
|
188
|
-
/**
|
|
189
|
-
|
|
190
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Where a ground's tokens come from, for its text and for everything else (its tint).
|
|
196
|
+
* `page`: the page's own tokens of the ground's polarity, wherever they read; `own`: steps on
|
|
197
|
+
* the ground's own ramp, searched to their floors; or one colour for all of them: `white`,
|
|
198
|
+
* `black`, or a step written `<ramp>-<step>` (`sage-100`).
|
|
199
|
+
*/
|
|
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}`;
|
|
212
|
+
/** A ground as declared: the ramp and step it is painted, and where its tokens come from */
|
|
213
|
+
interface GroundSpec {
|
|
214
|
+
ramp: string;
|
|
215
|
+
step: ShadeNumber;
|
|
216
|
+
/** Lines, panels, the card, the input edge, the ring and the buttons. Default: `own` */
|
|
217
|
+
tint?: GroundFill;
|
|
218
|
+
/** Body and secondary text. Default: `page` */
|
|
219
|
+
text?: GroundFill;
|
|
220
|
+
/** The main button. Default: unset, following the tint */
|
|
221
|
+
action?: GroundAction;
|
|
222
|
+
}
|
|
223
|
+
/** Where a ground token comes from: a ramp step, black or white (a page surface given as a colour stays a value) */
|
|
191
224
|
type GroundRef = ForegroundRef | {
|
|
192
225
|
type: "value";
|
|
193
226
|
value: string;
|
|
194
227
|
};
|
|
195
228
|
/**
|
|
196
|
-
* One ground
|
|
229
|
+
* One ground: a section painted a step of a ramp, and the tokens content needs on it.
|
|
197
230
|
*
|
|
198
|
-
*
|
|
199
|
-
* `canvas-foreground
|
|
200
|
-
* `
|
|
201
|
-
* `-subdued-foreground`, `-hover
|
|
202
|
-
*
|
|
231
|
+
* `tokens` and `_refs` hold every token as it reads inside the ground, under the page's own
|
|
232
|
+
* names (`canvas`, `canvas-foreground`, `canvas-foreground-secondary`, `border`, `input`, `ring`,
|
|
233
|
+
* `surface`, `surface-foreground`, `surface-foreground-secondary`, and each semantic colour's fill, `-foreground`, `-subdued`,
|
|
234
|
+
* `-subdued-foreground`, `-hover`, `-active`). Everything the ground doesn't change is the page's
|
|
235
|
+
* token of the ground's polarity (`polarity`); `own` lists what the ground writes itself.
|
|
203
236
|
*/
|
|
204
237
|
interface GroundTokens {
|
|
205
|
-
|
|
206
|
-
|
|
238
|
+
ramp: string;
|
|
239
|
+
step: ShadeNumber;
|
|
240
|
+
/** Whether the ground reads as light (dark text) or dark (light text): which page mode it borrows */
|
|
241
|
+
polarity: "light" | "dark";
|
|
242
|
+
tint: GroundFill;
|
|
243
|
+
text: GroundFill;
|
|
244
|
+
/** Where its main button comes from, when it doesn't follow the tint */
|
|
245
|
+
action?: GroundAction;
|
|
207
246
|
tokens: Record<string, string>;
|
|
208
247
|
_refs: Record<string, GroundRef>;
|
|
209
|
-
/**
|
|
210
|
-
|
|
211
|
-
/** What
|
|
248
|
+
/** The tokens this ground writes, in order: those that differ from the page's of its polarity */
|
|
249
|
+
own: string[];
|
|
250
|
+
/** What a value can't reach, in words, for the report */
|
|
212
251
|
notes: string[];
|
|
213
252
|
}
|
|
214
253
|
/** Contrast algorithm choice */
|
|
@@ -287,10 +326,13 @@ interface FamilyShape {
|
|
|
287
326
|
interface SurfaceShadeOverrides {
|
|
288
327
|
canvas?: ShadeNumber | "white" | "black";
|
|
289
328
|
"canvas-foreground"?: ShadeNumber | "white" | "black";
|
|
329
|
+
"canvas-foreground-secondary"?: ShadeNumber;
|
|
290
330
|
surface?: ShadeNumber | "white" | "black";
|
|
291
331
|
"surface-foreground"?: ShadeNumber | "white" | "black";
|
|
332
|
+
"surface-foreground-secondary"?: ShadeNumber;
|
|
292
333
|
overlay?: ShadeNumber | "white" | "black";
|
|
293
334
|
"overlay-foreground"?: ShadeNumber | "white" | "black";
|
|
335
|
+
"overlay-foreground-secondary"?: ShadeNumber;
|
|
294
336
|
}
|
|
295
337
|
/** Per-utility-token shade overrides */
|
|
296
338
|
interface UtilityShadeOverrides {
|
|
@@ -355,8 +397,8 @@ interface GenerationOptions {
|
|
|
355
397
|
pins?: Record<string, Partial<Record<ShadeNumber, string>>>;
|
|
356
398
|
/**
|
|
357
399
|
* Whether the status ramps also get their everyday names: `green`, `red` and `yellow` as the same
|
|
358
|
-
* ramps as `success`, `destructive` and `warning`, so `bg-red-500` matches. Default
|
|
359
|
-
*
|
|
400
|
+
* ramps as `success`, `destructive` and `warning`, so `bg-red-500` matches. Default false: each
|
|
401
|
+
* ramp is emitted once, under its semantic name (before 0.12 the default was true).
|
|
360
402
|
*/
|
|
361
403
|
aliases?: boolean;
|
|
362
404
|
/**
|
|
@@ -387,22 +429,29 @@ interface GenerationOptions {
|
|
|
387
429
|
dark?: Partial<Record<"canvas" | "surface" | "overlay", string>>;
|
|
388
430
|
};
|
|
389
431
|
/**
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
432
|
+
* Page surfaces a project adds beside canvas, surface and overlay, by name: a sunken well, a
|
|
433
|
+
* raised panel, an alternate section. Each is a ramp step per mode, written `<ramp>@<step>`
|
|
434
|
+
* (`{ sunken: { light: "neutral@100", dark: "neutral@900" } }`); `dark` defaults to the light
|
|
435
|
+
* step's mirror on the same ramp (100 to 800). Emitted as `--<name>` with a measured
|
|
436
|
+
* `--<name>-foreground`, in the mode blocks, and every page token is searched to work on it.
|
|
395
437
|
*/
|
|
396
|
-
|
|
438
|
+
pageSurfaces?: Record<string, {
|
|
397
439
|
light: string;
|
|
398
440
|
dark?: string;
|
|
399
441
|
}>;
|
|
400
442
|
/**
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
443
|
+
* Grounds: sections painted one step of a ramp, the same in light and dark mode, by name:
|
|
444
|
+
* `{ pine: { ramp: "pine", step: 800, tint: "white" } }`. Inside `data-surface="<name>"` content
|
|
445
|
+
* reads tokens that work on it (see `grounds.ts`). The ramp is any colour's: a `--color`, often
|
|
446
|
+
* decorative, or `primary` for a brand band.
|
|
404
447
|
*/
|
|
405
|
-
grounds?:
|
|
448
|
+
grounds?: Record<string, GroundSpec>;
|
|
449
|
+
/** Where every ground's tint comes from, unless it says otherwise. Default `own` */
|
|
450
|
+
groundTint?: GroundFill;
|
|
451
|
+
/** Where every ground's text comes from, unless it says otherwise. Default `page` */
|
|
452
|
+
groundText?: GroundFill;
|
|
453
|
+
/** Where every ground's main button comes from, unless it says otherwise. Default: the tint's */
|
|
454
|
+
groundAction?: GroundAction;
|
|
406
455
|
/**
|
|
407
456
|
* Which steps to emit. Default: all twelve (25–950).
|
|
408
457
|
* Tokens naming a dropped step are snapped to the nearest emitted one.
|
|
@@ -475,8 +524,11 @@ interface SavedConfig {
|
|
|
475
524
|
foreground?: GenerationOptions["foreground"];
|
|
476
525
|
wcagFloor?: boolean;
|
|
477
526
|
surfaceColors?: GenerationOptions["surfaceColors"];
|
|
478
|
-
|
|
479
|
-
grounds?:
|
|
527
|
+
pageSurfaces?: GenerationOptions["pageSurfaces"];
|
|
528
|
+
grounds?: GenerationOptions["grounds"];
|
|
529
|
+
groundTint?: GroundFill;
|
|
530
|
+
groundText?: GroundFill;
|
|
531
|
+
groundAction?: GroundAction;
|
|
480
532
|
shadeOverrides: SemanticShadeOverrides;
|
|
481
533
|
surfaceShadeOverrides?: GenerationOptions["surfaceShadeOverrides"];
|
|
482
534
|
utilityShadeOverrides?: GenerationOptions["utilityShadeOverrides"];
|
|
@@ -772,10 +824,12 @@ interface SemanticGamuts {
|
|
|
772
824
|
declare function generateSemanticTokens(palette: PrimitivePalette, mode: "light" | "dark", options?: Partial<GenerationOptions>, gamuts?: SemanticGamuts,
|
|
773
825
|
/** The backgrounds this mode paints (canvas, surface, overlay, named): status text must read on all */
|
|
774
826
|
pageGrounds?: readonly string[]): SemanticTokens;
|
|
775
|
-
declare function generateSurfaceTokens(palette: PrimitivePalette, mode: "light" | "dark", overrides?: Partial<SurfaceShadeOverrides>, shades?: readonly ShadeNumber[], colors?: Partial<Record<"canvas" | "surface" | "overlay", string>>,
|
|
827
|
+
declare function generateSurfaceTokens(palette: PrimitivePalette, mode: "light" | "dark", overrides?: Partial<SurfaceShadeOverrides>, shades?: readonly ShadeNumber[], colors?: Partial<Record<"canvas" | "surface" | "overlay", string>>, pageSurfaces?: Record<string, {
|
|
776
828
|
light: string;
|
|
777
829
|
dark?: string;
|
|
778
|
-
}
|
|
830
|
+
}>,
|
|
831
|
+
/** The text floor secondary text is searched to: 4.5, or 7 at AAA */
|
|
832
|
+
textFloor?: number): SurfaceTokens;
|
|
779
833
|
/**
|
|
780
834
|
* Generate utility tokens for borders, rings, inputs, shadow
|
|
781
835
|
*/
|
|
@@ -799,7 +853,7 @@ declare function checkSemanticContrastAPCA(tokens: SemanticTokens, gamut?: Gamut
|
|
|
799
853
|
/**
|
|
800
854
|
* Contrast for the pairings the semantic check never looked at.
|
|
801
855
|
*
|
|
802
|
-
* `checkSemanticContrast` covers the extended families
|
|
856
|
+
* `checkSemanticContrast` covers the extended families. That leaves
|
|
803
857
|
* the ground a page is actually painted on — canvas, surface, overlay — and the
|
|
804
858
|
* focus ring, unmeasured. The ground is the thing projects most often override,
|
|
805
859
|
* and an unreadable focus ring is an accessibility defect that no other check
|
|
@@ -836,7 +890,7 @@ declare function checkRampChroma(palette: PrimitivePalette): Record<string, {
|
|
|
836
890
|
/**
|
|
837
891
|
* Compute an overall accessibility score for the token system.
|
|
838
892
|
*
|
|
839
|
-
* Counts every extended-family pairing
|
|
893
|
+
* Counts every extended-family pairing. Neutral is
|
|
840
894
|
* deliberately included: it is the pairing most likely to fail on a default
|
|
841
895
|
* seed, and a score that quietly dropped it would flatter the palette exactly
|
|
842
896
|
* where a reader most needs the warning.
|
|
@@ -865,6 +919,20 @@ declare function computeAccessibilityScore(tokens: SemanticTokens, algorithm: Co
|
|
|
865
919
|
* keeps the sRGB values, which are complete and contrast-checked on their own.
|
|
866
920
|
*/
|
|
867
921
|
declare const WIDE_GAMUT_QUERY = "@media (color-gamut: p3)";
|
|
922
|
+
/**
|
|
923
|
+
* The selectors each mode block is emitted under, with the grounds.
|
|
924
|
+
*
|
|
925
|
+
* A ground is the same colour in either mode, so everything inside it that it doesn't change is
|
|
926
|
+
* the page's token of the ground's polarity: a light ground's selector joins the light block, a
|
|
927
|
+
* dark ground's the dark block, and the right values apply inside it whatever the page's mode.
|
|
928
|
+
* `data-surface="canvas"` resets to the page as it is: on the light block plainly, and on the
|
|
929
|
+
* dark ones under a dark page, where the more specific selector wins.
|
|
930
|
+
*/
|
|
931
|
+
declare function modeSelectors(tokens: TokenSystem): {
|
|
932
|
+
light: string;
|
|
933
|
+
dark: string;
|
|
934
|
+
systemDark: string;
|
|
935
|
+
};
|
|
868
936
|
/** The selector a ground's scope is emitted under */
|
|
869
937
|
declare const GROUND_SELECTOR: (ground: string) => string;
|
|
870
938
|
/**
|
|
@@ -1081,28 +1149,30 @@ declare class APCAUnavailableError extends Error {
|
|
|
1081
1149
|
declare function isAPCAAvailable(): boolean;
|
|
1082
1150
|
|
|
1083
1151
|
/**
|
|
1084
|
-
* Grounds:
|
|
1152
|
+
* Grounds: sections painted one step of a ramp, and the tokens content needs on them.
|
|
1085
1153
|
*
|
|
1086
|
-
* The page tokens are searched against the
|
|
1087
|
-
*
|
|
1088
|
-
*
|
|
1089
|
-
*
|
|
1154
|
+
* The page's tokens are searched against the page's surfaces. A section painted a colour (a deep
|
|
1155
|
+
* green band, a lime page) is somewhere they may not work: a primary button on a primary band is
|
|
1156
|
+
* 1:1, a caption on a dark band unreadable. A ground is that section, declared as a ramp and a
|
|
1157
|
+
* step (`pine@800`), and it gets tokens that work on it.
|
|
1090
1158
|
*
|
|
1091
|
-
*
|
|
1092
|
-
*
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1159
|
+
* A ground is the same colour in light and dark mode, so it has one set of tokens, and they start
|
|
1160
|
+
* from the page's tokens of its own polarity: a light ground from the light page's, a dark one
|
|
1161
|
+
* from the dark page's. The exports put each ground's selector on that mode block, so everything
|
|
1162
|
+
* a ground doesn't change is already right inside it in either mode. The ground's own scope then
|
|
1163
|
+
* writes only what differs, every value a ramp step (or white or black), never a computed colour.
|
|
1096
1164
|
*
|
|
1097
|
-
*
|
|
1098
|
-
*
|
|
1099
|
-
*
|
|
1165
|
+
* What differs comes from two choices per ground:
|
|
1166
|
+
* - tint, for lines, panels, the card, the input edge, the ring and the buttons;
|
|
1167
|
+
* - text, for body and secondary text.
|
|
1168
|
+
* Each is `page` (the page's tokens, where they read), `own` (steps on the ground's ramp, each
|
|
1169
|
+
* searched to its floor) or one colour (`white`, `black`, `sage-100`). Any other colour (accent,
|
|
1170
|
+
* success, a brand's own) keeps the page's value unless that fails on the ground, and is then
|
|
1171
|
+
* searched along its own ramp.
|
|
1100
1172
|
*/
|
|
1101
1173
|
|
|
1102
|
-
/** The status colours whose tints are grounds by default: a banner, an alert, an inline message */
|
|
1103
|
-
declare const STATUS_GROUNDS: readonly ["success", "warning", "destructive"];
|
|
1104
1174
|
/** The non-colour tokens every ground carries, in the order they are emitted */
|
|
1105
|
-
declare const GROUND_BASE_TOKENS: readonly ["canvas", "canvas-foreground", "
|
|
1175
|
+
declare const GROUND_BASE_TOKENS: readonly ["canvas", "canvas-foreground", "canvas-foreground-secondary", "border", "input", "ring", "surface", "surface-foreground", "surface-foreground-secondary"];
|
|
1106
1176
|
/** What each semantic colour carries inside a ground */
|
|
1107
1177
|
declare const GROUND_COLOR_PARTS: readonly ["", "-foreground", "-subdued", "-subdued-foreground", "-hover", "-active"];
|
|
1108
1178
|
interface View {
|
|
@@ -1111,26 +1181,27 @@ interface View {
|
|
|
1111
1181
|
}
|
|
1112
1182
|
/** Every token name a ground carries, for these semantic colours */
|
|
1113
1183
|
declare function groundTokenNames(colors: readonly string[]): string[];
|
|
1184
|
+
/** The page tokens a page surface's name can't take: it is emitted as `--<name>` beside them */
|
|
1185
|
+
declare function reservedSurfaceNames(colors: readonly string[]): string[];
|
|
1114
1186
|
/**
|
|
1115
|
-
*
|
|
1116
|
-
*
|
|
1117
|
-
*
|
|
1187
|
+
* The step a colour lands on by its lightness, on a ramp anchored where the system anchors by
|
|
1188
|
+
* default: a deep green near 900, a pale blue-grey near 200. What `--color name=colour@step`
|
|
1189
|
+
* should say for a colour that is to be painted as it is, as the CLI suggests in place of a
|
|
1190
|
+
* `--background`.
|
|
1118
1191
|
*/
|
|
1119
|
-
declare function
|
|
1192
|
+
declare function suggestStep(color: string, options?: Partial<GenerationOptions>): ShadeNumber;
|
|
1120
1193
|
/**
|
|
1121
|
-
* Every ground's tokens
|
|
1122
|
-
*
|
|
1123
|
-
* `views` is the palette the tokens resolve against, then any other gamut's: a pairing must
|
|
1124
|
-
* pass on every display the system is generated for.
|
|
1194
|
+
* Every ground's tokens. `views` is the palette the tokens resolve against, then any other
|
|
1195
|
+
* gamut's: a pairing must pass on every display the system is generated for.
|
|
1125
1196
|
*/
|
|
1126
1197
|
declare function generateGroundTokens(tiers: {
|
|
1127
1198
|
semantic: Record<"light" | "dark", SemanticTokens>;
|
|
1128
1199
|
surface: Record<"light" | "dark", SurfaceTokens>;
|
|
1129
1200
|
utility: Record<"light" | "dark", UtilityTokens>;
|
|
1130
|
-
},
|
|
1201
|
+
}, views: readonly View[], options?: Partial<GenerationOptions>): Record<string, GroundTokens>;
|
|
1131
1202
|
|
|
1132
1203
|
/**
|
|
1133
|
-
* Where each colour can go: every semantic fill, status text tone and
|
|
1204
|
+
* Where each colour can go: every semantic fill, status text tone and secondary text measured
|
|
1134
1205
|
* against every background a mode paints, with a verdict. Written beside the CSS with
|
|
1135
1206
|
* `--usage <file>` for @designtools/manifest, which turns the failures into usage rules a
|
|
1136
1207
|
* person reads on the rules page and an agent reads in rules.json. Deterministic: the same
|
|
@@ -1184,4 +1255,46 @@ interface ContractBreak {
|
|
|
1184
1255
|
/** Every step whose promise differs between colours, light to dark. Empty when every step means the same everywhere. */
|
|
1185
1256
|
declare function stepContract(palette: PrimitivePalette): ContractBreak[];
|
|
1186
1257
|
|
|
1187
|
-
|
|
1258
|
+
/**
|
|
1259
|
+
* The non-colour scale: space, size, type, radius, shadow, motion, screen sizes and widths. The colour
|
|
1260
|
+
* generator works a palette out from a seed; the scale has no seed, so this is a set of defaults, written
|
|
1261
|
+
* in every format the colour is, and retuned with overrides rather than by hand. The names are the
|
|
1262
|
+
* contract and the values are art direction: override the values, keep the names.
|
|
1263
|
+
*
|
|
1264
|
+
* The names are the CSS custom properties Tailwind v4 reads as theme namespaces (`--text-*`,
|
|
1265
|
+
* `--breakpoint-*`, `--container-*`), which makes each one a utility on Tailwind and a plain variable
|
|
1266
|
+
* everywhere else. Space is the gap between things (`--spacing`, one multiplier); size is the extent of a
|
|
1267
|
+
* thing (`--size-*`). Containers and screen sizes are scales too; a page's grid is composed from them and
|
|
1268
|
+
* from space, not named as tokens of its own.
|
|
1269
|
+
*/
|
|
1270
|
+
type ScaleTierId = "spacing" | "size" | "text" | "leading" | "tracking" | "font-weight" | "radius" | "shadow" | "duration" | "ease" | "breakpoint" | "container";
|
|
1271
|
+
interface ScaleToken {
|
|
1272
|
+
/** The custom property: `--text-sm`, `--text-sm--line-height`. */
|
|
1273
|
+
name: string;
|
|
1274
|
+
value: string;
|
|
1275
|
+
description?: string;
|
|
1276
|
+
}
|
|
1277
|
+
interface ScaleTier {
|
|
1278
|
+
id: ScaleTierId;
|
|
1279
|
+
title: string;
|
|
1280
|
+
/** Whether Tailwind v4 has a theme namespace for it. Without one it is a plain variable in `:root`. */
|
|
1281
|
+
themed: boolean;
|
|
1282
|
+
tokens: ScaleToken[];
|
|
1283
|
+
}
|
|
1284
|
+
/** The defaults. Every value is art direction a project retunes with overrides; the names stay. */
|
|
1285
|
+
declare function defaultScale(): ScaleTier[];
|
|
1286
|
+
/** An override: a value, a value with its description, or `null` to remove the token. */
|
|
1287
|
+
type ScaleOverride = string | {
|
|
1288
|
+
value: string;
|
|
1289
|
+
description?: string;
|
|
1290
|
+
} | null;
|
|
1291
|
+
/**
|
|
1292
|
+
* The defaults with a project's overrides applied, by token name: a new value (and description) for a
|
|
1293
|
+
* token, a new token in the tier its name belongs to, or `null` to drop one. A name in no tier is an
|
|
1294
|
+
* error, so a typo can't quietly add nothing.
|
|
1295
|
+
*/
|
|
1296
|
+
declare function applyScaleOverrides(tiers: ScaleTier[], overrides: Record<string, ScaleOverride>): ScaleTier[];
|
|
1297
|
+
type ScaleFormat = "css" | "tailwind-v4" | "tailwind-v3" | "dtcg" | "json";
|
|
1298
|
+
declare function exportScale(tiers: ScaleTier[], format: ScaleFormat, header?: string): string;
|
|
1299
|
+
|
|
1300
|
+
export { ALIAS_PAIRS, type APCAContrastResult, APCAUnavailableError, type BrandColors, type CVDType, type ChromaProfile, type ChromaShape, type ColorFormat, type ColorScale, type ContractBreak, type ContrastAlgorithm, type ContrastTarget, DEFAULT_NEUTRAL_COLOR, DEFAULT_SEED_SHADE, type Declaration, type ExportFormat, type ExportOptions, type ExtendedSemanticColor, type FamilyShape, type ForegroundRef, GENERATOR_NAME, GROUND_BASE_TOKENS, GROUND_COLOR_PARTS, GROUND_SELECTOR, type Gamut, type GamutTokens, type GenerationOptions, type GroundAction, type GroundColour, type GroundFill, type GroundRef, type GroundSpec, type GroundTokens, type HueDrift, type LightnessStrategy, type MergeResult, type PageContrast, type PageSurface, type PaletteOptions, type PrimitivePalette, type Provenance, SECTIONED_FORMATS, SHADE_PRESETS, type SavedConfig, type ScaleFormat, type ScaleOptions, type ScaleOverride, type ScaleTier, type ScaleTierId, type ScaleToken, type SeedFile, type SelectedTokens, type SemanticColorPair, type SemanticGamuts, type SemanticShadeOverrides, type SemanticTokens, type ShadeNumber, type SliceDiff, type SurfaceRef, type SurfaceShadeOverrides, type SurfaceTokens, TAILWIND_SHADES, TOKEN_SECTIONS, type TokenSection, type TokenSystem, type UsageReport, type UsageVerdict, type UtilityShadeOverrides, type UtilityTokens, VALID_SHADES, type VariantShadeOverrides, type WCAGContrastResult, WIDE_GAMUT_QUERY, adjustChroma, adjustLightness, aliasOf, applyScaleOverrides, checkRampChroma, checkSemanticContrast, checkSemanticContrastAPCA, checkSurfaceContrast, chromaShadeFor, classifyAPCALevel, computeAccessibilityScore, defaultScale, diffSlice, exportScale, exportToCss, exportToDtcg, exportToTailwindV3, exportToTailwindV4, exportTokens, externalReferences, familiesOf, familySeedShade, findContrastingColorAPCA, fingerprint, formatColorAs, formatColorShort, formatOklchInGamut, generateColorScale, generateColorScaleAPCA, generateGroundTokens, generatePrimitivePalette, generateSemanticTokens, generateSurfaceTokens, generateTokens, generateUtilityTokens, getAPCAContrast, getContrastRatio, getOklchString, getRelativeLuminance, getShade, groundTokenNames, isAPCAAvailable, isInGamut, meetsWCAG_AA, meetsWCAG_AAA, mergeSlice, modeSelectors, oklchToHex, parseProvenance, parseToOklch, provenanceComment, rangeOf, readDeclarations, reanchorFactors, reservedSurfaceNames, resolveShades, seedFingerprint, selectTokenSections, serialiseUsage, simulateCVD, snapShade, stableStringify, stepContract, suggestStep, tokenFamilies, usageReport, withJsonProvenance };
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
GROUND_SELECTOR,
|
|
10
10
|
SECTIONED_FORMATS,
|
|
11
11
|
SHADE_PRESETS,
|
|
12
|
-
STATUS_GROUNDS,
|
|
13
12
|
TAILWIND_SHADES,
|
|
14
13
|
TOKEN_SECTIONS,
|
|
15
14
|
VALID_SHADES,
|
|
@@ -17,6 +16,7 @@ import {
|
|
|
17
16
|
adjustChroma,
|
|
18
17
|
adjustLightness,
|
|
19
18
|
aliasOf,
|
|
19
|
+
applyScaleOverrides,
|
|
20
20
|
checkRampChroma,
|
|
21
21
|
checkSemanticContrast,
|
|
22
22
|
checkSemanticContrastAPCA,
|
|
@@ -24,7 +24,9 @@ import {
|
|
|
24
24
|
chromaShadeFor,
|
|
25
25
|
classifyAPCALevel,
|
|
26
26
|
computeAccessibilityScore,
|
|
27
|
+
defaultScale,
|
|
27
28
|
diffSlice,
|
|
29
|
+
exportScale,
|
|
28
30
|
exportToCss,
|
|
29
31
|
exportToDtcg,
|
|
30
32
|
exportToTailwindV3,
|
|
@@ -57,6 +59,7 @@ import {
|
|
|
57
59
|
meetsWCAG_AA,
|
|
58
60
|
meetsWCAG_AAA,
|
|
59
61
|
mergeSlice,
|
|
62
|
+
modeSelectors,
|
|
60
63
|
oklchToHex,
|
|
61
64
|
parseProvenance,
|
|
62
65
|
parseToOklch,
|
|
@@ -64,7 +67,7 @@ import {
|
|
|
64
67
|
rangeOf,
|
|
65
68
|
readDeclarations,
|
|
66
69
|
reanchorFactors,
|
|
67
|
-
|
|
70
|
+
reservedSurfaceNames,
|
|
68
71
|
resolveShades,
|
|
69
72
|
seedFingerprint,
|
|
70
73
|
selectTokenSections,
|
|
@@ -73,10 +76,11 @@ import {
|
|
|
73
76
|
snapShade,
|
|
74
77
|
stableStringify,
|
|
75
78
|
stepContract,
|
|
79
|
+
suggestStep,
|
|
76
80
|
tokenFamilies,
|
|
77
81
|
usageReport,
|
|
78
82
|
withJsonProvenance
|
|
79
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-HK7ME2YV.js";
|
|
80
84
|
export {
|
|
81
85
|
ALIAS_PAIRS,
|
|
82
86
|
APCAUnavailableError,
|
|
@@ -88,7 +92,6 @@ export {
|
|
|
88
92
|
GROUND_SELECTOR,
|
|
89
93
|
SECTIONED_FORMATS,
|
|
90
94
|
SHADE_PRESETS,
|
|
91
|
-
STATUS_GROUNDS,
|
|
92
95
|
TAILWIND_SHADES,
|
|
93
96
|
TOKEN_SECTIONS,
|
|
94
97
|
VALID_SHADES,
|
|
@@ -96,6 +99,7 @@ export {
|
|
|
96
99
|
adjustChroma,
|
|
97
100
|
adjustLightness,
|
|
98
101
|
aliasOf,
|
|
102
|
+
applyScaleOverrides,
|
|
99
103
|
checkRampChroma,
|
|
100
104
|
checkSemanticContrast,
|
|
101
105
|
checkSemanticContrastAPCA,
|
|
@@ -103,7 +107,9 @@ export {
|
|
|
103
107
|
chromaShadeFor,
|
|
104
108
|
classifyAPCALevel,
|
|
105
109
|
computeAccessibilityScore,
|
|
110
|
+
defaultScale,
|
|
106
111
|
diffSlice,
|
|
112
|
+
exportScale,
|
|
107
113
|
exportToCss,
|
|
108
114
|
exportToDtcg,
|
|
109
115
|
exportToTailwindV3,
|
|
@@ -136,6 +142,7 @@ export {
|
|
|
136
142
|
meetsWCAG_AA,
|
|
137
143
|
meetsWCAG_AAA,
|
|
138
144
|
mergeSlice,
|
|
145
|
+
modeSelectors,
|
|
139
146
|
oklchToHex,
|
|
140
147
|
parseProvenance,
|
|
141
148
|
parseToOklch,
|
|
@@ -143,7 +150,7 @@ export {
|
|
|
143
150
|
rangeOf,
|
|
144
151
|
readDeclarations,
|
|
145
152
|
reanchorFactors,
|
|
146
|
-
|
|
153
|
+
reservedSurfaceNames,
|
|
147
154
|
resolveShades,
|
|
148
155
|
seedFingerprint,
|
|
149
156
|
selectTokenSections,
|
|
@@ -152,6 +159,7 @@ export {
|
|
|
152
159
|
snapShade,
|
|
153
160
|
stableStringify,
|
|
154
161
|
stepContract,
|
|
162
|
+
suggestStep,
|
|
155
163
|
tokenFamilies,
|
|
156
164
|
usageReport,
|
|
157
165
|
withJsonProvenance
|
package/dist/studio/changes.js
CHANGED
|
@@ -72,6 +72,66 @@ export function describeChanges(before, now) {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
+
for (const mode of ["light", "dark"]) {
|
|
76
|
+
for (const key of ["canvas", "surface", "overlay"]) {
|
|
77
|
+
const x = before.surfaceColors?.[mode]?.[key];
|
|
78
|
+
const y = now.surfaceColors?.[mode]?.[key];
|
|
79
|
+
if (x !== y)
|
|
80
|
+
out.push(y ? `${key} ${y} in ${mode}` : `${key} generated again in ${mode}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
for (const key of ["surfaceShadeOverrides", "utilityShadeOverrides"]) {
|
|
84
|
+
for (const mode of ["light", "dark"]) {
|
|
85
|
+
const a = (before[key]?.[mode] ?? {});
|
|
86
|
+
const b = (now[key]?.[mode] ?? {});
|
|
87
|
+
for (const token of new Set([...Object.keys(a), ...Object.keys(b)])) {
|
|
88
|
+
if (a[token] !== b[token])
|
|
89
|
+
out.push(b[token] !== undefined ? `${token} on ${b[token]} in ${mode}` : `${token} back to the generator's choice in ${mode}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const surfaces = new Set([...Object.keys(before.pageSurfaces ?? {}), ...Object.keys(now.pageSurfaces ?? {})]);
|
|
94
|
+
for (const name of surfaces) {
|
|
95
|
+
const a = before.pageSurfaces?.[name];
|
|
96
|
+
const b = now.pageSurfaces?.[name];
|
|
97
|
+
if (same(a, b))
|
|
98
|
+
continue;
|
|
99
|
+
out.push(!b ? `${name} surface removed` : `${name} surface ${b.light}${b.dark ? `/${b.dark}` : ""}${a ? "" : " added"}`);
|
|
100
|
+
}
|
|
101
|
+
if (!same(before.groundText, now.groundText))
|
|
102
|
+
out.push(`every ground's text ${now.groundText ?? "page"}`);
|
|
103
|
+
if (!same(before.groundTint, now.groundTint))
|
|
104
|
+
out.push(`every ground's lines and panels ${now.groundTint ?? "own"}`);
|
|
105
|
+
if (!same(before.groundAction, now.groundAction))
|
|
106
|
+
out.push(`every ground's button ${now.groundAction ?? "as its lines"}`);
|
|
107
|
+
const grounds = new Set([...Object.keys(before.grounds ?? {}), ...Object.keys(now.grounds ?? {})]);
|
|
108
|
+
for (const name of grounds) {
|
|
109
|
+
const a = before.grounds?.[name];
|
|
110
|
+
const b = now.grounds?.[name];
|
|
111
|
+
if (same(a, b))
|
|
112
|
+
continue;
|
|
113
|
+
if (!b)
|
|
114
|
+
out.push(`${name} ground removed`);
|
|
115
|
+
else if (!a)
|
|
116
|
+
out.push(`${name} ground added, ${b.ramp}@${b.step}`);
|
|
117
|
+
else {
|
|
118
|
+
if (a.ramp !== b.ramp || a.step !== b.step)
|
|
119
|
+
out.push(`${name} ground painted ${b.ramp}@${b.step}`);
|
|
120
|
+
if (a.text !== b.text)
|
|
121
|
+
out.push(`${name} ground's text ${b.text ?? "as every ground's"}`);
|
|
122
|
+
if (a.tint !== b.tint)
|
|
123
|
+
out.push(`${name} ground's lines and panels ${b.tint ?? "as every ground's"}`);
|
|
124
|
+
if (a.action !== b.action)
|
|
125
|
+
out.push(`${name} ground's button ${b.action ?? "as every ground's"}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (!same(before.aliases, now.aliases))
|
|
129
|
+
out.push(now.aliases ? "everyday names (green, red, yellow) on" : "everyday names off");
|
|
130
|
+
if (!same(before.gamut, now.gamut))
|
|
131
|
+
out.push(`screens ${now.gamut ?? "srgb"}`);
|
|
132
|
+
const decorative = (s) => (s.additionalColors ?? []).filter((c) => c.decorative).map((c) => c.name).sort();
|
|
133
|
+
if (!same(decorative(before), decorative(now)))
|
|
134
|
+
out.push(`ramps only: ${decorative(now).join(", ") || "none"}`);
|
|
75
135
|
return out;
|
|
76
136
|
}
|
|
77
137
|
/** Where a link carries a seed: the page's hash, so nothing reaches the server. */
|