@loidolt/theme-tokens 0.6.0 → 0.8.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/README.md +5 -0
- package/dist/dark-auto.css +76 -0
- package/dist/dark.css +38 -0
- package/dist/index.d.ts +774 -53
- package/dist/index.js +705 -51
- package/dist/presets/compact-dark-auto.css +159 -0
- package/dist/presets/compact-dark.css +79 -0
- package/dist/presets/compact.css +156 -0
- package/dist/presets/compact.root-dark-auto.css +157 -0
- package/dist/presets/compact.root-dark.css +78 -0
- package/dist/presets/compact.root.css +156 -0
- package/dist/presets/loidolt-dark-auto.css +159 -0
- package/dist/presets/loidolt-dark.css +79 -0
- package/dist/presets/loidolt.css +156 -0
- package/dist/presets/loidolt.root-dark-auto.css +157 -0
- package/dist/presets/loidolt.root-dark.css +78 -0
- package/dist/presets/loidolt.root.css +156 -0
- package/dist/presets/soft-dark-auto.css +159 -0
- package/dist/presets/soft-dark.css +79 -0
- package/dist/presets/soft.css +156 -0
- package/dist/presets/soft.root-dark-auto.css +157 -0
- package/dist/presets/soft.root-dark.css +78 -0
- package/dist/presets/soft.root.css +156 -0
- package/dist/tokens.css +103 -0
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,53 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WCAG 2.x contrast arithmetic, shared by the token tests and by applications that need to pick
|
|
3
|
-
* or validate a colour at runtime (a user-chosen swatch, a generated label). Pure functions over
|
|
4
|
-
* hex strings, so they run anywhere — build scripts, servers, and the browser.
|
|
5
|
-
*
|
|
6
|
-
* @see https://www.w3.org/TR/WCAG22/#dfn-relative-luminance
|
|
7
|
-
*/
|
|
8
|
-
type ContrastLevel = 'AA' | 'AAA';
|
|
9
|
-
type TextSize = 'normal' | 'large';
|
|
10
|
-
interface ContrastValidation {
|
|
11
|
-
ratio: number;
|
|
12
|
-
/** `ratio` to two decimals, e.g. `'4.52:1'`. */
|
|
13
|
-
ratioString: string;
|
|
14
|
-
passesAANormal: boolean;
|
|
15
|
-
passesAALarge: boolean;
|
|
16
|
-
passesAAANormal: boolean;
|
|
17
|
-
passesAAALarge: boolean;
|
|
18
|
-
}
|
|
19
|
-
/** Minimum ratio per level and text size. Large text is 18.66px bold or 24px regular and up. */
|
|
20
|
-
declare const contrastRequirements: {
|
|
21
|
-
readonly AA: {
|
|
22
|
-
readonly normal: 4.5;
|
|
23
|
-
readonly large: 3;
|
|
24
|
-
};
|
|
25
|
-
readonly AAA: {
|
|
26
|
-
readonly normal: 7;
|
|
27
|
-
readonly large: 4.5;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
/** Relative luminance, from 0 (black) to 1 (white). Accepts `#rgb` and `#rrggbb`. */
|
|
31
|
-
declare function getLuminance(hex: string): number;
|
|
32
|
-
/** Contrast ratio between two colours, from 1 to 21. Order does not matter. */
|
|
33
|
-
declare function getContrastRatio(foreground: string, background: string): number;
|
|
34
|
-
/** Whether a pair clears the WCAG threshold for the given level and text size. */
|
|
35
|
-
declare function meetsContrast(foreground: string, background: string, { level, size }?: {
|
|
36
|
-
level?: ContrastLevel;
|
|
37
|
-
size?: TextSize;
|
|
38
|
-
}): boolean;
|
|
39
|
-
/** Every threshold at once, for reporting. */
|
|
40
|
-
declare function validateContrast(foreground: string, background: string): ContrastValidation;
|
|
41
|
-
/**
|
|
42
|
-
* Whichever of two inks reads better on `background` — by measured ratio, not a luminance
|
|
43
|
-
* cut-off, so it stays right for any pair you pass. Defaults to the theme's own deep ink and
|
|
44
|
-
* panel, rather than pure black and white.
|
|
45
|
-
*/
|
|
46
|
-
declare function getContrastTextColor(background: string, { dark, light }?: {
|
|
47
|
-
dark?: string;
|
|
48
|
-
light?: string;
|
|
49
|
-
}): string;
|
|
50
|
-
|
|
51
1
|
/**
|
|
52
2
|
* Design tokens for Loidolt applications.
|
|
53
3
|
*
|
|
@@ -61,7 +11,10 @@ declare function getContrastTextColor(background: string, { dark, light }?: {
|
|
|
61
11
|
type TokenRef = {
|
|
62
12
|
readonly $ref: string;
|
|
63
13
|
};
|
|
64
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* `['font', 'lineHeight', 'tight']` → `--loidolt-font-line-height-tight`; a trailing number is its
|
|
16
|
+
* own segment, so `chart1` → `--loidolt-chart-1`.
|
|
17
|
+
*/
|
|
65
18
|
declare const cssVarName: (path: readonly string[]) => string;
|
|
66
19
|
declare const colors: {
|
|
67
20
|
readonly paper: "#ebe7dc";
|
|
@@ -82,6 +35,59 @@ declare const colors: {
|
|
|
82
35
|
readonly success: "#3f5139";
|
|
83
36
|
readonly warning: "#7c4d17";
|
|
84
37
|
readonly info: "#265162";
|
|
38
|
+
/**
|
|
39
|
+
* Categorical series for charts, in the order they are handed out. Earth tones that stay apart
|
|
40
|
+
* from each other and hold 3:1 against every surface, so a line or bar needs no outline.
|
|
41
|
+
*/
|
|
42
|
+
readonly series: {
|
|
43
|
+
readonly 1: "#c65224";
|
|
44
|
+
readonly 2: "#2f6f8a";
|
|
45
|
+
readonly 3: "#5b7a3a";
|
|
46
|
+
readonly 4: "#9a6a12";
|
|
47
|
+
readonly 5: "#7a4a78";
|
|
48
|
+
readonly 6: "#4d5a6a";
|
|
49
|
+
readonly 7: "#2f7d6d";
|
|
50
|
+
readonly 8: "#8a5a3c";
|
|
51
|
+
};
|
|
52
|
+
/** One warm hue from little to most: heatmaps, choropleths, cluster sizes. */
|
|
53
|
+
readonly sequential: {
|
|
54
|
+
readonly 1: "#ecd3b8";
|
|
55
|
+
readonly 2: "#dea67a";
|
|
56
|
+
readonly 3: "#c97a45";
|
|
57
|
+
readonly 4: "#a4521f";
|
|
58
|
+
readonly 5: "#6e3314";
|
|
59
|
+
};
|
|
60
|
+
/** Below and above a midpoint: slate for below, orange for above, the neutral paper between. */
|
|
61
|
+
readonly diverging: {
|
|
62
|
+
readonly 1: "#265162";
|
|
63
|
+
readonly 2: "#4f8196";
|
|
64
|
+
readonly 3: "#9cbac3";
|
|
65
|
+
readonly 4: "#ddd7c9";
|
|
66
|
+
readonly 5: "#e0a986";
|
|
67
|
+
readonly 6: "#c96f3d";
|
|
68
|
+
readonly 7: "#9b3a17";
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Code highlighting. Code sits on the inverse surface — dark in the light theme — so these are
|
|
72
|
+
* the light inks; the dark theme's code block is light, and takes dark ones.
|
|
73
|
+
*/
|
|
74
|
+
readonly syntax: {
|
|
75
|
+
readonly keyword: "#f0895c";
|
|
76
|
+
readonly string: "#a3c197";
|
|
77
|
+
readonly comment: "#b5ae9c";
|
|
78
|
+
readonly constant: "#e2b56c";
|
|
79
|
+
readonly function: "#8fc0d4";
|
|
80
|
+
readonly parameter: "#d3a8cf";
|
|
81
|
+
readonly punctuation: "#d8d2c4";
|
|
82
|
+
};
|
|
83
|
+
/** Basemap fills. Quiet by design: the data drawn on top carries the colour. */
|
|
84
|
+
readonly map: {
|
|
85
|
+
readonly water: "#b9cdd3";
|
|
86
|
+
readonly park: "#d3d8bd";
|
|
87
|
+
readonly road: "#f5f2e9";
|
|
88
|
+
readonly roadMajor: "#ffffff";
|
|
89
|
+
readonly building: "#d8d3c7";
|
|
90
|
+
};
|
|
85
91
|
};
|
|
86
92
|
declare const typography: {
|
|
87
93
|
readonly display: "\"Jost\", \"Avenir Next\", sans-serif";
|
|
@@ -224,13 +230,215 @@ declare const semanticDefs: {
|
|
|
224
230
|
readonly focusRing: TokenRef;
|
|
225
231
|
readonly shadowColor: TokenRef;
|
|
226
232
|
readonly scrim: "color-mix(in srgb, var(--loidolt-shadow-color) 72%, transparent)";
|
|
233
|
+
readonly chart1: TokenRef;
|
|
234
|
+
readonly chart2: TokenRef;
|
|
235
|
+
readonly chart3: TokenRef;
|
|
236
|
+
readonly chart4: TokenRef;
|
|
237
|
+
readonly chart5: TokenRef;
|
|
238
|
+
readonly chart6: TokenRef;
|
|
239
|
+
readonly chart7: TokenRef;
|
|
240
|
+
readonly chart8: TokenRef;
|
|
241
|
+
readonly chartSequential1: TokenRef;
|
|
242
|
+
readonly chartSequential2: TokenRef;
|
|
243
|
+
readonly chartSequential3: TokenRef;
|
|
244
|
+
readonly chartSequential4: TokenRef;
|
|
245
|
+
readonly chartSequential5: TokenRef;
|
|
246
|
+
readonly chartDiverging1: TokenRef;
|
|
247
|
+
readonly chartDiverging2: TokenRef;
|
|
248
|
+
readonly chartDiverging3: TokenRef;
|
|
249
|
+
readonly chartDiverging4: TokenRef;
|
|
250
|
+
readonly chartDiverging5: TokenRef;
|
|
251
|
+
readonly chartDiverging6: TokenRef;
|
|
252
|
+
readonly chartDiverging7: TokenRef;
|
|
253
|
+
/** Gains and losses: candlestick up/down, positive/negative bars. */
|
|
254
|
+
readonly chartPositive: TokenRef;
|
|
255
|
+
readonly chartNegative: TokenRef;
|
|
256
|
+
readonly mapLand: TokenRef;
|
|
257
|
+
readonly mapWater: TokenRef;
|
|
258
|
+
readonly mapPark: TokenRef;
|
|
259
|
+
readonly mapRoad: TokenRef;
|
|
260
|
+
readonly mapRoadMajor: TokenRef;
|
|
261
|
+
readonly mapBuilding: TokenRef;
|
|
262
|
+
readonly mapBoundary: TokenRef;
|
|
263
|
+
readonly mapLabel: TokenRef;
|
|
264
|
+
readonly mapLabelHalo: TokenRef;
|
|
265
|
+
readonly syntaxKeyword: TokenRef;
|
|
266
|
+
readonly syntaxString: TokenRef;
|
|
267
|
+
readonly syntaxComment: TokenRef;
|
|
268
|
+
readonly syntaxConstant: TokenRef;
|
|
269
|
+
readonly syntaxFunction: TokenRef;
|
|
270
|
+
readonly syntaxParameter: TokenRef;
|
|
271
|
+
readonly syntaxPunctuation: TokenRef;
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* The shape-and-voice layer: the non-colour roles a preset restyles. Like the colour roles, each
|
|
275
|
+
* names a *job* (the corner of a control, the padding of a table cell, the case of a label) rather
|
|
276
|
+
* than a component, so one value moves every component that does that job.
|
|
277
|
+
*
|
|
278
|
+
* Every default reproduces the original hand-written value exactly; a preset that sets none of
|
|
279
|
+
* them looks identical to the base system.
|
|
280
|
+
*/
|
|
281
|
+
declare const roleDefs: {
|
|
282
|
+
/** Buttons, boxed fields, toggle groups, switches, swatches, tooltips. */
|
|
283
|
+
readonly radiusControl: TokenRef;
|
|
284
|
+
/** Rows and items inside a rounded container (menu items, list rows, filmstrip frames). */
|
|
285
|
+
readonly radiusInner: "0px";
|
|
286
|
+
/** Cards, panels, tables, alerts, code blocks, thumbnails. */
|
|
287
|
+
readonly radiusSurface: TokenRef;
|
|
288
|
+
/** Dialogs, popovers, menus, toasts. Drawers stay square: they are anchored to an edge. */
|
|
289
|
+
readonly radiusOverlay: TokenRef;
|
|
290
|
+
/** Width of the keyboard focus ring. WCAG 2.4.13 wants at least 2px; keep it there. */
|
|
291
|
+
readonly strokeFocus: "2px";
|
|
292
|
+
/** Selected-tab, active-nav and selected-row indicators. */
|
|
293
|
+
readonly strokeIndicator: "2px";
|
|
294
|
+
/** The status bar on the leading edge of an alert or toast. */
|
|
295
|
+
readonly strokeAccent: "3px";
|
|
296
|
+
readonly padControlX: "0.85rem";
|
|
297
|
+
readonly padControlXSm: "0.65rem";
|
|
298
|
+
readonly padControlXLg: "1.2rem";
|
|
299
|
+
readonly padControlY: "0.5rem";
|
|
300
|
+
readonly padControlYSm: "0.38rem";
|
|
301
|
+
/** Underlined fields: vertical, then horizontal. Boxed fields use `pad-control-x-sm` inline. */
|
|
302
|
+
readonly padField: "0.45rem 0.15rem";
|
|
303
|
+
readonly padItem: "0.65rem 0.55rem";
|
|
304
|
+
readonly padCell: "0.7rem 0.8rem";
|
|
305
|
+
readonly padCallout: "0.8rem 1rem";
|
|
306
|
+
readonly padSurface: TokenRef;
|
|
307
|
+
readonly padOverlay: "1rem 1.25rem";
|
|
308
|
+
readonly padPopover: "0.45rem";
|
|
309
|
+
readonly padBarX: "1.35rem";
|
|
310
|
+
readonly padPane: "1.25rem";
|
|
311
|
+
readonly padPage: TokenRef;
|
|
312
|
+
/** Between a field's label, control and help text. */
|
|
313
|
+
readonly gapField: "0.35rem";
|
|
314
|
+
/** Between the buttons of a dialog footer or an empty state. */
|
|
315
|
+
readonly gapActions: TokenRef;
|
|
316
|
+
readonly labelTransform: "uppercase";
|
|
317
|
+
readonly labelTracking: TokenRef;
|
|
318
|
+
readonly labelTrackingWide: TokenRef;
|
|
319
|
+
readonly labelWeight: "400";
|
|
320
|
+
readonly controlTransform: "uppercase";
|
|
321
|
+
readonly controlTracking: "0.08em";
|
|
322
|
+
readonly controlWeight: "400";
|
|
323
|
+
readonly headingWeight: "500";
|
|
324
|
+
readonly strongWeight: "600";
|
|
227
325
|
};
|
|
228
326
|
/** Every custom property the package emits, in declaration order. */
|
|
229
327
|
declare function flattenTokens(): Array<[string, string | TokenRef]>;
|
|
230
328
|
/** Serializes the token set to CSS. The build writes this to `dist/tokens.css`. */
|
|
231
329
|
declare function generateCss(): string;
|
|
232
330
|
/** Semantic roles with their refs resolved to concrete values, for TS/JS consumers. */
|
|
233
|
-
declare const semantic: {
|
|
331
|
+
declare const semantic: {
|
|
332
|
+
readonly background: string;
|
|
333
|
+
readonly surface: string;
|
|
334
|
+
readonly surfaceAlt: string;
|
|
335
|
+
readonly surfaceSunken: string;
|
|
336
|
+
readonly surfacePaper: string;
|
|
337
|
+
readonly surfaceInverse: string;
|
|
338
|
+
readonly surfaceInput: string;
|
|
339
|
+
readonly text: string;
|
|
340
|
+
readonly textMuted: string;
|
|
341
|
+
readonly textInverse: string;
|
|
342
|
+
readonly textAccent: string;
|
|
343
|
+
readonly border: string;
|
|
344
|
+
readonly borderSoft: string;
|
|
345
|
+
readonly borderStrong: string;
|
|
346
|
+
readonly borderControl: string;
|
|
347
|
+
readonly borderSunken: string;
|
|
348
|
+
readonly accent: string;
|
|
349
|
+
readonly accentHover: string;
|
|
350
|
+
readonly onAccent: string;
|
|
351
|
+
readonly danger: string;
|
|
352
|
+
readonly dangerHover: string;
|
|
353
|
+
readonly onDanger: string;
|
|
354
|
+
readonly textDanger: string;
|
|
355
|
+
readonly success: string;
|
|
356
|
+
readonly onSuccess: string;
|
|
357
|
+
readonly textSuccess: string;
|
|
358
|
+
readonly warning: string;
|
|
359
|
+
readonly onWarning: string;
|
|
360
|
+
readonly textWarning: string;
|
|
361
|
+
readonly info: string;
|
|
362
|
+
readonly onInfo: string;
|
|
363
|
+
readonly textInfo: string;
|
|
364
|
+
readonly focusRing: string;
|
|
365
|
+
readonly shadowColor: string;
|
|
366
|
+
readonly scrim: string;
|
|
367
|
+
readonly chart1: string;
|
|
368
|
+
readonly chart2: string;
|
|
369
|
+
readonly chart3: string;
|
|
370
|
+
readonly chart4: string;
|
|
371
|
+
readonly chart5: string;
|
|
372
|
+
readonly chart6: string;
|
|
373
|
+
readonly chart7: string;
|
|
374
|
+
readonly chart8: string;
|
|
375
|
+
readonly chartSequential1: string;
|
|
376
|
+
readonly chartSequential2: string;
|
|
377
|
+
readonly chartSequential3: string;
|
|
378
|
+
readonly chartSequential4: string;
|
|
379
|
+
readonly chartSequential5: string;
|
|
380
|
+
readonly chartDiverging1: string;
|
|
381
|
+
readonly chartDiverging2: string;
|
|
382
|
+
readonly chartDiverging3: string;
|
|
383
|
+
readonly chartDiverging4: string;
|
|
384
|
+
readonly chartDiverging5: string;
|
|
385
|
+
readonly chartDiverging6: string;
|
|
386
|
+
readonly chartDiverging7: string;
|
|
387
|
+
readonly chartPositive: string;
|
|
388
|
+
readonly chartNegative: string;
|
|
389
|
+
readonly mapLand: string;
|
|
390
|
+
readonly mapWater: string;
|
|
391
|
+
readonly mapPark: string;
|
|
392
|
+
readonly mapRoad: string;
|
|
393
|
+
readonly mapRoadMajor: string;
|
|
394
|
+
readonly mapBuilding: string;
|
|
395
|
+
readonly mapBoundary: string;
|
|
396
|
+
readonly mapLabel: string;
|
|
397
|
+
readonly mapLabelHalo: string;
|
|
398
|
+
readonly syntaxKeyword: string;
|
|
399
|
+
readonly syntaxString: string;
|
|
400
|
+
readonly syntaxComment: string;
|
|
401
|
+
readonly syntaxConstant: string;
|
|
402
|
+
readonly syntaxFunction: string;
|
|
403
|
+
readonly syntaxParameter: string;
|
|
404
|
+
readonly syntaxPunctuation: string;
|
|
405
|
+
};
|
|
406
|
+
/** Shape and voice roles with their refs resolved to concrete values. */
|
|
407
|
+
declare const roles: {
|
|
408
|
+
readonly radiusControl: string;
|
|
409
|
+
readonly radiusInner: string;
|
|
410
|
+
readonly radiusSurface: string;
|
|
411
|
+
readonly radiusOverlay: string;
|
|
412
|
+
readonly strokeFocus: string;
|
|
413
|
+
readonly strokeIndicator: string;
|
|
414
|
+
readonly strokeAccent: string;
|
|
415
|
+
readonly padControlX: string;
|
|
416
|
+
readonly padControlXSm: string;
|
|
417
|
+
readonly padControlXLg: string;
|
|
418
|
+
readonly padControlY: string;
|
|
419
|
+
readonly padControlYSm: string;
|
|
420
|
+
readonly padField: string;
|
|
421
|
+
readonly padItem: string;
|
|
422
|
+
readonly padCell: string;
|
|
423
|
+
readonly padCallout: string;
|
|
424
|
+
readonly padSurface: string;
|
|
425
|
+
readonly padOverlay: string;
|
|
426
|
+
readonly padPopover: string;
|
|
427
|
+
readonly padBarX: string;
|
|
428
|
+
readonly padPane: string;
|
|
429
|
+
readonly padPage: string;
|
|
430
|
+
readonly gapField: string;
|
|
431
|
+
readonly gapActions: string;
|
|
432
|
+
readonly labelTransform: string;
|
|
433
|
+
readonly labelTracking: string;
|
|
434
|
+
readonly labelTrackingWide: string;
|
|
435
|
+
readonly labelWeight: string;
|
|
436
|
+
readonly controlTransform: string;
|
|
437
|
+
readonly controlTracking: string;
|
|
438
|
+
readonly controlWeight: string;
|
|
439
|
+
readonly headingWeight: string;
|
|
440
|
+
readonly strongWeight: string;
|
|
441
|
+
};
|
|
234
442
|
/**
|
|
235
443
|
* Reference dark theme. Only the semantic tier is redefined — the primitives stay put — which
|
|
236
444
|
* is the same move a consumer makes for their own theme. Values are literal rather than linked
|
|
@@ -276,7 +484,121 @@ declare const darkSemantic: {
|
|
|
276
484
|
readonly focusRing: "#f0895c";
|
|
277
485
|
readonly shadowColor: "#000000";
|
|
278
486
|
readonly scrim: "color-mix(in srgb, var(--loidolt-shadow-color) 78%, transparent)";
|
|
487
|
+
readonly chart1: "#e0672f";
|
|
488
|
+
readonly chart2: "#6ea5bd";
|
|
489
|
+
readonly chart3: "#93b287";
|
|
490
|
+
readonly chart4: "#d9ab63";
|
|
491
|
+
readonly chart5: "#c49ac0";
|
|
492
|
+
readonly chart6: "#b8ad96";
|
|
493
|
+
readonly chart7: "#6fb8a6";
|
|
494
|
+
readonly chart8: "#c79a78";
|
|
495
|
+
readonly chartSequential1: "#3a2a1d";
|
|
496
|
+
readonly chartSequential2: "#6b4225";
|
|
497
|
+
readonly chartSequential3: "#a4602f";
|
|
498
|
+
readonly chartSequential4: "#d98a4d";
|
|
499
|
+
readonly chartSequential5: "#f2bd8a";
|
|
500
|
+
readonly chartDiverging1: "#85b6ca";
|
|
501
|
+
readonly chartDiverging2: "#5a8ea3";
|
|
502
|
+
readonly chartDiverging3: "#35596a";
|
|
503
|
+
readonly chartDiverging4: "#3a3d34";
|
|
504
|
+
readonly chartDiverging5: "#7a4428";
|
|
505
|
+
readonly chartDiverging6: "#bf6a3a";
|
|
506
|
+
readonly chartDiverging7: "#f0895c";
|
|
507
|
+
readonly chartPositive: "#93b287";
|
|
508
|
+
readonly chartNegative: "#e88b81";
|
|
509
|
+
readonly mapLand: "#161814";
|
|
510
|
+
readonly mapWater: "#1d2b31";
|
|
511
|
+
readonly mapPark: "#1f271c";
|
|
512
|
+
readonly mapRoad: "#2b2e26";
|
|
513
|
+
readonly mapRoadMajor: "#3a3d34";
|
|
514
|
+
readonly mapBuilding: "#24271f";
|
|
515
|
+
readonly mapBoundary: "#787c6b";
|
|
516
|
+
readonly mapLabel: "#ebe7dc";
|
|
517
|
+
readonly mapLabelHalo: "#161814";
|
|
518
|
+
readonly syntaxKeyword: "#a9441d";
|
|
519
|
+
readonly syntaxString: "#3f5139";
|
|
520
|
+
readonly syntaxComment: "#5f5b50";
|
|
521
|
+
readonly syntaxConstant: "#7c4d17";
|
|
522
|
+
readonly syntaxFunction: "#265162";
|
|
523
|
+
readonly syntaxParameter: "#7a4a78";
|
|
524
|
+
readonly syntaxPunctuation: "#474a42";
|
|
525
|
+
};
|
|
526
|
+
type ColorScheme = 'light' | 'dark';
|
|
527
|
+
type SemanticRole = keyof typeof semanticDefs;
|
|
528
|
+
/** The custom property a semantic role is published as: `chart1` → `--loidolt-chart-1`. */
|
|
529
|
+
declare const roleVar: (role: SemanticRole) => string;
|
|
530
|
+
/**
|
|
531
|
+
* A role's concrete value in the reference light or dark theme. Canvas and WebGL renderers cannot
|
|
532
|
+
* read `var()`, and neither can the server: this is what they fall back to when the live value
|
|
533
|
+
* cannot be read from the page.
|
|
534
|
+
*/
|
|
535
|
+
declare const roleValue: (role: SemanticRole, scheme?: ColorScheme) => string;
|
|
536
|
+
/** Names roles — singly or as an ordered list — under keys a renderer understands. */
|
|
537
|
+
type RoleSpec = {
|
|
538
|
+
readonly [key: string]: SemanticRole | readonly SemanticRole[];
|
|
539
|
+
};
|
|
540
|
+
type ResolvedRoles<S extends RoleSpec> = {
|
|
541
|
+
-readonly [K in keyof S]: S[K] extends readonly SemanticRole[] ? string[] : string;
|
|
279
542
|
};
|
|
543
|
+
/**
|
|
544
|
+
* Resolves every role in `spec`. `read` defaults to the reference theme; a runtime passes one
|
|
545
|
+
* that reads the page, so a consumer's own theme reaches the canvas too.
|
|
546
|
+
*/
|
|
547
|
+
declare function resolveRoles<S extends RoleSpec>(spec: S, scheme?: ColorScheme, read?: (role: SemanticRole) => string): ResolvedRoles<S>;
|
|
548
|
+
/** The roles a chart is painted with. */
|
|
549
|
+
declare const chartRoles: {
|
|
550
|
+
readonly categorical: readonly ["chart1", "chart2", "chart3", "chart4", "chart5", "chart6", "chart7", "chart8"];
|
|
551
|
+
readonly sequential: readonly ["chartSequential1", "chartSequential2", "chartSequential3", "chartSequential4", "chartSequential5"];
|
|
552
|
+
readonly diverging: readonly ["chartDiverging1", "chartDiverging2", "chartDiverging3", "chartDiverging4", "chartDiverging5", "chartDiverging6", "chartDiverging7"];
|
|
553
|
+
readonly positive: "chartPositive";
|
|
554
|
+
readonly negative: "chartNegative";
|
|
555
|
+
readonly text: "text";
|
|
556
|
+
readonly muted: "textMuted";
|
|
557
|
+
readonly axis: "border";
|
|
558
|
+
readonly grid: "borderSoft";
|
|
559
|
+
readonly surface: "surface";
|
|
560
|
+
readonly background: "background";
|
|
561
|
+
readonly accent: "accent";
|
|
562
|
+
};
|
|
563
|
+
/** The roles a basemap and map overlays are painted with. */
|
|
564
|
+
declare const mapRoles: {
|
|
565
|
+
readonly land: "mapLand";
|
|
566
|
+
readonly water: "mapWater";
|
|
567
|
+
readonly park: "mapPark";
|
|
568
|
+
readonly road: "mapRoad";
|
|
569
|
+
readonly roadMajor: "mapRoadMajor";
|
|
570
|
+
readonly building: "mapBuilding";
|
|
571
|
+
readonly boundary: "mapBoundary";
|
|
572
|
+
readonly label: "mapLabel";
|
|
573
|
+
readonly labelHalo: "mapLabelHalo";
|
|
574
|
+
readonly accent: "accent";
|
|
575
|
+
readonly text: "text";
|
|
576
|
+
readonly surface: "surface";
|
|
577
|
+
readonly focus: "focusRing";
|
|
578
|
+
readonly categorical: readonly ["chart1", "chart2", "chart3", "chart4", "chart5", "chart6", "chart7", "chart8"];
|
|
579
|
+
readonly sequential: readonly ["chartSequential1", "chartSequential2", "chartSequential3", "chartSequential4", "chartSequential5"];
|
|
580
|
+
};
|
|
581
|
+
/** The roles code is highlighted with, and the surface it sits on. */
|
|
582
|
+
declare const syntaxRoles: {
|
|
583
|
+
readonly background: "surfaceInverse";
|
|
584
|
+
readonly text: "textInverse";
|
|
585
|
+
readonly keyword: "syntaxKeyword";
|
|
586
|
+
readonly string: "syntaxString";
|
|
587
|
+
readonly comment: "syntaxComment";
|
|
588
|
+
readonly constant: "syntaxConstant";
|
|
589
|
+
readonly function: "syntaxFunction";
|
|
590
|
+
readonly parameter: "syntaxParameter";
|
|
591
|
+
readonly punctuation: "syntaxPunctuation";
|
|
592
|
+
};
|
|
593
|
+
type SyntaxColors = ResolvedRoles<typeof syntaxRoles>;
|
|
594
|
+
/** Syntax colours in the reference theme. */
|
|
595
|
+
declare const syntaxColors: (scheme?: ColorScheme) => SyntaxColors;
|
|
596
|
+
type ChartColors = ResolvedRoles<typeof chartRoles>;
|
|
597
|
+
type MapColors = ResolvedRoles<typeof mapRoles>;
|
|
598
|
+
/** Chart colours in the reference theme. */
|
|
599
|
+
declare const chartColors: (scheme?: ColorScheme) => ChartColors;
|
|
600
|
+
/** Map colours in the reference theme. */
|
|
601
|
+
declare const mapColors: (scheme?: ColorScheme) => MapColors;
|
|
280
602
|
/**
|
|
281
603
|
* Dark theme CSS. `scope` picks how it activates:
|
|
282
604
|
* - `attribute` (default): `[data-theme='dark']` only — the app drives it.
|
|
@@ -304,6 +626,59 @@ declare const tokens: {
|
|
|
304
626
|
readonly success: "#3f5139";
|
|
305
627
|
readonly warning: "#7c4d17";
|
|
306
628
|
readonly info: "#265162";
|
|
629
|
+
/**
|
|
630
|
+
* Categorical series for charts, in the order they are handed out. Earth tones that stay apart
|
|
631
|
+
* from each other and hold 3:1 against every surface, so a line or bar needs no outline.
|
|
632
|
+
*/
|
|
633
|
+
readonly series: {
|
|
634
|
+
readonly 1: "#c65224";
|
|
635
|
+
readonly 2: "#2f6f8a";
|
|
636
|
+
readonly 3: "#5b7a3a";
|
|
637
|
+
readonly 4: "#9a6a12";
|
|
638
|
+
readonly 5: "#7a4a78";
|
|
639
|
+
readonly 6: "#4d5a6a";
|
|
640
|
+
readonly 7: "#2f7d6d";
|
|
641
|
+
readonly 8: "#8a5a3c";
|
|
642
|
+
};
|
|
643
|
+
/** One warm hue from little to most: heatmaps, choropleths, cluster sizes. */
|
|
644
|
+
readonly sequential: {
|
|
645
|
+
readonly 1: "#ecd3b8";
|
|
646
|
+
readonly 2: "#dea67a";
|
|
647
|
+
readonly 3: "#c97a45";
|
|
648
|
+
readonly 4: "#a4521f";
|
|
649
|
+
readonly 5: "#6e3314";
|
|
650
|
+
};
|
|
651
|
+
/** Below and above a midpoint: slate for below, orange for above, the neutral paper between. */
|
|
652
|
+
readonly diverging: {
|
|
653
|
+
readonly 1: "#265162";
|
|
654
|
+
readonly 2: "#4f8196";
|
|
655
|
+
readonly 3: "#9cbac3";
|
|
656
|
+
readonly 4: "#ddd7c9";
|
|
657
|
+
readonly 5: "#e0a986";
|
|
658
|
+
readonly 6: "#c96f3d";
|
|
659
|
+
readonly 7: "#9b3a17";
|
|
660
|
+
};
|
|
661
|
+
/**
|
|
662
|
+
* Code highlighting. Code sits on the inverse surface — dark in the light theme — so these are
|
|
663
|
+
* the light inks; the dark theme's code block is light, and takes dark ones.
|
|
664
|
+
*/
|
|
665
|
+
readonly syntax: {
|
|
666
|
+
readonly keyword: "#f0895c";
|
|
667
|
+
readonly string: "#a3c197";
|
|
668
|
+
readonly comment: "#b5ae9c";
|
|
669
|
+
readonly constant: "#e2b56c";
|
|
670
|
+
readonly function: "#8fc0d4";
|
|
671
|
+
readonly parameter: "#d3a8cf";
|
|
672
|
+
readonly punctuation: "#d8d2c4";
|
|
673
|
+
};
|
|
674
|
+
/** Basemap fills. Quiet by design: the data drawn on top carries the colour. */
|
|
675
|
+
readonly map: {
|
|
676
|
+
readonly water: "#b9cdd3";
|
|
677
|
+
readonly park: "#d3d8bd";
|
|
678
|
+
readonly road: "#f5f2e9";
|
|
679
|
+
readonly roadMajor: "#ffffff";
|
|
680
|
+
readonly building: "#d8d3c7";
|
|
681
|
+
};
|
|
307
682
|
};
|
|
308
683
|
readonly typography: {
|
|
309
684
|
readonly display: "\"Jost\", \"Avenir Next\", sans-serif";
|
|
@@ -426,6 +801,44 @@ declare const tokens: {
|
|
|
426
801
|
readonly focusRing: string;
|
|
427
802
|
readonly shadowColor: string;
|
|
428
803
|
readonly scrim: string;
|
|
804
|
+
readonly chart1: string;
|
|
805
|
+
readonly chart2: string;
|
|
806
|
+
readonly chart3: string;
|
|
807
|
+
readonly chart4: string;
|
|
808
|
+
readonly chart5: string;
|
|
809
|
+
readonly chart6: string;
|
|
810
|
+
readonly chart7: string;
|
|
811
|
+
readonly chart8: string;
|
|
812
|
+
readonly chartSequential1: string;
|
|
813
|
+
readonly chartSequential2: string;
|
|
814
|
+
readonly chartSequential3: string;
|
|
815
|
+
readonly chartSequential4: string;
|
|
816
|
+
readonly chartSequential5: string;
|
|
817
|
+
readonly chartDiverging1: string;
|
|
818
|
+
readonly chartDiverging2: string;
|
|
819
|
+
readonly chartDiverging3: string;
|
|
820
|
+
readonly chartDiverging4: string;
|
|
821
|
+
readonly chartDiverging5: string;
|
|
822
|
+
readonly chartDiverging6: string;
|
|
823
|
+
readonly chartDiverging7: string;
|
|
824
|
+
readonly chartPositive: string;
|
|
825
|
+
readonly chartNegative: string;
|
|
826
|
+
readonly mapLand: string;
|
|
827
|
+
readonly mapWater: string;
|
|
828
|
+
readonly mapPark: string;
|
|
829
|
+
readonly mapRoad: string;
|
|
830
|
+
readonly mapRoadMajor: string;
|
|
831
|
+
readonly mapBuilding: string;
|
|
832
|
+
readonly mapBoundary: string;
|
|
833
|
+
readonly mapLabel: string;
|
|
834
|
+
readonly mapLabelHalo: string;
|
|
835
|
+
readonly syntaxKeyword: string;
|
|
836
|
+
readonly syntaxString: string;
|
|
837
|
+
readonly syntaxComment: string;
|
|
838
|
+
readonly syntaxConstant: string;
|
|
839
|
+
readonly syntaxFunction: string;
|
|
840
|
+
readonly syntaxParameter: string;
|
|
841
|
+
readonly syntaxPunctuation: string;
|
|
429
842
|
};
|
|
430
843
|
readonly darkSemantic: {
|
|
431
844
|
readonly background: "#161814";
|
|
@@ -463,8 +876,316 @@ declare const tokens: {
|
|
|
463
876
|
readonly focusRing: "#f0895c";
|
|
464
877
|
readonly shadowColor: "#000000";
|
|
465
878
|
readonly scrim: "color-mix(in srgb, var(--loidolt-shadow-color) 78%, transparent)";
|
|
879
|
+
readonly chart1: "#e0672f";
|
|
880
|
+
readonly chart2: "#6ea5bd";
|
|
881
|
+
readonly chart3: "#93b287";
|
|
882
|
+
readonly chart4: "#d9ab63";
|
|
883
|
+
readonly chart5: "#c49ac0";
|
|
884
|
+
readonly chart6: "#b8ad96";
|
|
885
|
+
readonly chart7: "#6fb8a6";
|
|
886
|
+
readonly chart8: "#c79a78";
|
|
887
|
+
readonly chartSequential1: "#3a2a1d";
|
|
888
|
+
readonly chartSequential2: "#6b4225";
|
|
889
|
+
readonly chartSequential3: "#a4602f";
|
|
890
|
+
readonly chartSequential4: "#d98a4d";
|
|
891
|
+
readonly chartSequential5: "#f2bd8a";
|
|
892
|
+
readonly chartDiverging1: "#85b6ca";
|
|
893
|
+
readonly chartDiverging2: "#5a8ea3";
|
|
894
|
+
readonly chartDiverging3: "#35596a";
|
|
895
|
+
readonly chartDiverging4: "#3a3d34";
|
|
896
|
+
readonly chartDiverging5: "#7a4428";
|
|
897
|
+
readonly chartDiverging6: "#bf6a3a";
|
|
898
|
+
readonly chartDiverging7: "#f0895c";
|
|
899
|
+
readonly chartPositive: "#93b287";
|
|
900
|
+
readonly chartNegative: "#e88b81";
|
|
901
|
+
readonly mapLand: "#161814";
|
|
902
|
+
readonly mapWater: "#1d2b31";
|
|
903
|
+
readonly mapPark: "#1f271c";
|
|
904
|
+
readonly mapRoad: "#2b2e26";
|
|
905
|
+
readonly mapRoadMajor: "#3a3d34";
|
|
906
|
+
readonly mapBuilding: "#24271f";
|
|
907
|
+
readonly mapBoundary: "#787c6b";
|
|
908
|
+
readonly mapLabel: "#ebe7dc";
|
|
909
|
+
readonly mapLabelHalo: "#161814";
|
|
910
|
+
readonly syntaxKeyword: "#a9441d";
|
|
911
|
+
readonly syntaxString: "#3f5139";
|
|
912
|
+
readonly syntaxComment: "#5f5b50";
|
|
913
|
+
readonly syntaxConstant: "#7c4d17";
|
|
914
|
+
readonly syntaxFunction: "#265162";
|
|
915
|
+
readonly syntaxParameter: "#7a4a78";
|
|
916
|
+
readonly syntaxPunctuation: "#474a42";
|
|
917
|
+
};
|
|
918
|
+
readonly roles: {
|
|
919
|
+
readonly radiusControl: string;
|
|
920
|
+
readonly radiusInner: string;
|
|
921
|
+
readonly radiusSurface: string;
|
|
922
|
+
readonly radiusOverlay: string;
|
|
923
|
+
readonly strokeFocus: string;
|
|
924
|
+
readonly strokeIndicator: string;
|
|
925
|
+
readonly strokeAccent: string;
|
|
926
|
+
readonly padControlX: string;
|
|
927
|
+
readonly padControlXSm: string;
|
|
928
|
+
readonly padControlXLg: string;
|
|
929
|
+
readonly padControlY: string;
|
|
930
|
+
readonly padControlYSm: string;
|
|
931
|
+
readonly padField: string;
|
|
932
|
+
readonly padItem: string;
|
|
933
|
+
readonly padCell: string;
|
|
934
|
+
readonly padCallout: string;
|
|
935
|
+
readonly padSurface: string;
|
|
936
|
+
readonly padOverlay: string;
|
|
937
|
+
readonly padPopover: string;
|
|
938
|
+
readonly padBarX: string;
|
|
939
|
+
readonly padPane: string;
|
|
940
|
+
readonly padPage: string;
|
|
941
|
+
readonly gapField: string;
|
|
942
|
+
readonly gapActions: string;
|
|
943
|
+
readonly labelTransform: string;
|
|
944
|
+
readonly labelTracking: string;
|
|
945
|
+
readonly labelTrackingWide: string;
|
|
946
|
+
readonly labelWeight: string;
|
|
947
|
+
readonly controlTransform: string;
|
|
948
|
+
readonly controlTracking: string;
|
|
949
|
+
readonly controlWeight: string;
|
|
950
|
+
readonly headingWeight: string;
|
|
951
|
+
readonly strongWeight: string;
|
|
466
952
|
};
|
|
467
953
|
};
|
|
468
954
|
type ThemeTokens = typeof tokens;
|
|
469
955
|
|
|
470
|
-
|
|
956
|
+
/**
|
|
957
|
+
* WCAG 2.x contrast arithmetic, shared by the token tests and by applications that need to pick
|
|
958
|
+
* or validate a colour at runtime (a user-chosen swatch, a generated label). Pure functions over
|
|
959
|
+
* hex strings, so they run anywhere — build scripts, servers, and the browser.
|
|
960
|
+
*
|
|
961
|
+
* @see https://www.w3.org/TR/WCAG22/#dfn-relative-luminance
|
|
962
|
+
*/
|
|
963
|
+
type ContrastLevel = 'AA' | 'AAA';
|
|
964
|
+
type TextSize = 'normal' | 'large';
|
|
965
|
+
interface ContrastValidation {
|
|
966
|
+
ratio: number;
|
|
967
|
+
/** `ratio` to two decimals, e.g. `'4.52:1'`. */
|
|
968
|
+
ratioString: string;
|
|
969
|
+
passesAANormal: boolean;
|
|
970
|
+
passesAALarge: boolean;
|
|
971
|
+
passesAAANormal: boolean;
|
|
972
|
+
passesAAALarge: boolean;
|
|
973
|
+
}
|
|
974
|
+
/** Minimum ratio per level and text size. Large text is 18.66px bold or 24px regular and up. */
|
|
975
|
+
declare const contrastRequirements: {
|
|
976
|
+
readonly AA: {
|
|
977
|
+
readonly normal: 4.5;
|
|
978
|
+
readonly large: 3;
|
|
979
|
+
};
|
|
980
|
+
readonly AAA: {
|
|
981
|
+
readonly normal: 7;
|
|
982
|
+
readonly large: 4.5;
|
|
983
|
+
};
|
|
984
|
+
};
|
|
985
|
+
/** Relative luminance, from 0 (black) to 1 (white). Accepts `#rgb` and `#rrggbb`. */
|
|
986
|
+
declare function getLuminance(hex: string): number;
|
|
987
|
+
/** Contrast ratio between two colours, from 1 to 21. Order does not matter. */
|
|
988
|
+
declare function getContrastRatio(foreground: string, background: string): number;
|
|
989
|
+
/** Whether a pair clears the WCAG threshold for the given level and text size. */
|
|
990
|
+
declare function meetsContrast(foreground: string, background: string, { level, size }?: {
|
|
991
|
+
level?: ContrastLevel;
|
|
992
|
+
size?: TextSize;
|
|
993
|
+
}): boolean;
|
|
994
|
+
/** Every threshold at once, for reporting. */
|
|
995
|
+
declare function validateContrast(foreground: string, background: string): ContrastValidation;
|
|
996
|
+
/**
|
|
997
|
+
* Whichever of two inks reads better on `background` — by measured ratio, not a luminance
|
|
998
|
+
* cut-off, so it stays right for any pair you pass. Defaults to the theme's own deep ink and
|
|
999
|
+
* panel, rather than pure black and white.
|
|
1000
|
+
*/
|
|
1001
|
+
declare function getContrastTextColor(background: string, { dark, light }?: {
|
|
1002
|
+
dark?: string;
|
|
1003
|
+
light?: string;
|
|
1004
|
+
}): string;
|
|
1005
|
+
/** A full set of colour roles as concrete values — a preset's `resolved.light` or `.dark`. */
|
|
1006
|
+
type ColorRoles = {
|
|
1007
|
+
readonly [K in SemanticRole]: string;
|
|
1008
|
+
};
|
|
1009
|
+
interface ContrastCheck {
|
|
1010
|
+
/** What the pair is, e.g. `muted text on surface`. */
|
|
1011
|
+
name: string;
|
|
1012
|
+
foreground: string;
|
|
1013
|
+
background: string;
|
|
1014
|
+
ratio: number;
|
|
1015
|
+
/** 4.5 for text (WCAG 1.4.3), 3 for control boundaries and focus rings (WCAG 1.4.11). */
|
|
1016
|
+
required: number;
|
|
1017
|
+
pass: boolean;
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* Every pairing the stylesheets actually draw, with the ratio WCAG AA asks of it.
|
|
1021
|
+
*
|
|
1022
|
+
* Small utility text (`--loidolt-font-size-xs`) is well under 18.66px, so every text pair needs
|
|
1023
|
+
* the full 4.5:1 rather than the large-text allowance. Decorative hairlines (`border`,
|
|
1024
|
+
* `border-soft`) are deliberately lighter and exempt; `border-control` is not, because it is the
|
|
1025
|
+
* only thing identifying an input.
|
|
1026
|
+
*/
|
|
1027
|
+
declare function contrastPairs(t: ColorRoles): Array<[name: string, fg: string, bg: string, required: number]>;
|
|
1028
|
+
/**
|
|
1029
|
+
* Checks a colour role set against WCAG AA. Run it in a test over your own preset's
|
|
1030
|
+
* `resolved.light` and `resolved.dark`:
|
|
1031
|
+
*
|
|
1032
|
+
* ```ts
|
|
1033
|
+
* expect(auditContrast(myPreset.resolved.dark).filter((check) => !check.pass)).toEqual([]);
|
|
1034
|
+
* ```
|
|
1035
|
+
*/
|
|
1036
|
+
declare function auditContrast(colors: ColorRoles): ContrastCheck[];
|
|
1037
|
+
|
|
1038
|
+
/** A colour role: `surface`, `textMuted`, `onAccent`, … */
|
|
1039
|
+
type ColorRole = keyof typeof semanticDefs;
|
|
1040
|
+
/** A shape or voice role: `radiusControl`, `padCell`, `labelTransform`, … */
|
|
1041
|
+
type Role = keyof typeof roleDefs;
|
|
1042
|
+
type Overrides<T> = {
|
|
1043
|
+
readonly [K in keyof T]?: T[K] extends string ? string : Overrides<T[K]>;
|
|
1044
|
+
};
|
|
1045
|
+
/**
|
|
1046
|
+
* The primitive scales a preset may move. Colour primitives are deliberately absent: colour is
|
|
1047
|
+
* restyled through the colour *roles*, which is also the only way it survives subtree scoping
|
|
1048
|
+
* (a `var()` resolves where it is declared, so a role declared on `:root` would never see a
|
|
1049
|
+
* primitive overridden further down).
|
|
1050
|
+
*/
|
|
1051
|
+
interface PresetPrimitives {
|
|
1052
|
+
readonly typography?: Overrides<typeof typography>;
|
|
1053
|
+
readonly spacing?: Overrides<typeof spacing>;
|
|
1054
|
+
readonly sizing?: Overrides<typeof sizing>;
|
|
1055
|
+
readonly borders?: Overrides<typeof borders>;
|
|
1056
|
+
readonly shadows?: Overrides<typeof shadows>;
|
|
1057
|
+
readonly motion?: Overrides<typeof motion>;
|
|
1058
|
+
}
|
|
1059
|
+
type ColorOverrides = {
|
|
1060
|
+
readonly [K in ColorRole]?: string;
|
|
1061
|
+
};
|
|
1062
|
+
interface PresetDefinition<Light extends ColorOverrides = ColorOverrides> {
|
|
1063
|
+
/** Lowercase identifier, used in `data-preset="…"` and file names. */
|
|
1064
|
+
name: string;
|
|
1065
|
+
/** Human-readable name for pickers. Defaults to the capitalised `name`. */
|
|
1066
|
+
label?: string;
|
|
1067
|
+
description?: string;
|
|
1068
|
+
/** Start from another preset instead of the base system, then apply this definition on top. */
|
|
1069
|
+
extends?: Preset;
|
|
1070
|
+
primitives?: PresetPrimitives;
|
|
1071
|
+
roles?: {
|
|
1072
|
+
readonly [K in Role]?: string;
|
|
1073
|
+
};
|
|
1074
|
+
/**
|
|
1075
|
+
* One knob for every padding and gap role (`pad-*`, `gap-*`) this definition does not set
|
|
1076
|
+
* itself: `0.75` is a quarter tighter, `1.2` a fifth roomier. Between 0.5 and 1.5.
|
|
1077
|
+
*/
|
|
1078
|
+
density?: number;
|
|
1079
|
+
/**
|
|
1080
|
+
* Colour roles for each scheme. `dark` must restate every role `light` changes — a light-only
|
|
1081
|
+
* override would leave the dark scheme pairing the new colour with the old one.
|
|
1082
|
+
*/
|
|
1083
|
+
colors?: {
|
|
1084
|
+
light: Light;
|
|
1085
|
+
dark: {
|
|
1086
|
+
readonly [K in keyof Light]-?: string;
|
|
1087
|
+
} & ColorOverrides;
|
|
1088
|
+
};
|
|
1089
|
+
/** Stylesheet URLs `@import`ed ahead of the preset, typically webfonts the preset names. */
|
|
1090
|
+
fontImport?: string | readonly string[];
|
|
1091
|
+
}
|
|
1092
|
+
interface Preset {
|
|
1093
|
+
readonly name: string;
|
|
1094
|
+
readonly label: string;
|
|
1095
|
+
readonly description: string | undefined;
|
|
1096
|
+
readonly fontImports: readonly string[];
|
|
1097
|
+
/** Custom property declarations per block, values as they are written to CSS. */
|
|
1098
|
+
readonly declarations: {
|
|
1099
|
+
/** Primitives and shape/voice roles — scheme-independent. */
|
|
1100
|
+
readonly shape: ReadonlyArray<readonly [name: string, value: string]>;
|
|
1101
|
+
readonly light: ReadonlyArray<readonly [name: string, value: string]>;
|
|
1102
|
+
readonly dark: ReadonlyArray<readonly [name: string, value: string]>;
|
|
1103
|
+
};
|
|
1104
|
+
/** Every role with its references followed to a concrete value, for JS consumers and tests. */
|
|
1105
|
+
readonly resolved: {
|
|
1106
|
+
readonly roles: {
|
|
1107
|
+
readonly [K in Role]: string;
|
|
1108
|
+
};
|
|
1109
|
+
readonly light: ColorRoles;
|
|
1110
|
+
readonly dark: ColorRoles;
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Defines a named style set: colours for both schemes plus the shape and voice of every
|
|
1115
|
+
* component, compiled to a stylesheet by {@link generatePresetCss}.
|
|
1116
|
+
*
|
|
1117
|
+
* ```ts
|
|
1118
|
+
* export const studio = definePreset({
|
|
1119
|
+
* name: 'studio',
|
|
1120
|
+
* roles: { radiusControl: '4px', labelTransform: 'none' },
|
|
1121
|
+
* colors: {
|
|
1122
|
+
* light: { accent: '#0b6bcb', accentHover: '#0956a3' },
|
|
1123
|
+
* dark: { accent: '#5aa7f0', accentHover: '#7ab8f3' },
|
|
1124
|
+
* },
|
|
1125
|
+
* });
|
|
1126
|
+
* ```
|
|
1127
|
+
*
|
|
1128
|
+
* Every preset is complete: whatever it does not set comes from the base system (or from the
|
|
1129
|
+
* preset it `extends`), so nesting one preset inside another restyles the subtree fully rather
|
|
1130
|
+
* than blending the two.
|
|
1131
|
+
*/
|
|
1132
|
+
declare function definePreset<const Light extends ColorOverrides & {
|
|
1133
|
+
readonly [K in Exclude<keyof Light, ColorRole>]: never;
|
|
1134
|
+
} = Record<never, never>>(definition: PresetDefinition<Light>): Preset;
|
|
1135
|
+
interface PresetCssOptions {
|
|
1136
|
+
/**
|
|
1137
|
+
* - `attribute` (default): applies under `[data-preset="<name>"]`, on `<html>` or any subtree,
|
|
1138
|
+
* so several presets can ship side by side and switch at runtime.
|
|
1139
|
+
* - `root`: applies to `:root` outright, for an app that only ever uses this one preset.
|
|
1140
|
+
*/
|
|
1141
|
+
scope?: 'attribute' | 'root';
|
|
1142
|
+
/**
|
|
1143
|
+
* Which block to emit, mirroring the base `tokens` / `dark` / `dark-auto` trio:
|
|
1144
|
+
* - `light` (default): shape, voice and the light colours, plus any `fontImport`.
|
|
1145
|
+
* - `dark`: the dark colours under `data-theme="dark"`.
|
|
1146
|
+
* - `dark-auto`: the same, plus a `prefers-color-scheme` rule an explicit light choice overrides.
|
|
1147
|
+
*/
|
|
1148
|
+
scheme?: 'light' | 'dark' | 'dark-auto';
|
|
1149
|
+
}
|
|
1150
|
+
/** Serializes one block of a preset to CSS. See {@link presetStylesheets} for the full set. */
|
|
1151
|
+
declare function generatePresetCss(preset: Preset, options?: PresetCssOptions): string;
|
|
1152
|
+
/**
|
|
1153
|
+
* Every stylesheet a preset ships, keyed by file name: `<name>.css`, `<name>-dark.css` and
|
|
1154
|
+
* `<name>-dark-auto.css` scoped to `data-preset`, and the same three with `.root` for a
|
|
1155
|
+
* single-preset app. Write them from a build script to ship your own preset the way the
|
|
1156
|
+
* built-in ones are shipped.
|
|
1157
|
+
*/
|
|
1158
|
+
declare function presetStylesheets(preset: Preset): Record<string, string>;
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* The Loidolt look, packed tighter for data-dense tools. Coarse pointers still get their 44px
|
|
1162
|
+
* targets: those rules key off the pointer, not the preset.
|
|
1163
|
+
*/
|
|
1164
|
+
declare const compact: Preset;
|
|
1165
|
+
|
|
1166
|
+
/** The base system as a preset: square, uppercase utility voice, warm paper and orange. */
|
|
1167
|
+
declare const loidolt: Preset;
|
|
1168
|
+
|
|
1169
|
+
/** Rounded corners, sentence-case labels and a cool neutral palette with a blue accent. */
|
|
1170
|
+
declare const soft: Preset;
|
|
1171
|
+
|
|
1172
|
+
/** The presets this package ships, default first. */
|
|
1173
|
+
declare const builtInPresets: readonly [Preset, Preset, Preset];
|
|
1174
|
+
/** Names of the built-in presets, for `createTheme({ presets })` and pickers. */
|
|
1175
|
+
type BuiltInPresetName = (typeof builtInPresets)[number]['name'];
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* Design tokens for Loidolt applications.
|
|
1179
|
+
*
|
|
1180
|
+
* Three tiers:
|
|
1181
|
+
* - **Primitives** (`--loidolt-color-*`, `--loidolt-space-*`, …) are the raw palette and scales.
|
|
1182
|
+
* - **Colour roles** (`--loidolt-surface`, `--loidolt-text`, `--loidolt-chart-1`, …) name what a
|
|
1183
|
+
* colour is *for*.
|
|
1184
|
+
* - **Shape and voice roles** (`--loidolt-radius-control`, `--loidolt-pad-cell`, …) do the same
|
|
1185
|
+
* for corners, strokes, density and typographic voice.
|
|
1186
|
+
*
|
|
1187
|
+
* Stylesheets and components consume only the role tiers, so a consumer can restyle the
|
|
1188
|
+
* system — or add a dark mode, or a whole preset — by redefining roles alone.
|
|
1189
|
+
*/
|
|
1190
|
+
|
|
1191
|
+
export { type BuiltInPresetName, type ChartColors, type ColorOverrides, type ColorRole, type ColorRoles, type ColorScheme, type ContrastCheck, type ContrastLevel, type ContrastValidation, type MapColors, type Preset, type PresetCssOptions, type PresetDefinition, type PresetPrimitives, type ResolvedRoles, type Role, type RoleSpec, type SemanticRole, type SyntaxColors, type TextSize, type ThemeTokens, type TokenRef, aspectRatio, auditContrast, borders, breakpoints, builtInPresets, chartColors, chartRoles, colors, compact, contrastPairs, contrastRequirements, cssVarName, darkSemantic, tokens as default, definePreset, flattenTokens, generateCss, generateDarkCss, generatePresetCss, getContrastRatio, getContrastTextColor, getLuminance, loidolt, mapColors, mapRoles, meetsContrast, motion, presetStylesheets, resolveRoles, roleValue, roleVar, roles, semantic, shadows, sizing, soft, spacing, syntaxColors, syntaxRoles, tokens, typography, validateContrast, zIndex };
|