@atomic-ui/design-tokens 0.0.0-stage → 0.1.1
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/README.md +87 -2
- package/dist/chunk-YUZFJX3U.js +40 -0
- package/dist/chunk-YUZFJX3U.js.map +1 -0
- package/dist/contrast.d.ts +96 -0
- package/dist/css.d.ts +42 -0
- package/dist/css.js +17 -0
- package/dist/css.js.map +1 -0
- package/dist/derive.d.ts +18 -0
- package/dist/dtcg.d.ts +27 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +393 -0
- package/dist/index.js.map +1 -0
- package/dist/inputs.d.ts +285 -0
- package/dist/tailwind.d.ts +70 -0
- package/dist/tailwind.js +69 -0
- package/dist/tailwind.js.map +1 -0
- package/dist/validate.d.ts +23 -0
- package/package.json +41 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PREFIX,
|
|
3
|
+
cssVarName,
|
|
4
|
+
escapeStyleText,
|
|
5
|
+
toCssDeclarations,
|
|
6
|
+
toStyleProperties,
|
|
7
|
+
toStylesheet
|
|
8
|
+
} from "./chunk-YUZFJX3U.js";
|
|
9
|
+
|
|
10
|
+
// packages/design-tokens/src/inputs.ts
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
var HexColorSchema = z.string().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, "Must be a hex colour, e.g. #5e10b1");
|
|
13
|
+
var SurfaceValueSchema = z.union([
|
|
14
|
+
HexColorSchema,
|
|
15
|
+
z.string().regex(/^(linear|radial|conic)-gradient\(.+\)$/, "Must be a hex colour or a CSS gradient")
|
|
16
|
+
]);
|
|
17
|
+
var WebFontSchema = z.object({
|
|
18
|
+
family: z.string(),
|
|
19
|
+
url: z.string(),
|
|
20
|
+
weight: z.string().optional(),
|
|
21
|
+
style: z.string().optional(),
|
|
22
|
+
display: z.string().optional()
|
|
23
|
+
});
|
|
24
|
+
var TypeScaleSchema = z.number().min(1.067).max(1.333);
|
|
25
|
+
var BrandInputsSchema = z.object({
|
|
26
|
+
color: z.strictObject({
|
|
27
|
+
/** The partner's primary colour: actions, emphasis, selected states. */
|
|
28
|
+
brand: HexColorSchema,
|
|
29
|
+
/** The secondary colour. Defaults to the brand colour when unset. */
|
|
30
|
+
accent: HexColorSchema.optional(),
|
|
31
|
+
/** The page behind everything. May be a gradient; carries no text. */
|
|
32
|
+
surfacePage: SurfaceValueSchema,
|
|
33
|
+
/** Where content actually sits, and what text is read against. */
|
|
34
|
+
surfaceCard: HexColorSchema,
|
|
35
|
+
/** The header band. */
|
|
36
|
+
surfaceHeader: HexColorSchema,
|
|
37
|
+
/** The footer band. */
|
|
38
|
+
surfaceFooter: HexColorSchema,
|
|
39
|
+
/** Default body text, on `surfaceCard`. */
|
|
40
|
+
text: HexColorSchema,
|
|
41
|
+
danger: HexColorSchema,
|
|
42
|
+
warning: HexColorSchema,
|
|
43
|
+
success: HexColorSchema,
|
|
44
|
+
info: HexColorSchema
|
|
45
|
+
}),
|
|
46
|
+
font: z.strictObject({
|
|
47
|
+
body: z.string(),
|
|
48
|
+
/** Defaults to `body` when unset — most brands have one typeface. */
|
|
49
|
+
heading: z.string().optional(),
|
|
50
|
+
/** Root size in px. Everything else is `rem`, scaled from this. */
|
|
51
|
+
sizeBase: z.number().min(14).max(20).default(16),
|
|
52
|
+
scale: TypeScaleSchema.default(1.2),
|
|
53
|
+
/** Faces the shell must load. A partner brings its own typeface. */
|
|
54
|
+
webFonts: z.array(WebFontSchema).default([])
|
|
55
|
+
}),
|
|
56
|
+
shape: z.strictObject({
|
|
57
|
+
/** Corner rounding in px. Every radius derives from it. */
|
|
58
|
+
radiusBase: z.number().min(0).max(24).default(4),
|
|
59
|
+
/** The spacing unit in px. All spacing is a multiple. */
|
|
60
|
+
spaceBase: z.number().min(2).max(8).default(4),
|
|
61
|
+
/** Default border weight in px. */
|
|
62
|
+
borderWidth: z.number().min(1).max(3).default(1)
|
|
63
|
+
}),
|
|
64
|
+
assets: z.strictObject({
|
|
65
|
+
logo: z.string(),
|
|
66
|
+
logoAlt: z.string(),
|
|
67
|
+
/** For use on dark surfaces, where the main logo would disappear. */
|
|
68
|
+
logoDark: z.string().optional(),
|
|
69
|
+
favicon: z.string().optional()
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
var DEFAULT_BRAND_INPUTS = BrandInputsSchema.parse({
|
|
73
|
+
color: {
|
|
74
|
+
brand: "#1f4ed8",
|
|
75
|
+
surfacePage: "#f4f5f7",
|
|
76
|
+
surfaceCard: "#ffffff",
|
|
77
|
+
surfaceHeader: "#ffffff",
|
|
78
|
+
surfaceFooter: "#1f2430",
|
|
79
|
+
text: "#1a1a1a",
|
|
80
|
+
danger: "#c8102e",
|
|
81
|
+
warning: "#b45309",
|
|
82
|
+
success: "#047857",
|
|
83
|
+
info: "#1f4ed8"
|
|
84
|
+
},
|
|
85
|
+
font: { body: 'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif' },
|
|
86
|
+
shape: {},
|
|
87
|
+
assets: { logo: "", logoAlt: "" }
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// packages/design-tokens/src/contrast.ts
|
|
91
|
+
var HEX = /^#?([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
92
|
+
function parseHex(value) {
|
|
93
|
+
const m = HEX.exec(value.trim());
|
|
94
|
+
if (!m) return null;
|
|
95
|
+
let h = m[1];
|
|
96
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
97
|
+
return {
|
|
98
|
+
r: parseInt(h.slice(0, 2), 16),
|
|
99
|
+
g: parseInt(h.slice(2, 4), 16),
|
|
100
|
+
b: parseInt(h.slice(4, 6), 16)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function toHex({ r, g, b }) {
|
|
104
|
+
const c = (n) => Math.round(Math.min(255, Math.max(0, n))).toString(16).padStart(2, "0");
|
|
105
|
+
return `#${c(r)}${c(g)}${c(b)}`;
|
|
106
|
+
}
|
|
107
|
+
function luminance(rgb) {
|
|
108
|
+
const channel = (v) => {
|
|
109
|
+
const s = v / 255;
|
|
110
|
+
return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
111
|
+
};
|
|
112
|
+
return 0.2126 * channel(rgb.r) + 0.7152 * channel(rgb.g) + 0.0722 * channel(rgb.b);
|
|
113
|
+
}
|
|
114
|
+
function contrastRatio(a, b) {
|
|
115
|
+
const ra = parseHex(a);
|
|
116
|
+
const rb = parseHex(b);
|
|
117
|
+
if (!ra || !rb) return 0;
|
|
118
|
+
const la = luminance(ra);
|
|
119
|
+
const lb = luminance(rb);
|
|
120
|
+
const [hi, lo] = la > lb ? [la, lb] : [lb, la];
|
|
121
|
+
return (hi + 0.05) / (lo + 0.05);
|
|
122
|
+
}
|
|
123
|
+
var AA_TEXT = 4.5;
|
|
124
|
+
var AA_LARGE_TEXT = 3;
|
|
125
|
+
var AA_NON_TEXT = 3;
|
|
126
|
+
var FOREGROUND_DARK = "#1a1a1a";
|
|
127
|
+
var FOREGROUND_LIGHT = "#ffffff";
|
|
128
|
+
function pickForeground(background) {
|
|
129
|
+
const dark = contrastRatio(background, FOREGROUND_DARK);
|
|
130
|
+
const light = contrastRatio(background, FOREGROUND_LIGHT);
|
|
131
|
+
return dark >= light ? FOREGROUND_DARK : FOREGROUND_LIGHT;
|
|
132
|
+
}
|
|
133
|
+
function shade(color, amount) {
|
|
134
|
+
const rgb = parseHex(color);
|
|
135
|
+
if (!rgb) return color;
|
|
136
|
+
const t = amount < 0 ? 255 : 0;
|
|
137
|
+
const k = Math.abs(amount);
|
|
138
|
+
return toHex({
|
|
139
|
+
r: rgb.r + (t - rgb.r) * k,
|
|
140
|
+
g: rgb.g + (t - rgb.g) * k,
|
|
141
|
+
b: rgb.b + (t - rgb.b) * k
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
var darken = (color, amount) => shade(color, amount);
|
|
145
|
+
var lighten = (color, amount) => shade(color, -amount);
|
|
146
|
+
var tint = (color) => lighten(color, 0.88);
|
|
147
|
+
function mix(a, b, amount) {
|
|
148
|
+
const ra = parseHex(a);
|
|
149
|
+
const rb = parseHex(b);
|
|
150
|
+
if (!ra || !rb) return a;
|
|
151
|
+
const k = Math.min(1, Math.max(0, amount));
|
|
152
|
+
return toHex({
|
|
153
|
+
r: ra.r + (rb.r - ra.r) * k,
|
|
154
|
+
g: ra.g + (rb.g - ra.g) * k,
|
|
155
|
+
b: ra.b + (rb.b - ra.b) * k
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function ensureContrast(foreground, background, target) {
|
|
159
|
+
const fg = parseHex(foreground);
|
|
160
|
+
const bg = parseHex(background);
|
|
161
|
+
if (!fg || !bg) return foreground;
|
|
162
|
+
if (contrastRatio(foreground, background) >= target) return toHex(fg);
|
|
163
|
+
const toward = luminance(bg) > 0.5 ? FOREGROUND_DARK : FOREGROUND_LIGHT;
|
|
164
|
+
let current = toHex(fg);
|
|
165
|
+
for (let step = 1; step <= 20; step += 1) {
|
|
166
|
+
current = mix(toHex(fg), toward, step / 20);
|
|
167
|
+
if (contrastRatio(current, background) >= target) return current;
|
|
168
|
+
}
|
|
169
|
+
return current;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// packages/design-tokens/src/derive.ts
|
|
173
|
+
var LOCKED_TOKENS = {
|
|
174
|
+
"focus.ring.inner": "#ffffff",
|
|
175
|
+
"focus.ring.outer": "#1a1a1a",
|
|
176
|
+
"focus.ring.width": "2px",
|
|
177
|
+
"focus.ring.offset": "2px",
|
|
178
|
+
"focus.ring.shadow": "0 0 0 2px #ffffff, 0 0 0 4px #1a1a1a",
|
|
179
|
+
"target.min": "24px",
|
|
180
|
+
"target.spacing": "8px"
|
|
181
|
+
};
|
|
182
|
+
var SPACE_STEPS = {
|
|
183
|
+
"0": 0,
|
|
184
|
+
"1": 1,
|
|
185
|
+
"2": 2,
|
|
186
|
+
"3": 3,
|
|
187
|
+
"4": 4,
|
|
188
|
+
"5": 6,
|
|
189
|
+
"6": 8,
|
|
190
|
+
"7": 12,
|
|
191
|
+
"8": 16,
|
|
192
|
+
"9": 24,
|
|
193
|
+
"10": 32
|
|
194
|
+
};
|
|
195
|
+
var TYPE_STEPS = {
|
|
196
|
+
"2xs": -3,
|
|
197
|
+
xs: -2,
|
|
198
|
+
sm: -1,
|
|
199
|
+
md: 0,
|
|
200
|
+
lg: 1,
|
|
201
|
+
xl: 2,
|
|
202
|
+
"2xl": 3,
|
|
203
|
+
"3xl": 4
|
|
204
|
+
};
|
|
205
|
+
var MIN_FONT_PX = 12;
|
|
206
|
+
function onSurface(surface, accent) {
|
|
207
|
+
const rgb = parseHex(surface);
|
|
208
|
+
if (!rgb) return pickForeground("#000000");
|
|
209
|
+
return luminance(rgb) > 0.5 ? ensureContrast(accent, surface, AA_TEXT) : pickForeground(surface);
|
|
210
|
+
}
|
|
211
|
+
function typeRamp(sizeBase, scale) {
|
|
212
|
+
const out = {};
|
|
213
|
+
for (const [name, step] of Object.entries(TYPE_STEPS)) {
|
|
214
|
+
const px = Math.max(MIN_FONT_PX, sizeBase * scale ** step);
|
|
215
|
+
const rem = Math.ceil(px / sizeBase * 1e4) / 1e4;
|
|
216
|
+
out[`font.size.${name}`] = `${rem}rem`;
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
function deriveTokens(input) {
|
|
221
|
+
const { color, font, shape } = input;
|
|
222
|
+
const card = color.surfaceCard;
|
|
223
|
+
const accent = color.accent ?? color.brand;
|
|
224
|
+
const tokens = { ...LOCKED_TOKENS };
|
|
225
|
+
tokens["color.surface.page"] = color.surfacePage;
|
|
226
|
+
tokens["color.surface.card"] = card;
|
|
227
|
+
tokens["color.surface.header"] = color.surfaceHeader;
|
|
228
|
+
tokens["color.surface.footer"] = color.surfaceFooter;
|
|
229
|
+
tokens["color.surface.subtle"] = tint(color.brand);
|
|
230
|
+
tokens["color.surface.inset"] = mix(card, pickForeground(card), 0.05);
|
|
231
|
+
tokens["color.brand.default"] = color.brand;
|
|
232
|
+
tokens["color.brand.hover"] = darken(color.brand, 0.12);
|
|
233
|
+
tokens["color.brand.active"] = darken(color.brand, 0.24);
|
|
234
|
+
tokens["color.brand.subtle"] = tint(color.brand);
|
|
235
|
+
tokens["color.brand.on"] = pickForeground(color.brand);
|
|
236
|
+
tokens["color.accent.default"] = accent;
|
|
237
|
+
tokens["color.accent.hover"] = darken(accent, 0.12);
|
|
238
|
+
tokens["color.accent.on"] = pickForeground(accent);
|
|
239
|
+
tokens["color.text.default"] = ensureContrast(color.text, card, AA_TEXT);
|
|
240
|
+
tokens["color.text.muted"] = ensureContrast(mix(color.text, card, 0.38), card, AA_TEXT);
|
|
241
|
+
tokens["color.text.placeholder"] = ensureContrast(mix(color.text, card, 0.5), card, AA_TEXT);
|
|
242
|
+
tokens["color.text.on-brand"] = pickForeground(color.brand);
|
|
243
|
+
tokens["color.text.on-header"] = onSurface(color.surfaceHeader, accent);
|
|
244
|
+
tokens["color.text.on-footer"] = onSurface(color.surfaceFooter, accent);
|
|
245
|
+
tokens["color.text.heading"] = ensureContrast(accent, card, AA_TEXT);
|
|
246
|
+
tokens["color.text.link"] = ensureContrast(color.brand, card, AA_TEXT);
|
|
247
|
+
tokens["color.text.link-hover"] = darken(tokens["color.text.link"], 0.2);
|
|
248
|
+
tokens["color.border.default"] = ensureContrast(mix(color.text, card, 0.7), card, AA_NON_TEXT);
|
|
249
|
+
tokens["color.border.strong"] = ensureContrast(mix(color.text, card, 0.45), card, AA_NON_TEXT);
|
|
250
|
+
for (const name of ["danger", "warning", "success", "info"]) {
|
|
251
|
+
const base = color[name];
|
|
252
|
+
tokens[`color.status.${name}.default`] = ensureContrast(base, card, AA_NON_TEXT);
|
|
253
|
+
tokens[`color.status.${name}.text`] = ensureContrast(base, card, AA_TEXT);
|
|
254
|
+
tokens[`color.status.${name}.subtle`] = tint(base);
|
|
255
|
+
tokens[`color.status.${name}.on`] = pickForeground(base);
|
|
256
|
+
}
|
|
257
|
+
tokens["font.family.body"] = font.body;
|
|
258
|
+
tokens["font.family.heading"] = font.heading ?? font.body;
|
|
259
|
+
tokens["font.size.root"] = `${font.sizeBase}px`;
|
|
260
|
+
Object.assign(tokens, typeRamp(font.sizeBase, font.scale));
|
|
261
|
+
tokens["font.weight.regular"] = "400";
|
|
262
|
+
tokens["font.weight.medium"] = "500";
|
|
263
|
+
tokens["font.weight.semibold"] = "600";
|
|
264
|
+
tokens["font.weight.bold"] = "700";
|
|
265
|
+
tokens["font.line-height.tight"] = "1.25";
|
|
266
|
+
tokens["font.line-height.normal"] = "1.5";
|
|
267
|
+
tokens["font.line-height.relaxed"] = "1.75";
|
|
268
|
+
for (const [name, multiple] of Object.entries(SPACE_STEPS)) {
|
|
269
|
+
tokens[`space.${name}`] = `${shape.spaceBase * multiple}px`;
|
|
270
|
+
}
|
|
271
|
+
tokens["radius.none"] = "0";
|
|
272
|
+
tokens["radius.sm"] = `${shape.radiusBase / 2}px`;
|
|
273
|
+
tokens["radius.md"] = `${shape.radiusBase}px`;
|
|
274
|
+
tokens["radius.lg"] = `${shape.radiusBase * 2}px`;
|
|
275
|
+
tokens["radius.xl"] = `${shape.radiusBase * 3}px`;
|
|
276
|
+
tokens["radius.full"] = "9999px";
|
|
277
|
+
tokens["border.width.thin"] = `${shape.borderWidth}px`;
|
|
278
|
+
tokens["border.width.thick"] = `${shape.borderWidth * 2}px`;
|
|
279
|
+
return tokens;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// packages/design-tokens/src/validate.ts
|
|
283
|
+
var isMeasurable = (value) => parseHex(value) !== null;
|
|
284
|
+
function pairsFor(tokens) {
|
|
285
|
+
const card = tokens["color.surface.card"];
|
|
286
|
+
const text = (t) => ({ required: AA_TEXT, criterion: "1.4.3 Contrast (Minimum)", what: t });
|
|
287
|
+
const ui = (t) => ({ required: AA_NON_TEXT, criterion: "1.4.11 Non-text Contrast", what: t });
|
|
288
|
+
const pairs = [
|
|
289
|
+
{ token: "color.text.default", fg: tokens["color.text.default"], bg: card, ...text("Body text on a card") },
|
|
290
|
+
{ token: "color.text.muted", fg: tokens["color.text.muted"], bg: card, ...text("Muted text on a card") },
|
|
291
|
+
{ token: "color.text.placeholder", fg: tokens["color.text.placeholder"], bg: card, ...text("Placeholder text in a field") },
|
|
292
|
+
{ token: "color.text.link", fg: tokens["color.text.link"], bg: card, ...text("A link on a card") },
|
|
293
|
+
{ token: "color.text.on-brand", fg: tokens["color.text.on-brand"], bg: tokens["color.brand.default"], ...text("Text on a brand-coloured button") },
|
|
294
|
+
{ token: "color.text.on-header", fg: tokens["color.text.on-header"], bg: tokens["color.surface.header"], ...text("Text in the header") },
|
|
295
|
+
{ token: "color.text.on-footer", fg: tokens["color.text.on-footer"], bg: tokens["color.surface.footer"], ...text("Text in the footer") },
|
|
296
|
+
{ token: "color.brand.default", fg: tokens["color.brand.default"], bg: card, ...ui("A brand-coloured control against a card") },
|
|
297
|
+
{ token: "color.border.default", fg: tokens["color.border.default"], bg: card, ...ui("A field border against a card") }
|
|
298
|
+
];
|
|
299
|
+
for (const name of ["danger", "warning", "success", "info"]) {
|
|
300
|
+
pairs.push({
|
|
301
|
+
token: `color.status.${name}.text`,
|
|
302
|
+
fg: tokens[`color.status.${name}.text`],
|
|
303
|
+
bg: card,
|
|
304
|
+
...text(`${name[0].toUpperCase()}${name.slice(1)} message text`)
|
|
305
|
+
});
|
|
306
|
+
pairs.push({
|
|
307
|
+
token: `color.status.${name}.default`,
|
|
308
|
+
fg: tokens[`color.status.${name}.default`],
|
|
309
|
+
bg: card,
|
|
310
|
+
...ui(`The ${name} indicator against a card`)
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
return pairs;
|
|
314
|
+
}
|
|
315
|
+
function checkContrast(tokens) {
|
|
316
|
+
const issues = [];
|
|
317
|
+
let checked = 0;
|
|
318
|
+
for (const pair of pairsFor(tokens)) {
|
|
319
|
+
if (!isMeasurable(pair.fg) || !isMeasurable(pair.bg)) continue;
|
|
320
|
+
checked += 1;
|
|
321
|
+
const ratio = contrastRatio(pair.fg, pair.bg);
|
|
322
|
+
if (ratio >= pair.required) continue;
|
|
323
|
+
issues.push({
|
|
324
|
+
token: pair.token,
|
|
325
|
+
foreground: pair.fg,
|
|
326
|
+
background: pair.bg,
|
|
327
|
+
ratio: Math.round(ratio * 100) / 100,
|
|
328
|
+
required: pair.required,
|
|
329
|
+
criterion: pair.criterion,
|
|
330
|
+
message: `${pair.what} is ${(Math.round(ratio * 100) / 100).toFixed(2)}:1, below the ${pair.required}:1 that ${pair.criterion} requires.`
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
return { ok: issues.length === 0, issues, checked };
|
|
334
|
+
}
|
|
335
|
+
var checkBrandContrast = (input) => checkContrast(deriveTokens(input));
|
|
336
|
+
|
|
337
|
+
// packages/design-tokens/src/dtcg.ts
|
|
338
|
+
function typeOf(path, value) {
|
|
339
|
+
if (path.startsWith("color.") || path.startsWith("focus.ring.") && !/width|offset|shadow/.test(path)) return "color";
|
|
340
|
+
if (path.includes("font.family")) return "fontFamily";
|
|
341
|
+
if (path.includes("font.weight")) return "fontWeight";
|
|
342
|
+
if (path.includes("line-height")) return "number";
|
|
343
|
+
if (path.includes("shadow")) return "shadow";
|
|
344
|
+
if (/^-?[\d.]+(px|rem|em|%)$/.test(value) || value === "0") return "dimension";
|
|
345
|
+
return "color";
|
|
346
|
+
}
|
|
347
|
+
function toDtcg(tokens) {
|
|
348
|
+
const root = {};
|
|
349
|
+
for (const [path, value] of Object.entries(tokens)) {
|
|
350
|
+
const parts = path.split(".");
|
|
351
|
+
const leaf = parts.pop();
|
|
352
|
+
let node = root;
|
|
353
|
+
for (const part of parts) {
|
|
354
|
+
if (!(part in node) || "$value" in node[part]) node[part] = {};
|
|
355
|
+
node = node[part];
|
|
356
|
+
}
|
|
357
|
+
node[leaf] = { $type: typeOf(path, value), $value: value };
|
|
358
|
+
}
|
|
359
|
+
return root;
|
|
360
|
+
}
|
|
361
|
+
export {
|
|
362
|
+
AA_LARGE_TEXT,
|
|
363
|
+
AA_NON_TEXT,
|
|
364
|
+
AA_TEXT,
|
|
365
|
+
BrandInputsSchema,
|
|
366
|
+
DEFAULT_BRAND_INPUTS,
|
|
367
|
+
HexColorSchema,
|
|
368
|
+
LOCKED_TOKENS,
|
|
369
|
+
PREFIX,
|
|
370
|
+
SurfaceValueSchema,
|
|
371
|
+
TypeScaleSchema,
|
|
372
|
+
WebFontSchema,
|
|
373
|
+
checkBrandContrast,
|
|
374
|
+
checkContrast,
|
|
375
|
+
contrastRatio,
|
|
376
|
+
cssVarName,
|
|
377
|
+
darken,
|
|
378
|
+
deriveTokens,
|
|
379
|
+
ensureContrast,
|
|
380
|
+
escapeStyleText,
|
|
381
|
+
lighten,
|
|
382
|
+
luminance,
|
|
383
|
+
mix,
|
|
384
|
+
parseHex,
|
|
385
|
+
pickForeground,
|
|
386
|
+
tint,
|
|
387
|
+
toCssDeclarations,
|
|
388
|
+
toDtcg,
|
|
389
|
+
toHex,
|
|
390
|
+
toStyleProperties,
|
|
391
|
+
toStylesheet
|
|
392
|
+
};
|
|
393
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/inputs.ts","../src/contrast.ts","../src/derive.ts","../src/validate.ts","../src/dtcg.ts"],"sourcesContent":["/**\n * Brand inputs — everything a partner may set, and nothing else.\n *\n * The list is closed, and it is short on purpose. Stripe's Appearance API gets\n * almost all of its brand expression from eight variables and derives the rest;\n * Cloudscape allows typography, colour and border radius and refuses the\n * question beyond that; the legacy Sanity CMS this replaces allowed everything\n * and accumulated forty per-viewport override fields nobody could prune. The\n * reasoning, with sources, is\n * [ADR 0010](../../../docs/decisions/0010-what-a-brand-may-set.md).\n *\n * Two absences are the point of the whole file. There is no foreground colour\n * anywhere — text on a surface is computed, so a partner cannot pin white text\n * onto a mid-tone brand colour. And there is no focus colour — the ring keeps\n * system values, because a focus indicator drawn in a partner's own brand\n * colour on that partner's own background is where focus visibility dies.\n */\nimport { z } from 'zod';\n\n/** A hex colour. The only colour form the inputs accept. */\nexport const HexColorSchema = z\n .string()\n .regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, 'Must be a hex colour, e.g. #5e10b1');\n\n/**\n * The page background, which may be a gradient.\n *\n * It is the one exception and it is safe by construction rather than by\n * exception: the page background never carries text directly — text sits on a\n * card — so it is the only surface with nothing to contrast against. Northwind\n * Plus's shell is a three-stop gradient, which is a real requirement and\n * would otherwise need an escape hatch.\n */\nexport const SurfaceValueSchema = z.union([\n HexColorSchema,\n z.string().regex(/^(linear|radial|conic)-gradient\\(.+\\)$/, 'Must be a hex colour or a CSS gradient'),\n]);\n\nexport const WebFontSchema = z.object({\n family: z.string(),\n url: z.string(),\n weight: z.string().optional(),\n style: z.string().optional(),\n display: z.string().optional(),\n});\nexport type WebFont = z.infer<typeof WebFontSchema>;\n\n/**\n * The type ramp ratio.\n *\n * Bounded rather than free. Below 1.067 the ramp stops distinguishing levels\n * and heading structure becomes invisible to a sighted reader even though the\n * markup is correct; above 1.333 the top of the scale overflows a 360px\n * viewport at 200% zoom, which fails 1.4.4. A partner who wants bigger headings\n * raises the base size.\n */\nexport const TypeScaleSchema = z.number().min(1.067).max(1.333);\n\n/**\n * Each group is `.strict()`.\n *\n * Zod strips unknown keys by default, so `color.onBrand` would validate, be\n * dropped, and leave an editor looking at a brand that ignores a value they\n * set. Rejecting it says what is actually true: there is nowhere to put a\n * foreground colour, because foregrounds are measured.\n */\nexport const BrandInputsSchema = z.object({\n color: z.strictObject({\n /** The partner's primary colour: actions, emphasis, selected states. */\n brand: HexColorSchema,\n /** The secondary colour. Defaults to the brand colour when unset. */\n accent: HexColorSchema.optional(),\n\n /** The page behind everything. May be a gradient; carries no text. */\n surfacePage: SurfaceValueSchema,\n /** Where content actually sits, and what text is read against. */\n surfaceCard: HexColorSchema,\n /** The header band. */\n surfaceHeader: HexColorSchema,\n /** The footer band. */\n surfaceFooter: HexColorSchema,\n\n /** Default body text, on `surfaceCard`. */\n text: HexColorSchema,\n\n danger: HexColorSchema,\n warning: HexColorSchema,\n success: HexColorSchema,\n info: HexColorSchema,\n }),\n\n font: z.strictObject({\n body: z.string(),\n /** Defaults to `body` when unset — most brands have one typeface. */\n heading: z.string().optional(),\n /** Root size in px. Everything else is `rem`, scaled from this. */\n sizeBase: z.number().min(14).max(20).default(16),\n scale: TypeScaleSchema.default(1.2),\n /** Faces the shell must load. A partner brings its own typeface. */\n webFonts: z.array(WebFontSchema).default([]),\n }),\n\n shape: z.strictObject({\n /** Corner rounding in px. Every radius derives from it. */\n radiusBase: z.number().min(0).max(24).default(4),\n /** The spacing unit in px. All spacing is a multiple. */\n spaceBase: z.number().min(2).max(8).default(4),\n /** Default border weight in px. */\n borderWidth: z.number().min(1).max(3).default(1),\n }),\n\n assets: z.strictObject({\n logo: z.string(),\n logoAlt: z.string(),\n /** For use on dark surfaces, where the main logo would disappear. */\n logoDark: z.string().optional(),\n favicon: z.string().optional(),\n }),\n});\n\nexport type BrandInputs = z.infer<typeof BrandInputsSchema>;\n\n/**\n * The house defaults — a complete, neutral, AA-passing brand.\n *\n * Every input is optional at the edges of the system because this exists: a\n * site with no brand document still renders something legible rather than\n * unstyled, which is what makes a missing brand a visible problem instead of a\n * broken page.\n */\nexport const DEFAULT_BRAND_INPUTS: BrandInputs = BrandInputsSchema.parse({\n color: {\n brand: '#1f4ed8',\n surfacePage: '#f4f5f7',\n surfaceCard: '#ffffff',\n surfaceHeader: '#ffffff',\n surfaceFooter: '#1f2430',\n text: '#1a1a1a',\n danger: '#c8102e',\n warning: '#b45309',\n success: '#047857',\n info: '#1f4ed8',\n },\n font: { body: 'system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif' },\n shape: {},\n assets: { logo: '', logoAlt: '' },\n});\n","/**\n * Contrast maths, to WCAG 2.x.\n *\n * This file exists because of one decision: a partner never authors a text\n * colour to sit on a background ([ADR 0010](../../../docs/decisions/0010-what-a-brand-may-set.md)).\n * They pick a brand colour and the system picks what reads on top of it. That\n * makes the most common white-label accessibility failure — a mid-tone brand\n * colour under a white label — unrepresentable rather than merely discouraged.\n *\n * The formulae are from WCAG 2.2 (relative luminance, and the (L1+0.05)/(L2+0.05)\n * contrast ratio). They are stable, cheap and exactly what an auditor will use.\n * APCA is better maths and is not normative yet; when it is, this is the one\n * file that changes.\n */\n\n/** A colour this module can reason about: #rgb, #rrggbb, or #rrggbbaa. */\nexport type Hex = string;\n\nexport interface Rgb {\n r: number;\n g: number;\n b: number;\n}\n\nconst HEX = /^#?([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\n\n/**\n * Parse a hex colour. Returns null rather than throwing: callers are usually\n * validating authored content, where \"this is not a colour\" is a message to an\n * editor and not an exception.\n */\nexport function parseHex(value: string): Rgb | null {\n const m = HEX.exec(value.trim());\n if (!m) return null;\n let h = m[1];\n if (h.length === 3) h = h.split('').map((c) => c + c).join('');\n return {\n r: parseInt(h.slice(0, 2), 16),\n g: parseInt(h.slice(2, 4), 16),\n b: parseInt(h.slice(4, 6), 16),\n };\n}\n\nexport function toHex({ r, g, b }: Rgb): Hex {\n const c = (n: number) => Math.round(Math.min(255, Math.max(0, n))).toString(16).padStart(2, '0');\n return `#${c(r)}${c(g)}${c(b)}`;\n}\n\n/** WCAG relative luminance. */\nexport function luminance(rgb: Rgb): number {\n const channel = (v: number) => {\n const s = v / 255;\n return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;\n };\n return 0.2126 * channel(rgb.r) + 0.7152 * channel(rgb.g) + 0.0722 * channel(rgb.b);\n}\n\n/** WCAG contrast ratio, 1–21. Returns 0 for anything unparseable. */\nexport function contrastRatio(a: string, b: string): number {\n const ra = parseHex(a);\n const rb = parseHex(b);\n if (!ra || !rb) return 0;\n const la = luminance(ra);\n const lb = luminance(rb);\n const [hi, lo] = la > lb ? [la, lb] : [lb, la];\n return (hi + 0.05) / (lo + 0.05);\n}\n\n/** The thresholds, named, so call sites read as the criterion they enforce. */\nexport const AA_TEXT = 4.5;\nexport const AA_LARGE_TEXT = 3;\n/** 1.4.11 Non-text Contrast: UI components and meaningful graphics. */\nexport const AA_NON_TEXT = 3;\n\n/**\n * The two foregrounds anything may be drawn in.\n *\n * Not pure black and white. Pure black on a light surface is harsher than it\n * needs to be and pure white on a saturated brand colour haloes; these are the\n * near-neutrals most systems settle on, and they still clear 4.5:1 against\n * every surface the inputs can produce — which the tests assert rather than\n * assume.\n */\nexport const FOREGROUND_DARK = '#1a1a1a';\nexport const FOREGROUND_LIGHT = '#ffffff';\n\n/**\n * Pick the foreground that reads best on `background`.\n *\n * Deliberately returns the BETTER of the two rather than the first that passes.\n * On a mid-tone brand colour both may clear 4.5:1 and the winner is still\n * visibly easier to read; on a colour where neither passes, the better one is\n * what gets rendered while the publish check reports the failure. A caller that\n * needs to know whether it passed asks `contrastRatio` — this function always\n * answers.\n */\nexport function pickForeground(background: string): Hex {\n const dark = contrastRatio(background, FOREGROUND_DARK);\n const light = contrastRatio(background, FOREGROUND_LIGHT);\n return dark >= light ? FOREGROUND_DARK : FOREGROUND_LIGHT;\n}\n\n/**\n * Shift a colour toward black or white by `amount` (0–1).\n *\n * This is how every hover, active and subtle state is derived. Mixing in sRGB\n * is not perceptually uniform and a perceptual space would give more even\n * steps; sRGB is used because it is what CSS `color-mix` does, so a value\n * derived here and a value a stylesheet computes agree. Matching the platform\n * matters more here than being slightly more correct than it.\n */\nexport function shade(color: string, amount: number): Hex {\n const rgb = parseHex(color);\n if (!rgb) return color;\n const t = amount < 0 ? 255 : 0;\n const k = Math.abs(amount);\n return toHex({\n r: rgb.r + (t - rgb.r) * k,\n g: rgb.g + (t - rgb.g) * k,\n b: rgb.b + (t - rgb.b) * k,\n });\n}\n\n/** Darken toward black. */\nexport const darken = (color: string, amount: number): Hex => shade(color, amount);\n/** Lighten toward white. */\nexport const lighten = (color: string, amount: number): Hex => shade(color, -amount);\n\n/**\n * A very light tint of a colour, for subtle backgrounds — an info panel, a\n * selected row. Always light enough to take the dark foreground, which is what\n * makes \"subtle\" a safe surface rather than a guess.\n */\nexport const tint = (color: string): Hex => lighten(color, 0.88);\n\n/** Blend two colours. `amount` is how far from `a` toward `b`. */\nexport function mix(a: string, b: string, amount: number): Hex {\n const ra = parseHex(a);\n const rb = parseHex(b);\n if (!ra || !rb) return a;\n const k = Math.min(1, Math.max(0, amount));\n return toHex({\n r: ra.r + (rb.r - ra.r) * k,\n g: ra.g + (rb.g - ra.g) * k,\n b: ra.b + (rb.b - ra.b) * k,\n });\n}\n\n/**\n * Walk a foreground away from its background until it clears `target`.\n *\n * This is the mechanism that makes a derived token safe rather than merely\n * plausible. Muted text, placeholder text and borders are all produced by\n * blending toward a surface, and a blend that looks right on one brand falls\n * under 4.5:1 on the next. Rather than pick a blend that happens to work for\n * the brands we have, each derived value is pushed back until it passes.\n *\n * It moves toward whichever end of the scale is already further from the\n * background, in small steps, and gives up after it runs out of room — at\n * which point the colour is returned as-is and the publish check reports it.\n * Silently returning black would hide a brand that cannot work.\n */\nexport function ensureContrast(foreground: string, background: string, target: number): Hex {\n const fg = parseHex(foreground);\n const bg = parseHex(background);\n if (!fg || !bg) return foreground;\n if (contrastRatio(foreground, background) >= target) return toHex(fg);\n\n const toward = luminance(bg) > 0.5 ? FOREGROUND_DARK : FOREGROUND_LIGHT;\n let current = toHex(fg);\n for (let step = 1; step <= 20; step += 1) {\n current = mix(toHex(fg), toward, step / 20);\n if (contrastRatio(current, background) >= target) return current;\n }\n return current;\n}\n","/**\n * Brand inputs → the semantic tokens components actually read.\n *\n * This is the whole argument of\n * [ADR 0010](../../../docs/decisions/0010-what-a-brand-may-set.md) in executable\n * form: around twenty authored values go in, roughly a hundred come out, and\n * the hundred are not authorable. A partner who wants a different hover colour\n * is describing a change to this function, which is a product decision with a\n * version number, rather than a field in a CMS nobody can later prune.\n *\n * Three rules run through it. Foregrounds are always picked by measured\n * contrast, never authored. Anything that carries text is ratcheted until it\n * passes AA rather than trusted to. And the focus ring and the minimum target\n * size are constants, because they are the two things a brand would break first\n * and notice last.\n */\nimport {\n AA_NON_TEXT,\n AA_TEXT,\n darken,\n ensureContrast,\n luminance,\n mix,\n parseHex,\n pickForeground,\n tint,\n} from './contrast';\nimport type { BrandInputs } from './inputs';\n\n/** A flat token set: dotted path → CSS value. */\nexport type TokenSet = Record<string, string>;\n\n/**\n * The locked tokens. A brand cannot reach these and nothing derives them.\n *\n * The focus ring is two-tone — a light inner ring inside a dark outer one — so\n * that it stays visible on any surface a partner can produce, including their\n * own brand colour. A single-colour ring has to assume a background, and the\n * one it assumes is the one a white-label product does not have. This is the\n * rule Scotland's design system states directly: adopters may change the\n * colours, and must still keep the system's colours for focus.\n *\n * `target.min` is WCAG 2.2's 2.5.8 minimum. It is here rather than in the\n * spacing scale so that shrinking the spacing unit cannot shrink a tap target.\n */\nexport const LOCKED_TOKENS: TokenSet = {\n 'focus.ring.inner': '#ffffff',\n 'focus.ring.outer': '#1a1a1a',\n 'focus.ring.width': '2px',\n 'focus.ring.offset': '2px',\n 'focus.ring.shadow': '0 0 0 2px #ffffff, 0 0 0 4px #1a1a1a',\n 'target.min': '24px',\n 'target.spacing': '8px',\n};\n\n/** Spacing steps, as multiples of the base unit. */\nconst SPACE_STEPS: Record<string, number> = {\n '0': 0, '1': 1, '2': 2, '3': 3, '4': 4,\n '5': 6, '6': 8, '7': 12, '8': 16, '9': 24, '10': 32,\n};\n\n/** Type ramp, as powers of the scale ratio either side of the base. */\nconst TYPE_STEPS: Record<string, number> = {\n '2xs': -3, xs: -2, sm: -1, md: 0, lg: 1, xl: 2, '2xl': 3, '3xl': 4,\n};\n\n/**\n * The smallest text the ramp may produce, in px.\n *\n * A 1.333 ratio three steps below a 14px base lands at 5.9px. Clamping here\n * rather than narrowing the ratio keeps the top of the ramp expressive while\n * stopping the bottom from becoming unreadable.\n */\nconst MIN_FONT_PX = 12;\n\n/**\n * The text colour for a branded band — the header, the footer.\n *\n * Not simply the picked foreground, because that throws away real brand\n * expression: Northwind's header is white with dark-purple text, and deriving\n * near-black there would be legible and wrong. On a LIGHT band the accent\n * colour is used, ratcheted until it passes, which is what partners actually\n * do and what every migrated theme authored. On a DARK band the picked\n * foreground wins, because coloured text on a saturated brand background is\n * exactly where legibility goes, and a washed-out tint of the band's own\n * colour is worse than white.\n *\n * An unparseable surface — a gradient — is treated as dark, since a gradient\n * is only allowed on the page and the page is the one band nothing sits on.\n */\nfunction onSurface(surface: string, accent: string): string {\n const rgb = parseHex(surface);\n if (!rgb) return pickForeground('#000000');\n return luminance(rgb) > 0.5 ? ensureContrast(accent, surface, AA_TEXT) : pickForeground(surface);\n}\n\nfunction typeRamp(sizeBase: number, scale: number): TokenSet {\n const out: TokenSet = {};\n for (const [name, step] of Object.entries(TYPE_STEPS)) {\n const px = Math.max(MIN_FONT_PX, sizeBase * scale ** step);\n // Round UP at four places. Rounding to nearest loses the 12px floor by a\n // ten-thousandth, which is invisible until a test asserts the floor and\n // fails — and the floor is the accessibility claim, so it rounds its way.\n const rem = Math.ceil((px / sizeBase) * 10000) / 10000;\n out[`font.size.${name}`] = `${rem}rem`;\n }\n return out;\n}\n\nexport function deriveTokens(input: BrandInputs): TokenSet {\n const { color, font, shape } = input;\n const card = color.surfaceCard;\n const accent = color.accent ?? color.brand;\n\n const tokens: TokenSet = { ...LOCKED_TOKENS };\n\n // --- surfaces ------------------------------------------------------------\n // `page` is the only one that may be a gradient, and the only one nothing is\n // read against. `inset` is for wells and disabled fields: a step away from\n // the card in whichever direction the card is not.\n tokens['color.surface.page'] = color.surfacePage;\n tokens['color.surface.card'] = card;\n tokens['color.surface.header'] = color.surfaceHeader;\n tokens['color.surface.footer'] = color.surfaceFooter;\n tokens['color.surface.subtle'] = tint(color.brand);\n tokens['color.surface.inset'] = mix(card, pickForeground(card), 0.05);\n\n // --- brand ---------------------------------------------------------------\n // Hover and active are tone shifts rather than authored colours. The\n // direction is fixed: darker on interaction, because a lighter hover on a\n // light surface reads as disabled.\n tokens['color.brand.default'] = color.brand;\n tokens['color.brand.hover'] = darken(color.brand, 0.12);\n tokens['color.brand.active'] = darken(color.brand, 0.24);\n tokens['color.brand.subtle'] = tint(color.brand);\n tokens['color.brand.on'] = pickForeground(color.brand);\n\n tokens['color.accent.default'] = accent;\n tokens['color.accent.hover'] = darken(accent, 0.12);\n tokens['color.accent.on'] = pickForeground(accent);\n\n // --- text ----------------------------------------------------------------\n // Muted and placeholder are blends toward the surface, then ratcheted back\n // until they clear AA. Placeholder is included deliberately: it is routinely\n // treated as exempt and 1.4.3 does not exempt it.\n tokens['color.text.default'] = ensureContrast(color.text, card, AA_TEXT);\n tokens['color.text.muted'] = ensureContrast(mix(color.text, card, 0.38), card, AA_TEXT);\n tokens['color.text.placeholder'] = ensureContrast(mix(color.text, card, 0.5), card, AA_TEXT);\n tokens['color.text.on-brand'] = pickForeground(color.brand);\n tokens['color.text.on-header'] = onSurface(color.surfaceHeader, accent);\n tokens['color.text.on-footer'] = onSurface(color.surfaceFooter, accent);\n // A link is the brand colour where that is readable, and a darkened brand\n // colour where it is not — so a partner with a pale brand still gets links\n // that look like theirs.\n // Headings take the accent colour. The legacy schema had an authored\n // `typography.headingColor`, and on every migrated theme it was the secondary\n // colour — so deriving it reproduces them exactly and removes a field whose\n // only job was to restate another one.\n tokens['color.text.heading'] = ensureContrast(accent, card, AA_TEXT);\n tokens['color.text.link'] = ensureContrast(color.brand, card, AA_TEXT);\n tokens['color.text.link-hover'] = darken(tokens['color.text.link'], 0.2);\n\n // --- borders -------------------------------------------------------------\n // 1.4.11 governs these: a field border is a UI component boundary, so 3:1,\n // not 4.5:1.\n tokens['color.border.default'] = ensureContrast(mix(color.text, card, 0.7), card, AA_NON_TEXT);\n tokens['color.border.strong'] = ensureContrast(mix(color.text, card, 0.45), card, AA_NON_TEXT);\n\n // --- status --------------------------------------------------------------\n // Each gets three: the colour itself at UI contrast, a tint to sit behind it,\n // and the foreground that reads on it. `*.text` is separate from `*.default`\n // because the same red that is fine as a 3:1 border is not fine as 4.5:1 body\n // text, and conflating them is how error messages end up unreadable.\n for (const name of ['danger', 'warning', 'success', 'info'] as const) {\n const base = color[name];\n tokens[`color.status.${name}.default`] = ensureContrast(base, card, AA_NON_TEXT);\n tokens[`color.status.${name}.text`] = ensureContrast(base, card, AA_TEXT);\n tokens[`color.status.${name}.subtle`] = tint(base);\n tokens[`color.status.${name}.on`] = pickForeground(base);\n }\n\n // --- typography ----------------------------------------------------------\n tokens['font.family.body'] = font.body;\n tokens['font.family.heading'] = font.heading ?? font.body;\n tokens['font.size.root'] = `${font.sizeBase}px`;\n Object.assign(tokens, typeRamp(font.sizeBase, font.scale));\n tokens['font.weight.regular'] = '400';\n tokens['font.weight.medium'] = '500';\n tokens['font.weight.semibold'] = '600';\n tokens['font.weight.bold'] = '700';\n // 1.4.8 asks for 1.5 within a paragraph; `tight` is for headings, where it\n // does not apply.\n tokens['font.line-height.tight'] = '1.25';\n tokens['font.line-height.normal'] = '1.5';\n tokens['font.line-height.relaxed'] = '1.75';\n\n // --- space, radius, border width -----------------------------------------\n for (const [name, multiple] of Object.entries(SPACE_STEPS)) {\n tokens[`space.${name}`] = `${shape.spaceBase * multiple}px`;\n }\n tokens['radius.none'] = '0';\n tokens['radius.sm'] = `${shape.radiusBase / 2}px`;\n tokens['radius.md'] = `${shape.radiusBase}px`;\n tokens['radius.lg'] = `${shape.radiusBase * 2}px`;\n tokens['radius.xl'] = `${shape.radiusBase * 3}px`;\n tokens['radius.full'] = '9999px';\n tokens['border.width.thin'] = `${shape.borderWidth}px`;\n tokens['border.width.thick'] = `${shape.borderWidth * 2}px`;\n\n return tokens;\n}\n","/**\n * The contrast gate.\n *\n * Derivation means most pairs cannot fail — a foreground is picked by measured\n * contrast and a blend is ratcheted until it passes. What is left are the pairs\n * a partner controls both sides of: their brand colour against their own\n * surfaces, their text against their own card, and their status colours\n * against it. Those are checked here, and a failure blocks a publish the way a\n * dangling reference already does\n * ([ADR 0009](../../../docs/decisions/0009-wcag-is-an-authoring-gate.md)).\n *\n * This is a floor, not a certificate. It is arithmetic over colour pairs: it\n * cannot see a value rendered on an image, text baked into a logo, or a\n * disabled control whose contrast is exempt but whose meaning is not. Treating\n * a green build as \"the brand is accessible\" is the failure mode to guard\n * against, which is why the result says what it checked.\n */\nimport { AA_NON_TEXT, AA_TEXT, contrastRatio, parseHex } from './contrast';\nimport { deriveTokens, type TokenSet } from './derive';\nimport type { BrandInputs } from './inputs';\n\nexport interface ContrastIssue {\n /** The token that fails, as an editor would be shown it. */\n token: string;\n foreground: string;\n background: string;\n ratio: number;\n required: number;\n /** The WCAG criterion, so the message can cite it. */\n criterion: '1.4.3 Contrast (Minimum)' | '1.4.11 Non-text Contrast';\n message: string;\n}\n\nexport interface ContrastReport {\n ok: boolean;\n issues: ContrastIssue[];\n /** How many pairs were examined — the honest denominator. */\n checked: number;\n}\n\ninterface Pair {\n token: string;\n fg: string;\n bg: string;\n required: number;\n criterion: ContrastIssue['criterion'];\n what: string;\n}\n\n/**\n * A gradient has no single luminance, so it is skipped rather than guessed at.\n * Safe because nothing is read directly against the page surface — the one\n * place a gradient is allowed.\n */\nconst isMeasurable = (value: string): boolean => parseHex(value) !== null;\n\nfunction pairsFor(tokens: TokenSet): Pair[] {\n const card = tokens['color.surface.card'];\n const text = (t: string) => ({ required: AA_TEXT, criterion: '1.4.3 Contrast (Minimum)' as const, what: t });\n const ui = (t: string) => ({ required: AA_NON_TEXT, criterion: '1.4.11 Non-text Contrast' as const, what: t });\n\n const pairs: Pair[] = [\n { token: 'color.text.default', fg: tokens['color.text.default'], bg: card, ...text('Body text on a card') },\n { token: 'color.text.muted', fg: tokens['color.text.muted'], bg: card, ...text('Muted text on a card') },\n { token: 'color.text.placeholder', fg: tokens['color.text.placeholder'], bg: card, ...text('Placeholder text in a field') },\n { token: 'color.text.link', fg: tokens['color.text.link'], bg: card, ...text('A link on a card') },\n { token: 'color.text.on-brand', fg: tokens['color.text.on-brand'], bg: tokens['color.brand.default'], ...text('Text on a brand-coloured button') },\n { token: 'color.text.on-header', fg: tokens['color.text.on-header'], bg: tokens['color.surface.header'], ...text('Text in the header') },\n { token: 'color.text.on-footer', fg: tokens['color.text.on-footer'], bg: tokens['color.surface.footer'], ...text('Text in the footer') },\n { token: 'color.brand.default', fg: tokens['color.brand.default'], bg: card, ...ui('A brand-coloured control against a card') },\n { token: 'color.border.default', fg: tokens['color.border.default'], bg: card, ...ui('A field border against a card') },\n ];\n\n for (const name of ['danger', 'warning', 'success', 'info']) {\n pairs.push({\n token: `color.status.${name}.text`,\n fg: tokens[`color.status.${name}.text`],\n bg: card,\n ...text(`${name[0].toUpperCase()}${name.slice(1)} message text`),\n });\n pairs.push({\n token: `color.status.${name}.default`,\n fg: tokens[`color.status.${name}.default`],\n bg: card,\n ...ui(`The ${name} indicator against a card`),\n });\n }\n\n return pairs;\n}\n\n/** Check a derived token set. */\nexport function checkContrast(tokens: TokenSet): ContrastReport {\n const issues: ContrastIssue[] = [];\n let checked = 0;\n\n for (const pair of pairsFor(tokens)) {\n if (!isMeasurable(pair.fg) || !isMeasurable(pair.bg)) continue;\n checked += 1;\n const ratio = contrastRatio(pair.fg, pair.bg);\n if (ratio >= pair.required) continue;\n issues.push({\n token: pair.token,\n foreground: pair.fg,\n background: pair.bg,\n ratio: Math.round(ratio * 100) / 100,\n required: pair.required,\n criterion: pair.criterion,\n message:\n `${pair.what} is ${(Math.round(ratio * 100) / 100).toFixed(2)}:1, ` +\n `below the ${pair.required}:1 that ${pair.criterion} requires.`,\n });\n }\n\n return { ok: issues.length === 0, issues, checked };\n}\n\n/** Check a brand before its tokens exist. What the CMS editor calls. */\nexport const checkBrandContrast = (input: BrandInputs): ContrastReport =>\n checkContrast(deriveTokens(input));\n","/**\n * Tokens → the W3C Design Tokens Community Group format.\n *\n * An OUTPUT, not the source. ADR 0005 originally had tokens authored as DTCG\n * files and built by Style Dictionary; writing the derivation showed why that\n * cannot be the whole story. A partner's tokens are computed at runtime from a\n * published brand document, so the authoring format has to be code — a\n * build-time pipeline can only ever produce the house theme, and a second\n * emitter for the runtime path would drift from it.\n *\n * So the format is kept as an export. It is what Figma, Style Dictionary and\n * the token tooling read, which is what makes a design-tool round trip a thing\n * we can add later rather than a rewrite, and it costs one function.\n */\nimport type { TokenSet } from './derive';\n\nexport type DtcgType = 'color' | 'dimension' | 'fontFamily' | 'fontWeight' | 'number' | 'shadow';\n\ninterface DtcgToken {\n $type: DtcgType;\n $value: string;\n $description?: string;\n}\n\nexport type DtcgGroup = { [key: string]: DtcgGroup | DtcgToken };\n\n/**\n * Infer the type from the token's path and value.\n *\n * By path first, because a value alone is ambiguous — `\"400\"` is a font weight\n * and `\"2px\"` is a dimension and both are strings. The paths are ours, so this\n * is reading our own naming convention rather than guessing.\n */\nfunction typeOf(path: string, value: string): DtcgType {\n if (path.startsWith('color.') || path.startsWith('focus.ring.') && !/width|offset|shadow/.test(path)) return 'color';\n if (path.includes('font.family')) return 'fontFamily';\n if (path.includes('font.weight')) return 'fontWeight';\n if (path.includes('line-height')) return 'number';\n if (path.includes('shadow')) return 'shadow';\n if (/^-?[\\d.]+(px|rem|em|%)$/.test(value) || value === '0') return 'dimension';\n return 'color';\n}\n\n/** A flat token set as a nested DTCG document. */\nexport function toDtcg(tokens: TokenSet): DtcgGroup {\n const root: DtcgGroup = {};\n for (const [path, value] of Object.entries(tokens)) {\n const parts = path.split('.');\n const leaf = parts.pop() as string;\n let node = root;\n for (const part of parts) {\n if (!(part in node) || '$value' in (node[part] as DtcgToken)) node[part] = {} as DtcgGroup;\n node = node[part] as DtcgGroup;\n }\n node[leaf] = { $type: typeOf(path, value), $value: value };\n }\n return root;\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAS,SAAS;AAGX,IAAM,iBAAiB,EAC3B,OAAO,EACP,MAAM,sCAAsC,oCAAoC;AAW5E,IAAM,qBAAqB,EAAE,MAAM;AAAA,EACxC;AAAA,E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