@designtools/tokens 0.1.6 → 0.2.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 +215 -8
- package/dist/{chunk-G6P25B5W.js → chunk-T62MMGGQ.js} +378 -497
- package/dist/cli.js +340 -29
- package/dist/index.d.ts +133 -125
- package/dist/index.js +2 -6
- package/package.json +2 -2
|
@@ -1,3 +1,64 @@
|
|
|
1
|
+
// src/types.ts
|
|
2
|
+
var VALID_SHADES = [25, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
3
|
+
|
|
4
|
+
// src/shades.ts
|
|
5
|
+
var DEFAULT_SEED_SHADE = 500;
|
|
6
|
+
var DEFAULT_ANCHOR_INDEX = VALID_SHADES.indexOf(DEFAULT_SEED_SHADE);
|
|
7
|
+
var TAILWIND_SHADES = VALID_SHADES.filter((s) => s !== 25);
|
|
8
|
+
var SHADE_PRESETS = {
|
|
9
|
+
tailwind: TAILWIND_SHADES,
|
|
10
|
+
full: [...VALID_SHADES]
|
|
11
|
+
};
|
|
12
|
+
function resolveShades(requested) {
|
|
13
|
+
if (!requested || requested.length === 0) return [...VALID_SHADES];
|
|
14
|
+
const seen = new Set(requested);
|
|
15
|
+
return VALID_SHADES.filter((s) => seen.has(s));
|
|
16
|
+
}
|
|
17
|
+
function snapShade(shade, active) {
|
|
18
|
+
if (active.includes(shade)) return shade;
|
|
19
|
+
if (active.length === 0) {
|
|
20
|
+
throw new Error("cannot snap a shade against an empty shade set");
|
|
21
|
+
}
|
|
22
|
+
const target = VALID_SHADES.indexOf(shade);
|
|
23
|
+
let best = active[0];
|
|
24
|
+
let bestDistance = Infinity;
|
|
25
|
+
for (const candidate of active) {
|
|
26
|
+
const distance = Math.abs(VALID_SHADES.indexOf(candidate) - target);
|
|
27
|
+
if (distance < bestDistance || distance === bestDistance && candidate > best) {
|
|
28
|
+
best = candidate;
|
|
29
|
+
bestDistance = distance;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return best;
|
|
33
|
+
}
|
|
34
|
+
function sampleCurve(curve, t) {
|
|
35
|
+
if (curve.length === 1) return curve[0];
|
|
36
|
+
const pos = t * (curve.length - 1);
|
|
37
|
+
const i = Math.min(Math.floor(pos), curve.length - 2);
|
|
38
|
+
return curve[i] + (curve[i + 1] - curve[i]) * (pos - i);
|
|
39
|
+
}
|
|
40
|
+
function reanchorFactors(base, seedShade) {
|
|
41
|
+
const anchor = VALID_SHADES.indexOf(seedShade);
|
|
42
|
+
if (anchor === DEFAULT_ANCHOR_INDEX) return [...base];
|
|
43
|
+
const lighter = base.slice(0, DEFAULT_ANCHOR_INDEX);
|
|
44
|
+
const darker = base.slice(DEFAULT_ANCHOR_INDEX + 1);
|
|
45
|
+
const out = new Array(base.length).fill(0);
|
|
46
|
+
for (let i = 0; i < anchor; i++) {
|
|
47
|
+
out[i] = sampleCurve(lighter, anchor > 1 ? i / (anchor - 1) : 0);
|
|
48
|
+
}
|
|
49
|
+
out[anchor] = 0;
|
|
50
|
+
const below = base.length - 1 - anchor;
|
|
51
|
+
for (let j = 0; j < below; j++) {
|
|
52
|
+
out[anchor + 1 + j] = sampleCurve(darker, below > 1 ? j / (below - 1) : 1);
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
function chromaShadeFor(index, seedShade) {
|
|
57
|
+
const anchor = VALID_SHADES.indexOf(seedShade);
|
|
58
|
+
const shifted = index + (DEFAULT_ANCHOR_INDEX - anchor);
|
|
59
|
+
return VALID_SHADES[Math.max(0, Math.min(VALID_SHADES.length - 1, shifted))];
|
|
60
|
+
}
|
|
61
|
+
|
|
1
62
|
// src/oklch.ts
|
|
2
63
|
import {
|
|
3
64
|
formatHex,
|
|
@@ -47,100 +108,64 @@ function computeScaleChroma(scaleValue, baseChroma) {
|
|
|
47
108
|
const t = (scaleValue - 0.85) / 0.15;
|
|
48
109
|
return baseChroma * (1 - 0.06 * t);
|
|
49
110
|
}
|
|
50
|
-
|
|
111
|
+
var LIGHTNESS_FACTORS = {
|
|
112
|
+
// Radix-style easing: smooth gradients at the light end, larger jumps at the
|
|
113
|
+
// dark end for text contrast.
|
|
114
|
+
fixed: {
|
|
115
|
+
chromatic: [0.98, 0.93, 0.86, 0.71, 0.6, 0.38, 0, -0.2, -0.38, -0.56, -0.82, -0.95],
|
|
116
|
+
// Neutrals: smoother exponential curve, more even perceptual steps.
|
|
117
|
+
achromatic: [0.98, 0.94, 0.88, 0.78, 0.64, 0.32, 0, -0.3, -0.48, -0.66, -0.82, -0.92]
|
|
118
|
+
},
|
|
119
|
+
// APCA-tuned: tighter spacing in the light range, more even steps in the dark.
|
|
120
|
+
perceptual: {
|
|
121
|
+
chromatic: [0.97, 0.92, 0.84, 0.68, 0.52, 0.3, 0, -0.22, -0.4, -0.58, -0.82, -0.95],
|
|
122
|
+
achromatic: [0.98, 0.95, 0.9, 0.8, 0.66, 0.38, 0, -0.26, -0.44, -0.62, -0.8, -0.92]
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
function buildScale(baseColor, strategy, options) {
|
|
51
126
|
const base = parseToOklch(baseColor);
|
|
52
127
|
const baseLightness = base.l;
|
|
53
128
|
const baseChroma = base.c || 0;
|
|
54
129
|
const baseHue = base.h || 0;
|
|
55
130
|
const isAchromatic = baseChroma < 0.01;
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
const
|
|
131
|
+
const seedShade = options?.seedShade ?? DEFAULT_SEED_SHADE;
|
|
132
|
+
const emitted = resolveShades(options?.shades);
|
|
133
|
+
const maxLightness = Math.max(0.98, baseLightness);
|
|
134
|
+
const minLightness = Math.min(0.15, baseLightness);
|
|
59
135
|
const headroomUp = maxLightness - baseLightness;
|
|
60
136
|
const headroomDown = baseLightness - minLightness;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// Very light
|
|
67
|
-
100: baseLightness + headroomUp * 0.88,
|
|
68
|
-
// Very light
|
|
69
|
-
200: baseLightness + headroomUp * 0.78,
|
|
70
|
-
// Light
|
|
71
|
-
300: baseLightness + headroomUp * 0.64,
|
|
72
|
-
// Light
|
|
73
|
-
400: baseLightness + headroomUp * 0.32,
|
|
74
|
-
// Medium-light
|
|
75
|
-
500: baseLightness,
|
|
76
|
-
// Exact match
|
|
77
|
-
600: baseLightness - headroomDown * 0.3,
|
|
78
|
-
// Medium-dark
|
|
79
|
-
700: baseLightness - headroomDown * 0.48,
|
|
80
|
-
// Dark
|
|
81
|
-
800: baseLightness - headroomDown * 0.66,
|
|
82
|
-
// Dark
|
|
83
|
-
900: baseLightness - headroomDown * 0.82,
|
|
84
|
-
// Very dark
|
|
85
|
-
950: baseLightness - headroomDown * 0.92
|
|
86
|
-
// Extremely dark
|
|
87
|
-
};
|
|
88
|
-
} else {
|
|
89
|
-
lightnessSteps = {
|
|
90
|
-
25: baseLightness + headroomUp * 0.98,
|
|
91
|
-
// Nearly white (subtle tint)
|
|
92
|
-
50: baseLightness + headroomUp * 0.93,
|
|
93
|
-
// Very light background
|
|
94
|
-
100: baseLightness + headroomUp * 0.86,
|
|
95
|
-
// Light background
|
|
96
|
-
200: baseLightness + headroomUp * 0.71,
|
|
97
|
-
// Soft background
|
|
98
|
-
300: baseLightness + headroomUp * 0.6,
|
|
99
|
-
// UI element background
|
|
100
|
-
400: baseLightness + headroomUp * 0.38,
|
|
101
|
-
// Hover state
|
|
102
|
-
500: baseLightness,
|
|
103
|
-
// Base color
|
|
104
|
-
600: baseLightness - headroomDown * 0.2,
|
|
105
|
-
// Active/pressed state (smaller step)
|
|
106
|
-
700: baseLightness - headroomDown * 0.38,
|
|
107
|
-
// Borders
|
|
108
|
-
800: baseLightness - headroomDown * 0.56,
|
|
109
|
-
// Solid backgrounds
|
|
110
|
-
900: baseLightness - headroomDown * 0.82,
|
|
111
|
-
// High contrast text
|
|
112
|
-
950: baseLightness - headroomDown * 0.95
|
|
113
|
-
// Highest contrast
|
|
114
|
-
};
|
|
115
|
-
}
|
|
137
|
+
const factors = reanchorFactors(
|
|
138
|
+
LIGHTNESS_FACTORS[strategy][isAchromatic ? "achromatic" : "chromatic"],
|
|
139
|
+
seedShade
|
|
140
|
+
);
|
|
141
|
+
const computeChroma = strategy === "perceptual" ? computeScaleChromaPerceptual : computeScaleChroma;
|
|
116
142
|
const scale = {};
|
|
117
|
-
for (
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
|
|
143
|
+
for (let i = 0; i < VALID_SHADES.length; i++) {
|
|
144
|
+
const shade = VALID_SHADES[i];
|
|
145
|
+
if (!emitted.includes(shade)) continue;
|
|
146
|
+
if (shade === seedShade) {
|
|
147
|
+
scale[shade] = getOklchString(baseColor);
|
|
121
148
|
continue;
|
|
122
149
|
}
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
c: Math.max(0, chroma),
|
|
134
|
-
// Ensure chroma doesn't go negative
|
|
135
|
-
h: hue
|
|
136
|
-
};
|
|
137
|
-
const l = (shadeColor.l * 100).toFixed(2) + "%";
|
|
138
|
-
const c = shadeColor.c.toFixed(4);
|
|
139
|
-
const h = (shadeColor.h || 0).toFixed(2);
|
|
140
|
-
scale[shadeNum] = `oklch(${l} ${c} ${h})`;
|
|
150
|
+
const factor = factors[i];
|
|
151
|
+
const target = factor >= 0 ? baseLightness + headroomUp * factor : baseLightness + headroomDown * factor;
|
|
152
|
+
const lightness = Math.max(minLightness, Math.min(maxLightness, target));
|
|
153
|
+
const chromaShade = chromaShadeFor(i, seedShade);
|
|
154
|
+
const normalizedPosition = (chromaShade - 25) / 925;
|
|
155
|
+
const chroma = isAchromatic ? baseChroma : computeChroma(normalizedPosition, baseChroma);
|
|
156
|
+
const l = (lightness * 100).toFixed(2) + "%";
|
|
157
|
+
const c = Math.max(0, chroma).toFixed(4);
|
|
158
|
+
const h = baseHue.toFixed(2);
|
|
159
|
+
scale[shade] = `oklch(${l} ${c} ${h})`;
|
|
141
160
|
}
|
|
142
161
|
return scale;
|
|
143
162
|
}
|
|
163
|
+
function generateColorScale(baseColor, options) {
|
|
164
|
+
return buildScale(baseColor, "fixed", options);
|
|
165
|
+
}
|
|
166
|
+
function generateColorScaleAPCA(baseColor, options) {
|
|
167
|
+
return buildScale(baseColor, "perceptual", options);
|
|
168
|
+
}
|
|
144
169
|
function adjustLightness(color, lightness) {
|
|
145
170
|
const oklchColor = parseToOklch(color);
|
|
146
171
|
return oklchToHex({
|
|
@@ -220,74 +245,6 @@ function classifyAPCALevel(lcValue) {
|
|
|
220
245
|
if (lcValue >= 45) return "Minimum";
|
|
221
246
|
return "Fail";
|
|
222
247
|
}
|
|
223
|
-
function generateColorScaleAPCA(baseColor) {
|
|
224
|
-
const base = parseToOklch(baseColor);
|
|
225
|
-
const baseLightness = base.l;
|
|
226
|
-
const baseChroma = base.c || 0;
|
|
227
|
-
const baseHue = base.h || 0;
|
|
228
|
-
const isAchromatic = baseChroma < 0.01;
|
|
229
|
-
const maxLightness = 0.98;
|
|
230
|
-
const minLightness = 0.15;
|
|
231
|
-
const headroomUp = maxLightness - baseLightness;
|
|
232
|
-
const headroomDown = baseLightness - minLightness;
|
|
233
|
-
let lightnessSteps;
|
|
234
|
-
if (isAchromatic) {
|
|
235
|
-
lightnessSteps = {
|
|
236
|
-
25: baseLightness + headroomUp * 0.98,
|
|
237
|
-
50: baseLightness + headroomUp * 0.95,
|
|
238
|
-
100: baseLightness + headroomUp * 0.9,
|
|
239
|
-
200: baseLightness + headroomUp * 0.8,
|
|
240
|
-
300: baseLightness + headroomUp * 0.66,
|
|
241
|
-
400: baseLightness + headroomUp * 0.38,
|
|
242
|
-
500: baseLightness,
|
|
243
|
-
600: baseLightness - headroomDown * 0.26,
|
|
244
|
-
700: baseLightness - headroomDown * 0.44,
|
|
245
|
-
800: baseLightness - headroomDown * 0.62,
|
|
246
|
-
900: baseLightness - headroomDown * 0.8,
|
|
247
|
-
950: baseLightness - headroomDown * 0.92
|
|
248
|
-
};
|
|
249
|
-
} else {
|
|
250
|
-
lightnessSteps = {
|
|
251
|
-
25: baseLightness + headroomUp * 0.97,
|
|
252
|
-
50: baseLightness + headroomUp * 0.92,
|
|
253
|
-
100: baseLightness + headroomUp * 0.84,
|
|
254
|
-
200: baseLightness + headroomUp * 0.68,
|
|
255
|
-
300: baseLightness + headroomUp * 0.52,
|
|
256
|
-
400: baseLightness + headroomUp * 0.3,
|
|
257
|
-
500: baseLightness,
|
|
258
|
-
600: baseLightness - headroomDown * 0.22,
|
|
259
|
-
700: baseLightness - headroomDown * 0.4,
|
|
260
|
-
800: baseLightness - headroomDown * 0.58,
|
|
261
|
-
900: baseLightness - headroomDown * 0.82,
|
|
262
|
-
950: baseLightness - headroomDown * 0.95
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
const scale = {};
|
|
266
|
-
for (const [shade, targetLightness] of Object.entries(lightnessSteps)) {
|
|
267
|
-
const shadeNum = parseInt(shade);
|
|
268
|
-
if (shadeNum === 500) {
|
|
269
|
-
scale[500] = getOklchString(baseColor);
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
|
-
const lightness = Math.max(0.15, Math.min(0.98, targetLightness));
|
|
273
|
-
const normalizedPosition = (shadeNum - 25) / 925;
|
|
274
|
-
let chroma = baseChroma;
|
|
275
|
-
if (!isAchromatic) {
|
|
276
|
-
chroma = computeScaleChromaPerceptual(normalizedPosition, baseChroma);
|
|
277
|
-
}
|
|
278
|
-
const shadeColor = {
|
|
279
|
-
mode: "oklch",
|
|
280
|
-
l: lightness,
|
|
281
|
-
c: Math.max(0, chroma),
|
|
282
|
-
h: baseHue
|
|
283
|
-
};
|
|
284
|
-
const l = (shadeColor.l * 100).toFixed(2) + "%";
|
|
285
|
-
const c = shadeColor.c.toFixed(4);
|
|
286
|
-
const h = (shadeColor.h || 0).toFixed(2);
|
|
287
|
-
scale[shadeNum] = `oklch(${l} ${c} ${h})`;
|
|
288
|
-
}
|
|
289
|
-
return scale;
|
|
290
|
-
}
|
|
291
248
|
function computeScaleChromaPerceptual(scaleValue, baseChroma) {
|
|
292
249
|
if (scaleValue < 0.03) {
|
|
293
250
|
const t2 = scaleValue / 0.03;
|
|
@@ -382,8 +339,9 @@ function deriveWarningColor(primaryColor) {
|
|
|
382
339
|
};
|
|
383
340
|
return oklchToHex(warning);
|
|
384
341
|
}
|
|
385
|
-
function generatePrimitivePalette(brandColors, lightnessStrategy = "fixed") {
|
|
386
|
-
const
|
|
342
|
+
function generatePrimitivePalette(brandColors, lightnessStrategy = "fixed", scaleOptions) {
|
|
343
|
+
const gen = lightnessStrategy === "perceptual" ? generateColorScaleAPCA : generateColorScale;
|
|
344
|
+
const genScale = (color) => gen(color, scaleOptions);
|
|
387
345
|
const palette = {};
|
|
388
346
|
palette.black = "oklch(0 0 0)";
|
|
389
347
|
palette.white = "oklch(1 0 0)";
|
|
@@ -414,7 +372,9 @@ function getShade(palette, colorName, shade) {
|
|
|
414
372
|
}
|
|
415
373
|
|
|
416
374
|
// src/semantic.ts
|
|
417
|
-
|
|
375
|
+
function shadeKeys(shades) {
|
|
376
|
+
return resolveShades(shades);
|
|
377
|
+
}
|
|
418
378
|
function getContrastThresholds(algorithm, target) {
|
|
419
379
|
if (algorithm === "apca") {
|
|
420
380
|
switch (target) {
|
|
@@ -436,13 +396,13 @@ function getContrastThresholds(algorithm, target) {
|
|
|
436
396
|
}
|
|
437
397
|
}
|
|
438
398
|
}
|
|
439
|
-
function findBestForeground(background, scale, neutralScale, white, black, algorithm, contrastTarget, colorName) {
|
|
399
|
+
function findBestForeground(background, scale, neutralScale, white, black, algorithm, contrastTarget, colorName, activeShades) {
|
|
440
400
|
const { floor, target } = getContrastThresholds(algorithm, contrastTarget);
|
|
441
401
|
const getContrast = (fg) => algorithm === "apca" ? getAPCAContrast(fg, background) : getContrastRatio(background, fg);
|
|
442
402
|
function searchScale(s, refColorName) {
|
|
443
403
|
let bestPassing = null;
|
|
444
404
|
let bestOverall = null;
|
|
445
|
-
for (const shade of
|
|
405
|
+
for (const shade of activeShades) {
|
|
446
406
|
const c = getContrast(s[shade]);
|
|
447
407
|
if (c >= floor) {
|
|
448
408
|
if (!bestPassing || Math.abs(c - target) < Math.abs(bestPassing.contrast - target)) {
|
|
@@ -487,12 +447,14 @@ function findBestForeground(background, scale, neutralScale, white, black, algor
|
|
|
487
447
|
if (whiteC >= blackC) return { value: white, ref: { type: "white" } };
|
|
488
448
|
return { value: black, ref: { type: "black" } };
|
|
489
449
|
}
|
|
490
|
-
function createExtendedSemanticColor(scale, neutral, white, black, mode, contrastAlgorithm = "wcag", contrastTarget = "aa", overrides, colorName = "primary") {
|
|
491
|
-
const
|
|
492
|
-
const
|
|
493
|
-
const
|
|
494
|
-
const
|
|
495
|
-
const
|
|
450
|
+
function createExtendedSemanticColor(scale, neutral, white, black, mode, contrastAlgorithm = "wcag", contrastTarget = "aa", overrides, colorName = "primary", shades) {
|
|
451
|
+
const activeShades = shadeKeys(shades);
|
|
452
|
+
const findFg = (bg) => findBestForeground(bg, scale, neutral, white, black, contrastAlgorithm, contrastTarget, colorName, activeShades);
|
|
453
|
+
const snap = (shade) => snapShade(shade, activeShades);
|
|
454
|
+
const defaults = mode === "light" ? { DEFAULT: snap(500), subdued: snap(50), highlight: snap(700) } : { DEFAULT: snap(600), subdued: snap(200), highlight: snap(400) };
|
|
455
|
+
const defaultShade = overrides?.DEFAULT ? snap(overrides.DEFAULT) : defaults.DEFAULT;
|
|
456
|
+
const subduedShade = overrides?.subdued ? snap(overrides.subdued) : defaults.subdued;
|
|
457
|
+
const highlightShade = overrides?.highlight ? snap(overrides.highlight) : defaults.highlight;
|
|
496
458
|
const DEFAULT = scale[defaultShade];
|
|
497
459
|
const subdued = scale[subduedShade];
|
|
498
460
|
const highlight = scale[highlightShade];
|
|
@@ -517,6 +479,7 @@ function generateSemanticTokens(palette, mode, options) {
|
|
|
517
479
|
const contrastAlgorithm = options?.contrastAlgorithm ?? "wcag";
|
|
518
480
|
const contrastTarget = options?.contrastTarget ?? "aa";
|
|
519
481
|
const shadeOverrides = options?.shadeOverrides ?? {};
|
|
482
|
+
const activeShades = shadeKeys(options?.shades);
|
|
520
483
|
const neutral = palette.neutral;
|
|
521
484
|
if (!neutral) {
|
|
522
485
|
throw new Error("Neutral palette not found");
|
|
@@ -531,18 +494,18 @@ function generateSemanticTokens(palette, mode, options) {
|
|
|
531
494
|
throw new Error("Required color palettes not found");
|
|
532
495
|
}
|
|
533
496
|
const muted = mode === "light" ? {
|
|
534
|
-
DEFAULT: neutral[25],
|
|
535
|
-
foreground: neutral[500]
|
|
497
|
+
DEFAULT: neutral[snapShade(25, activeShades)],
|
|
498
|
+
foreground: neutral[snapShade(500, activeShades)]
|
|
536
499
|
} : {
|
|
537
|
-
DEFAULT: neutral[800],
|
|
538
|
-
foreground: neutral[200]
|
|
500
|
+
DEFAULT: neutral[snapShade(800, activeShades)],
|
|
501
|
+
foreground: neutral[snapShade(200, activeShades)]
|
|
539
502
|
};
|
|
540
503
|
const tokens = {
|
|
541
|
-
primary: createExtendedSemanticColor(primary, neutral, white, black, mode, contrastAlgorithm, contrastTarget, shadeOverrides.primary?.[mode], "primary"),
|
|
542
|
-
neutral: createExtendedSemanticColor(neutral, neutral, white, black, mode, contrastAlgorithm, contrastTarget, shadeOverrides.neutral?.[mode], "neutral"),
|
|
543
|
-
success: createExtendedSemanticColor(success, neutral, white, black, mode, contrastAlgorithm, contrastTarget, shadeOverrides.success?.[mode], "success"),
|
|
544
|
-
destructive: createExtendedSemanticColor(destructive, neutral, white, black, mode, contrastAlgorithm, contrastTarget, shadeOverrides.destructive?.[mode], "destructive"),
|
|
545
|
-
warning: createExtendedSemanticColor(warning, neutral, white, black, mode, contrastAlgorithm, contrastTarget, shadeOverrides.warning?.[mode], "warning"),
|
|
504
|
+
primary: createExtendedSemanticColor(primary, neutral, white, black, mode, contrastAlgorithm, contrastTarget, shadeOverrides.primary?.[mode], "primary", activeShades),
|
|
505
|
+
neutral: createExtendedSemanticColor(neutral, neutral, white, black, mode, contrastAlgorithm, contrastTarget, shadeOverrides.neutral?.[mode], "neutral", activeShades),
|
|
506
|
+
success: createExtendedSemanticColor(success, neutral, white, black, mode, contrastAlgorithm, contrastTarget, shadeOverrides.success?.[mode], "success", activeShades),
|
|
507
|
+
destructive: createExtendedSemanticColor(destructive, neutral, white, black, mode, contrastAlgorithm, contrastTarget, shadeOverrides.destructive?.[mode], "destructive", activeShades),
|
|
508
|
+
warning: createExtendedSemanticColor(warning, neutral, white, black, mode, contrastAlgorithm, contrastTarget, shadeOverrides.warning?.[mode], "warning", activeShades),
|
|
546
509
|
muted
|
|
547
510
|
};
|
|
548
511
|
const coreColors = [
|
|
@@ -568,24 +531,28 @@ function generateSemanticTokens(palette, mode, options) {
|
|
|
568
531
|
contrastAlgorithm,
|
|
569
532
|
contrastTarget,
|
|
570
533
|
shadeOverrides[colorName]?.[mode],
|
|
571
|
-
colorName
|
|
534
|
+
colorName,
|
|
535
|
+
activeShades
|
|
572
536
|
);
|
|
573
537
|
}
|
|
574
538
|
}
|
|
575
539
|
return tokens;
|
|
576
540
|
}
|
|
577
|
-
function generateSurfaceTokens(palette, mode, overrides) {
|
|
541
|
+
function generateSurfaceTokens(palette, mode, overrides, shades) {
|
|
542
|
+
const activeShades = shadeKeys(shades);
|
|
543
|
+
const snap = (shade) => snapShade(shade, activeShades);
|
|
578
544
|
const neutral = palette.neutral;
|
|
579
545
|
if (!neutral) {
|
|
580
546
|
throw new Error("Neutral palette not found");
|
|
581
547
|
}
|
|
582
548
|
const black = palette.black;
|
|
583
549
|
const white = palette.white;
|
|
584
|
-
const defaults = mode === "light" ? { canvas: 25, "canvas-foreground": 800, surface: "white", "surface-foreground": 800, overlay: "white", "overlay-foreground": 800 } : { canvas: 950, "canvas-foreground": "white", surface: "black", "surface-foreground": "white", overlay: "black", "overlay-foreground": "white" };
|
|
550
|
+
const defaults = mode === "light" ? { canvas: snap(25), "canvas-foreground": snap(800), surface: "white", "surface-foreground": snap(800), overlay: "white", "overlay-foreground": snap(800) } : { canvas: snap(950), "canvas-foreground": "white", surface: "black", "surface-foreground": "white", overlay: "black", "overlay-foreground": "white" };
|
|
585
551
|
function resolve(key) {
|
|
586
|
-
const
|
|
587
|
-
if (
|
|
588
|
-
if (
|
|
552
|
+
const raw = overrides?.[key] ?? defaults[key];
|
|
553
|
+
if (raw === "white") return { value: white, ref: { type: "white" } };
|
|
554
|
+
if (raw === "black") return { value: black, ref: { type: "black" } };
|
|
555
|
+
const val = snap(raw);
|
|
589
556
|
return { value: neutral[val], ref: { type: "shade", shade: val } };
|
|
590
557
|
}
|
|
591
558
|
const canvas = resolve("canvas");
|
|
@@ -611,18 +578,20 @@ function generateSurfaceTokens(palette, mode, overrides) {
|
|
|
611
578
|
}
|
|
612
579
|
};
|
|
613
580
|
}
|
|
614
|
-
function generateUtilityTokens(palette, mode, overrides) {
|
|
581
|
+
function generateUtilityTokens(palette, mode, overrides, shades) {
|
|
582
|
+
const activeShades = shadeKeys(shades);
|
|
583
|
+
const snap = (shade) => snapShade(shade, activeShades);
|
|
615
584
|
const neutral = palette.neutral;
|
|
616
585
|
const primary = palette.primary;
|
|
617
586
|
if (!neutral || !primary) {
|
|
618
587
|
throw new Error("Required palettes not found");
|
|
619
588
|
}
|
|
620
|
-
const defaults = mode === "light" ? { border: 200, input: 200, ring: 400, shadow: 950 } : { border: 800, input: 800, ring: 700, shadow: 950 };
|
|
589
|
+
const defaults = mode === "light" ? { border: snap(200), input: snap(200), ring: snap(400), shadow: snap(950) } : { border: snap(800), input: snap(800), ring: snap(700), shadow: snap(950) };
|
|
621
590
|
return {
|
|
622
|
-
border: neutral[overrides?.border
|
|
623
|
-
input: neutral[overrides?.input
|
|
624
|
-
ring: primary[overrides?.ring
|
|
625
|
-
shadow: neutral[overrides?.shadow
|
|
591
|
+
border: neutral[overrides?.border ? snap(overrides.border) : defaults.border],
|
|
592
|
+
input: neutral[overrides?.input ? snap(overrides.input) : defaults.input],
|
|
593
|
+
ring: primary[overrides?.ring ? snap(overrides.ring) : defaults.ring],
|
|
594
|
+
shadow: neutral[overrides?.shadow ? snap(overrides.shadow) : defaults.shadow]
|
|
626
595
|
};
|
|
627
596
|
}
|
|
628
597
|
function checkSemanticContrast(tokens) {
|
|
@@ -808,14 +777,15 @@ var defaultShadows = {
|
|
|
808
777
|
function generateTokens(brandColors, options) {
|
|
809
778
|
const primitives = generatePrimitivePalette(
|
|
810
779
|
brandColors,
|
|
811
|
-
options?.lightnessStrategy ?? "fixed"
|
|
780
|
+
options?.lightnessStrategy ?? "fixed",
|
|
781
|
+
{ seedShade: options?.seedShade, shades: options?.shades }
|
|
812
782
|
);
|
|
813
783
|
const lightSemantic = generateSemanticTokens(primitives, "light", options);
|
|
814
784
|
const darkSemantic = generateSemanticTokens(primitives, "dark", options);
|
|
815
|
-
const lightSurface = generateSurfaceTokens(primitives, "light", options?.surfaceShadeOverrides?.light);
|
|
816
|
-
const darkSurface = generateSurfaceTokens(primitives, "dark", options?.surfaceShadeOverrides?.dark);
|
|
817
|
-
const lightUtility = generateUtilityTokens(primitives, "light", options?.utilityShadeOverrides?.light);
|
|
818
|
-
const darkUtility = generateUtilityTokens(primitives, "dark", options?.utilityShadeOverrides?.dark);
|
|
785
|
+
const lightSurface = generateSurfaceTokens(primitives, "light", options?.surfaceShadeOverrides?.light, options?.shades);
|
|
786
|
+
const darkSurface = generateSurfaceTokens(primitives, "dark", options?.surfaceShadeOverrides?.dark, options?.shades);
|
|
787
|
+
const lightUtility = generateUtilityTokens(primitives, "light", options?.utilityShadeOverrides?.light, options?.shades);
|
|
788
|
+
const darkUtility = generateUtilityTokens(primitives, "dark", options?.utilityShadeOverrides?.dark, options?.shades);
|
|
819
789
|
return {
|
|
820
790
|
primitives,
|
|
821
791
|
semantic: {
|
|
@@ -841,19 +811,32 @@ function generateTokens(brandColors, options) {
|
|
|
841
811
|
function formatColor(color, format) {
|
|
842
812
|
return formatColorAs(color, format);
|
|
843
813
|
}
|
|
844
|
-
function colorScaleToCssVars(name, scale, colorFormat = "hex") {
|
|
814
|
+
function colorScaleToCssVars(name, scale, colorFormat = "hex", indent = " ") {
|
|
845
815
|
return Object.entries(scale).map(
|
|
846
|
-
([shade, color]) =>
|
|
816
|
+
([shade, color]) => `${indent}--color-${name}-${shade}: ${formatColor(color, colorFormat)};`
|
|
847
817
|
);
|
|
848
818
|
}
|
|
849
|
-
function
|
|
819
|
+
function emitPrimitiveVars(tokens, colorFormat, want, indent) {
|
|
820
|
+
const lines = [];
|
|
821
|
+
const rampsOnly = !want.has("primitives");
|
|
822
|
+
for (const [name, scale] of Object.entries(tokens.primitives)) {
|
|
823
|
+
if (typeof scale === "string") {
|
|
824
|
+
if (rampsOnly) continue;
|
|
825
|
+
lines.push(`${indent}--color-${name}: ${formatColor(scale, colorFormat)};`);
|
|
826
|
+
} else {
|
|
827
|
+
lines.push(...colorScaleToCssVars(name, scale, colorFormat, indent));
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
return lines;
|
|
831
|
+
}
|
|
832
|
+
function getExtendedMappings(mode, colorName, overrides, active) {
|
|
850
833
|
const defaults = DEFAULT_SHADE_MAPPINGS[mode].extended;
|
|
851
834
|
const ov = overrides?.[colorName]?.[mode];
|
|
852
|
-
|
|
835
|
+
const snap = (shade) => snapShade(shade, active);
|
|
853
836
|
return {
|
|
854
|
-
DEFAULT: ov
|
|
855
|
-
subdued: ov
|
|
856
|
-
highlight: ov
|
|
837
|
+
DEFAULT: snap(ov?.DEFAULT ?? defaults.DEFAULT),
|
|
838
|
+
subdued: snap(ov?.subdued ?? defaults.subdued),
|
|
839
|
+
highlight: snap(ov?.highlight ?? defaults.highlight)
|
|
857
840
|
};
|
|
858
841
|
}
|
|
859
842
|
var DEFAULT_SHADE_MAPPINGS = {
|
|
@@ -936,44 +919,12 @@ function emitSurfaceVars(surface, colorFormat, indent) {
|
|
|
936
919
|
}
|
|
937
920
|
return lines;
|
|
938
921
|
}
|
|
939
|
-
function
|
|
940
|
-
const lines = [];
|
|
941
|
-
const chartShade = mode === "light" ? 500 : 400;
|
|
942
|
-
lines.push("");
|
|
943
|
-
lines.push(`${indent}/* shadcn/ui compatibility */`);
|
|
944
|
-
lines.push(`${indent}--background: var(--canvas);`);
|
|
945
|
-
lines.push(`${indent}--foreground: var(--canvas-foreground);`);
|
|
946
|
-
lines.push(`${indent}--card: var(--surface);`);
|
|
947
|
-
lines.push(`${indent}--card-foreground: var(--surface-foreground);`);
|
|
948
|
-
lines.push(`${indent}--popover: var(--overlay);`);
|
|
949
|
-
lines.push(`${indent}--popover-foreground: var(--overlay-foreground);`);
|
|
950
|
-
lines.push(`${indent}--secondary: var(--neutral-subdued);`);
|
|
951
|
-
lines.push(`${indent}--secondary-foreground: var(--neutral-subdued-foreground);`);
|
|
952
|
-
lines.push(`${indent}--accent: var(--neutral-subdued);`);
|
|
953
|
-
lines.push(`${indent}--accent-foreground: var(--neutral-subdued-foreground);`);
|
|
954
|
-
lines.push(`${indent}--sidebar: var(--surface);`);
|
|
955
|
-
lines.push(`${indent}--sidebar-foreground: var(--surface-foreground);`);
|
|
956
|
-
lines.push(`${indent}--sidebar-primary: var(--primary);`);
|
|
957
|
-
lines.push(`${indent}--sidebar-primary-foreground: var(--primary-foreground);`);
|
|
958
|
-
lines.push(`${indent}--sidebar-accent: var(--neutral-subdued);`);
|
|
959
|
-
lines.push(`${indent}--sidebar-accent-foreground: var(--neutral-subdued-foreground);`);
|
|
960
|
-
lines.push(`${indent}--sidebar-border: var(--border);`);
|
|
961
|
-
lines.push(`${indent}--sidebar-ring: var(--ring);`);
|
|
962
|
-
const chartColors = ["primary", "success", "destructive", "warning", "neutral"];
|
|
963
|
-
for (let i = 0; i < chartColors.length; i++) {
|
|
964
|
-
const scale = tokens.primitives[chartColors[i]];
|
|
965
|
-
if (scale && typeof scale !== "string") {
|
|
966
|
-
lines.push(`${indent}--chart-${i + 1}: var(--color-${chartColors[i]}-${chartShade});`);
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
return lines;
|
|
970
|
-
}
|
|
971
|
-
function emitSemanticVars(tokens, mode, colorFormat, shadeOverrides, indent) {
|
|
922
|
+
function emitSemanticVars(tokens, mode, colorFormat, shadeOverrides, indent, active) {
|
|
972
923
|
const lines = [];
|
|
973
924
|
const extendedSemanticNames = ["primary", "neutral", "success", "destructive", "warning"];
|
|
974
925
|
for (const name of extendedSemanticNames) {
|
|
975
926
|
const color = tokens.semantic[mode][name];
|
|
976
|
-
const mappings = getExtendedMappings(mode, name, shadeOverrides);
|
|
927
|
+
const mappings = getExtendedMappings(mode, name, shadeOverrides, active);
|
|
977
928
|
lines.push(`${indent}--${name}: var(--color-${name}-${mappings.DEFAULT});`);
|
|
978
929
|
lines.push(`${indent}--${name}-foreground: ${color._refs ? refToVar(color._refs.foreground) : formatColor(color.foreground, colorFormat)};`);
|
|
979
930
|
lines.push(`${indent}--${name}-subdued: var(--color-${name}-${mappings.subdued});`);
|
|
@@ -984,7 +935,7 @@ function emitSemanticVars(tokens, mode, colorFormat, shadeOverrides, indent) {
|
|
|
984
935
|
for (const [name, color] of Object.entries(tokens.semantic[mode])) {
|
|
985
936
|
if (!extendedSemanticNames.includes(name) && name !== "muted") {
|
|
986
937
|
const ext = color;
|
|
987
|
-
const mappings = getExtendedMappings(mode, name, shadeOverrides);
|
|
938
|
+
const mappings = getExtendedMappings(mode, name, shadeOverrides, active);
|
|
988
939
|
lines.push(`${indent}--${name}: var(--color-${name}-${mappings.DEFAULT});`);
|
|
989
940
|
lines.push(`${indent}--${name}-foreground: ${ext._refs ? refToVar(ext._refs.foreground) : formatColor(ext.foreground, colorFormat)};`);
|
|
990
941
|
lines.push(`${indent}--${name}-subdued: var(--color-${name}-${mappings.subdued});`);
|
|
@@ -993,167 +944,193 @@ function emitSemanticVars(tokens, mode, colorFormat, shadeOverrides, indent) {
|
|
|
993
944
|
lines.push(`${indent}--${name}-highlight-foreground: ${ext._refs ? refToVar(ext._refs["highlight-foreground"]) : formatColor(ext["highlight-foreground"], colorFormat)};`);
|
|
994
945
|
}
|
|
995
946
|
}
|
|
996
|
-
|
|
997
|
-
lines.push(`${indent}--muted
|
|
947
|
+
const muted = DEFAULT_SHADE_MAPPINGS[mode].muted;
|
|
948
|
+
lines.push(`${indent}--muted: var(--color-neutral-${snapShade(muted.DEFAULT, active)});`);
|
|
949
|
+
lines.push(`${indent}--muted-foreground: var(--color-neutral-${snapShade(muted.foreground, active)});`);
|
|
998
950
|
return lines;
|
|
999
951
|
}
|
|
1000
|
-
function emitUtilityVars(mode, indent) {
|
|
952
|
+
function emitUtilityVars(mode, indent, active) {
|
|
1001
953
|
const lines = [];
|
|
1002
954
|
for (const [token, ref] of Object.entries(UTILITY_SHADE_MAPPINGS[mode])) {
|
|
1003
|
-
|
|
955
|
+
const [scale, shade] = ref.split(/-(?=\d+$)/);
|
|
956
|
+
const snapped = `${scale}-${snapShade(Number(shade), active)}`;
|
|
957
|
+
lines.push(`${indent}--${token}: ${primitiveToVar(snapped)};`);
|
|
1004
958
|
}
|
|
1005
959
|
return lines;
|
|
1006
960
|
}
|
|
1007
|
-
function exportToCss(tokens, colorFormat = "hex", shadeOverrides,
|
|
961
|
+
function exportToCss(tokens, colorFormat = "hex", shadeOverrides, sections, shades) {
|
|
1008
962
|
const lines = [];
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
963
|
+
const active = resolveShades(shades);
|
|
964
|
+
const want = sectionSet(sections);
|
|
965
|
+
const wantPrimitives = want.has("primitives") || want.has("ramp");
|
|
966
|
+
const wantModes = want.has("semantic") || want.has("surface") || want.has("utility");
|
|
967
|
+
const modeBody = (mode, indent, withComments) => {
|
|
968
|
+
const body = [];
|
|
969
|
+
if (want.has("surface")) {
|
|
970
|
+
if (withComments) body.push(`${indent}/* Surface */`);
|
|
971
|
+
body.push(...emitSurfaceVars(tokens.surface[mode], colorFormat, indent));
|
|
972
|
+
if (withComments) body.push("");
|
|
973
|
+
}
|
|
974
|
+
if (want.has("utility")) {
|
|
975
|
+
if (withComments) body.push(`${indent}/* Utility */`);
|
|
976
|
+
body.push(...emitUtilityVars(mode, indent, active));
|
|
977
|
+
if (withComments) body.push("");
|
|
1016
978
|
}
|
|
979
|
+
if (want.has("semantic")) {
|
|
980
|
+
if (withComments) body.push(`${indent}/* Semantic Colors */`);
|
|
981
|
+
body.push(...emitSemanticVars(tokens, mode, colorFormat, shadeOverrides, indent, active));
|
|
982
|
+
}
|
|
983
|
+
while (body.length > 0 && body[body.length - 1] === "") body.pop();
|
|
984
|
+
return body;
|
|
985
|
+
};
|
|
986
|
+
if (wantPrimitives) {
|
|
987
|
+
lines.push(":root {");
|
|
988
|
+
lines.push(" /* Primitive Colors */");
|
|
989
|
+
lines.push(...emitPrimitiveVars(tokens, colorFormat, want, " "));
|
|
990
|
+
lines.push("}");
|
|
991
|
+
}
|
|
992
|
+
if (wantModes) {
|
|
993
|
+
if (wantPrimitives) lines.push("");
|
|
994
|
+
lines.push("/* Light Mode */");
|
|
995
|
+
lines.push(':root, [data-theme="light"] {');
|
|
996
|
+
lines.push(...modeBody("light", " ", true));
|
|
997
|
+
lines.push("}");
|
|
998
|
+
lines.push("");
|
|
999
|
+
lines.push("/* Dark Mode */");
|
|
1000
|
+
lines.push('[data-theme="dark"] {');
|
|
1001
|
+
lines.push(...modeBody("dark", " ", true));
|
|
1002
|
+
lines.push("}");
|
|
1003
|
+
lines.push("");
|
|
1004
|
+
lines.push("/* System Preference: Dark Mode */");
|
|
1005
|
+
lines.push("@media (prefers-color-scheme: dark) {");
|
|
1006
|
+
lines.push(' :root:not([data-theme="light"]) {');
|
|
1007
|
+
lines.push(...modeBody("dark", " ", false));
|
|
1008
|
+
lines.push(" }");
|
|
1009
|
+
lines.push("}");
|
|
1017
1010
|
}
|
|
1018
|
-
lines.push("}");
|
|
1019
|
-
lines.push("");
|
|
1020
|
-
lines.push("/* Light Mode */");
|
|
1021
|
-
lines.push(':root, [data-theme="light"] {');
|
|
1022
|
-
lines.push(" /* Surface */");
|
|
1023
|
-
lines.push(...emitSurfaceVars(tokens.surface.light, colorFormat, " "));
|
|
1024
|
-
lines.push("");
|
|
1025
|
-
lines.push(" /* Utility */");
|
|
1026
|
-
lines.push(...emitUtilityVars("light", " "));
|
|
1027
|
-
lines.push("");
|
|
1028
|
-
lines.push(" /* Semantic Colors */");
|
|
1029
|
-
lines.push(...emitSemanticVars(tokens, "light", colorFormat, shadeOverrides, " "));
|
|
1030
|
-
if (compat) lines.push(...emitShadcnAliases(tokens, "light", " "));
|
|
1031
|
-
lines.push("}");
|
|
1032
|
-
lines.push("");
|
|
1033
|
-
lines.push("/* Dark Mode */");
|
|
1034
|
-
lines.push('[data-theme="dark"] {');
|
|
1035
|
-
lines.push(" /* Surface */");
|
|
1036
|
-
lines.push(...emitSurfaceVars(tokens.surface.dark, colorFormat, " "));
|
|
1037
|
-
lines.push("");
|
|
1038
|
-
lines.push(" /* Utility */");
|
|
1039
|
-
lines.push(...emitUtilityVars("dark", " "));
|
|
1040
|
-
lines.push("");
|
|
1041
|
-
lines.push(" /* Semantic Colors */");
|
|
1042
|
-
lines.push(...emitSemanticVars(tokens, "dark", colorFormat, shadeOverrides, " "));
|
|
1043
|
-
if (compat) lines.push(...emitShadcnAliases(tokens, "dark", " "));
|
|
1044
|
-
lines.push("}");
|
|
1045
|
-
lines.push("");
|
|
1046
|
-
lines.push("/* System Preference: Dark Mode */");
|
|
1047
|
-
lines.push("@media (prefers-color-scheme: dark) {");
|
|
1048
|
-
lines.push(' :root:not([data-theme="light"]) {');
|
|
1049
|
-
lines.push(...emitSurfaceVars(tokens.surface.dark, colorFormat, " "));
|
|
1050
|
-
lines.push(...emitUtilityVars("dark", " "));
|
|
1051
|
-
lines.push(...emitSemanticVars(tokens, "dark", colorFormat, shadeOverrides, " "));
|
|
1052
|
-
if (compat) lines.push(...emitShadcnAliases(tokens, "dark", " "));
|
|
1053
|
-
lines.push(" }");
|
|
1054
|
-
lines.push("}");
|
|
1055
1011
|
return lines.join("\n");
|
|
1056
1012
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1013
|
+
var TOKEN_SECTIONS = [
|
|
1014
|
+
"primitives",
|
|
1015
|
+
"ramp",
|
|
1016
|
+
"semantic",
|
|
1017
|
+
"surface",
|
|
1018
|
+
"utility"
|
|
1019
|
+
];
|
|
1020
|
+
var ALL_SECTIONS = [...TOKEN_SECTIONS];
|
|
1021
|
+
function sectionSet(sections) {
|
|
1022
|
+
return new Set(sections && sections.length > 0 ? sections : ALL_SECTIONS);
|
|
1023
|
+
}
|
|
1024
|
+
function semanticAliasNames(tokens, sections) {
|
|
1025
|
+
const want = sectionSet(sections);
|
|
1026
|
+
const extended = ["primary", "neutral", "success", "destructive", "warning"];
|
|
1027
|
+
const names = [];
|
|
1028
|
+
const pushExtended = (n) => {
|
|
1029
|
+
names.push(
|
|
1030
|
+
n,
|
|
1031
|
+
`${n}-foreground`,
|
|
1032
|
+
`${n}-subdued`,
|
|
1033
|
+
`${n}-subdued-foreground`,
|
|
1034
|
+
`${n}-highlight`,
|
|
1035
|
+
`${n}-highlight-foreground`
|
|
1036
|
+
);
|
|
1037
|
+
};
|
|
1038
|
+
if (want.has("semantic")) {
|
|
1039
|
+
for (const name of extended) pushExtended(name);
|
|
1040
|
+
for (const name of Object.keys(tokens.semantic.light)) {
|
|
1041
|
+
if (!extended.includes(name) && name !== "muted") pushExtended(name);
|
|
1069
1042
|
}
|
|
1043
|
+
names.push("muted", "muted-foreground");
|
|
1070
1044
|
}
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1045
|
+
if (want.has("surface")) {
|
|
1046
|
+
names.push(
|
|
1047
|
+
"canvas",
|
|
1048
|
+
"canvas-foreground",
|
|
1049
|
+
"surface",
|
|
1050
|
+
"surface-foreground",
|
|
1051
|
+
"overlay",
|
|
1052
|
+
"overlay-foreground"
|
|
1053
|
+
);
|
|
1080
1054
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
lines.push(` --color-${name}: var(--${name});`);
|
|
1084
|
-
lines.push(` --color-${name}-foreground: var(--${name}-foreground);`);
|
|
1085
|
-
lines.push(` --color-${name}-subdued: var(--${name}-subdued);`);
|
|
1086
|
-
lines.push(` --color-${name}-subdued-foreground: var(--${name}-subdued-foreground);`);
|
|
1087
|
-
lines.push(` --color-${name}-highlight: var(--${name}-highlight);`);
|
|
1088
|
-
lines.push(` --color-${name}-highlight-foreground: var(--${name}-highlight-foreground);`);
|
|
1089
|
-
}
|
|
1055
|
+
if (want.has("utility")) {
|
|
1056
|
+
names.push("border", "input", "ring", "shadow");
|
|
1090
1057
|
}
|
|
1058
|
+
return names;
|
|
1059
|
+
}
|
|
1060
|
+
function emitThemeRebinding(aliases, indent) {
|
|
1061
|
+
const lines = [];
|
|
1091
1062
|
lines.push("");
|
|
1092
|
-
lines.push(
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
lines
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
lines
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
lines.push(" --color-overlay: var(--overlay);");
|
|
1104
|
-
lines.push(" --color-overlay-foreground: var(--overlay-foreground);");
|
|
1105
|
-
lines.push("");
|
|
1106
|
-
lines.push(" /* Utility Colors */");
|
|
1107
|
-
lines.push(" --color-border: var(--border);");
|
|
1108
|
-
lines.push(" --color-input: var(--input);");
|
|
1109
|
-
lines.push(" --color-ring: var(--ring);");
|
|
1110
|
-
lines.push(" --color-shadow: var(--shadow);");
|
|
1111
|
-
if (compat) {
|
|
1063
|
+
lines.push(`${indent}/* Re-bind theme aliases so utilities follow this mode when scoped */`);
|
|
1064
|
+
for (const alias of aliases) {
|
|
1065
|
+
lines.push(`${indent}--color-${alias}: var(--${alias});`);
|
|
1066
|
+
}
|
|
1067
|
+
return lines;
|
|
1068
|
+
}
|
|
1069
|
+
function emitTailwindV4Mode(tokens, mode, colorFormat, shadeOverrides, aliases, want, indent, active) {
|
|
1070
|
+
const lines = [];
|
|
1071
|
+
if (want.has("surface")) {
|
|
1072
|
+
lines.push(`${indent}/* Surface */`);
|
|
1073
|
+
lines.push(...emitSurfaceVars(tokens.surface[mode], colorFormat, indent));
|
|
1112
1074
|
lines.push("");
|
|
1113
|
-
lines.push(" /* shadcn/ui compatibility */");
|
|
1114
|
-
lines.push(" --color-background: var(--background);");
|
|
1115
|
-
lines.push(" --color-foreground: var(--foreground);");
|
|
1116
|
-
lines.push(" --color-card: var(--card);");
|
|
1117
|
-
lines.push(" --color-card-foreground: var(--card-foreground);");
|
|
1118
|
-
lines.push(" --color-popover: var(--popover);");
|
|
1119
|
-
lines.push(" --color-popover-foreground: var(--popover-foreground);");
|
|
1120
|
-
lines.push(" --color-secondary: var(--secondary);");
|
|
1121
|
-
lines.push(" --color-secondary-foreground: var(--secondary-foreground);");
|
|
1122
|
-
lines.push(" --color-accent: var(--accent);");
|
|
1123
|
-
lines.push(" --color-accent-foreground: var(--accent-foreground);");
|
|
1124
|
-
lines.push(" --color-sidebar: var(--sidebar);");
|
|
1125
|
-
lines.push(" --color-sidebar-foreground: var(--sidebar-foreground);");
|
|
1126
|
-
lines.push(" --color-sidebar-primary: var(--sidebar-primary);");
|
|
1127
|
-
lines.push(" --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);");
|
|
1128
|
-
lines.push(" --color-sidebar-accent: var(--sidebar-accent);");
|
|
1129
|
-
lines.push(" --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);");
|
|
1130
|
-
lines.push(" --color-sidebar-border: var(--sidebar-border);");
|
|
1131
|
-
lines.push(" --color-sidebar-ring: var(--sidebar-ring);");
|
|
1132
1075
|
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1076
|
+
if (want.has("utility")) {
|
|
1077
|
+
lines.push(`${indent}/* Utility */`);
|
|
1078
|
+
lines.push(...emitUtilityVars(mode, indent, active));
|
|
1079
|
+
lines.push("");
|
|
1080
|
+
}
|
|
1081
|
+
if (want.has("semantic")) {
|
|
1082
|
+
lines.push(`${indent}/* Semantic Colors */`);
|
|
1083
|
+
lines.push(...emitSemanticVars(tokens, mode, colorFormat, shadeOverrides, indent, active));
|
|
1084
|
+
}
|
|
1085
|
+
while (lines.length > 0 && lines[lines.length - 1] === "") lines.pop();
|
|
1086
|
+
lines.push(...emitThemeRebinding(aliases, indent));
|
|
1087
|
+
return lines;
|
|
1088
|
+
}
|
|
1089
|
+
function exportToTailwindV4(tokens, colorFormat = "hex", shadeOverrides, replacePalette = false, sections, shades) {
|
|
1090
|
+
const lines = [];
|
|
1091
|
+
const active = resolveShades(shades);
|
|
1092
|
+
const want = sectionSet(sections);
|
|
1093
|
+
const aliases = semanticAliasNames(tokens, sections);
|
|
1094
|
+
const wantPrimitives = want.has("primitives") || want.has("ramp");
|
|
1095
|
+
const wantModes = aliases.length > 0;
|
|
1096
|
+
lines.push("@theme static {");
|
|
1097
|
+
if (replacePalette) {
|
|
1098
|
+
lines.push(" /* Clear Tailwind's stock palette \u2014 undefined colour classes now fail to compile */");
|
|
1099
|
+
lines.push(" --color-*: initial;");
|
|
1100
|
+
lines.push("");
|
|
1101
|
+
}
|
|
1102
|
+
if (wantPrimitives) {
|
|
1103
|
+
lines.push(" /* Primitives \u2014 real values, mode-invariant. Deliberately override");
|
|
1104
|
+
lines.push(" Tailwind's stock palette: bg-red-500 becomes the project's red. */");
|
|
1105
|
+
lines.push(...emitPrimitiveVars(tokens, colorFormat, want, " "));
|
|
1106
|
+
}
|
|
1107
|
+
if (wantModes) {
|
|
1108
|
+
if (wantPrimitives) lines.push("");
|
|
1109
|
+
lines.push(" /* Semantics \u2014 registers the utility; the value is re-bound per mode below */");
|
|
1110
|
+
for (const alias of aliases) {
|
|
1111
|
+
lines.push(` --color-${alias}: var(--${alias});`);
|
|
1143
1112
|
}
|
|
1144
1113
|
}
|
|
1145
|
-
lines.push(...emitSurfaceVars(tokens.surface.light, colorFormat, " "));
|
|
1146
|
-
lines.push(...emitSemanticVars(tokens, "light", colorFormat, shadeOverrides, " "));
|
|
1147
|
-
lines.push(...emitUtilityVars("light", " "));
|
|
1148
|
-
if (compat) lines.push(...emitShadcnAliases(tokens, "light", " "));
|
|
1149
|
-
lines.push("}");
|
|
1150
|
-
lines.push("");
|
|
1151
|
-
lines.push(".dark {");
|
|
1152
|
-
lines.push(...emitSurfaceVars(tokens.surface.dark, colorFormat, " "));
|
|
1153
|
-
lines.push(...emitSemanticVars(tokens, "dark", colorFormat, shadeOverrides, " "));
|
|
1154
|
-
lines.push(...emitUtilityVars("dark", " "));
|
|
1155
|
-
if (compat) lines.push(...emitShadcnAliases(tokens, "dark", " "));
|
|
1156
1114
|
lines.push("}");
|
|
1115
|
+
if (wantModes) {
|
|
1116
|
+
lines.push("");
|
|
1117
|
+
lines.push("/* Light Mode */");
|
|
1118
|
+
lines.push(':root, [data-theme="light"] {');
|
|
1119
|
+
lines.push(...emitTailwindV4Mode(tokens, "light", colorFormat, shadeOverrides, aliases, want, " ", active));
|
|
1120
|
+
lines.push("}");
|
|
1121
|
+
lines.push("");
|
|
1122
|
+
lines.push("/* Dark Mode */");
|
|
1123
|
+
lines.push('[data-theme="dark"], .dark {');
|
|
1124
|
+
lines.push(...emitTailwindV4Mode(tokens, "dark", colorFormat, shadeOverrides, aliases, want, " ", active));
|
|
1125
|
+
lines.push("}");
|
|
1126
|
+
lines.push("");
|
|
1127
|
+
lines.push("/* System Preference: Dark Mode */");
|
|
1128
|
+
lines.push("@media (prefers-color-scheme: dark) {");
|
|
1129
|
+
lines.push(' :root:not([data-theme="light"]):not(.light) {');
|
|
1130
|
+
lines.push(...emitTailwindV4Mode(tokens, "dark", colorFormat, shadeOverrides, aliases, want, " ", active));
|
|
1131
|
+
lines.push(" }");
|
|
1132
|
+
lines.push("}");
|
|
1133
|
+
}
|
|
1157
1134
|
return lines.join("\n");
|
|
1158
1135
|
}
|
|
1159
1136
|
function exportToTailwindV3(tokens, colorFormat = "hex") {
|
|
@@ -1227,34 +1204,6 @@ function exportToTailwindV3(tokens, colorFormat = "hex") {
|
|
|
1227
1204
|
DEFAULT: "var(--overlay)",
|
|
1228
1205
|
foreground: "var(--overlay-foreground)"
|
|
1229
1206
|
};
|
|
1230
|
-
config.theme.extend.colors["background"] = "var(--background)";
|
|
1231
|
-
config.theme.extend.colors["foreground"] = "var(--foreground)";
|
|
1232
|
-
config.theme.extend.colors["card"] = {
|
|
1233
|
-
DEFAULT: "var(--card)",
|
|
1234
|
-
foreground: "var(--card-foreground)"
|
|
1235
|
-
};
|
|
1236
|
-
config.theme.extend.colors["popover"] = {
|
|
1237
|
-
DEFAULT: "var(--popover)",
|
|
1238
|
-
foreground: "var(--popover-foreground)"
|
|
1239
|
-
};
|
|
1240
|
-
config.theme.extend.colors["secondary"] = {
|
|
1241
|
-
DEFAULT: "var(--secondary)",
|
|
1242
|
-
foreground: "var(--secondary-foreground)"
|
|
1243
|
-
};
|
|
1244
|
-
config.theme.extend.colors["accent"] = {
|
|
1245
|
-
DEFAULT: "var(--accent)",
|
|
1246
|
-
foreground: "var(--accent-foreground)"
|
|
1247
|
-
};
|
|
1248
|
-
config.theme.extend.colors["sidebar"] = {
|
|
1249
|
-
DEFAULT: "var(--sidebar)",
|
|
1250
|
-
foreground: "var(--sidebar-foreground)",
|
|
1251
|
-
primary: "var(--sidebar-primary)",
|
|
1252
|
-
"primary-foreground": "var(--sidebar-primary-foreground)",
|
|
1253
|
-
accent: "var(--sidebar-accent)",
|
|
1254
|
-
"accent-foreground": "var(--sidebar-accent-foreground)",
|
|
1255
|
-
border: "var(--sidebar-border)",
|
|
1256
|
-
ring: "var(--sidebar-ring)"
|
|
1257
|
-
};
|
|
1258
1207
|
config.theme.extend.colors["border"] = "var(--border)";
|
|
1259
1208
|
config.theme.extend.colors["input"] = "var(--input)";
|
|
1260
1209
|
config.theme.extend.colors["ring"] = "var(--ring)";
|
|
@@ -1345,128 +1294,59 @@ function exportToDtcg(tokens) {
|
|
|
1345
1294
|
}
|
|
1346
1295
|
return JSON.stringify(dtcg, null, 2);
|
|
1347
1296
|
}
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
lines.push(" --color-card: var(--card);");
|
|
1360
|
-
lines.push(" --color-card-foreground: var(--card-foreground);");
|
|
1361
|
-
lines.push(" --color-popover: var(--popover);");
|
|
1362
|
-
lines.push(" --color-popover-foreground: var(--popover-foreground);");
|
|
1363
|
-
lines.push("");
|
|
1364
|
-
lines.push(" /* Semantic */");
|
|
1365
|
-
lines.push(" --color-primary: var(--primary);");
|
|
1366
|
-
lines.push(" --color-primary-foreground: var(--primary-foreground);");
|
|
1367
|
-
lines.push(" --color-secondary: var(--secondary);");
|
|
1368
|
-
lines.push(" --color-secondary-foreground: var(--secondary-foreground);");
|
|
1369
|
-
lines.push(" --color-muted: var(--muted);");
|
|
1370
|
-
lines.push(" --color-muted-foreground: var(--muted-foreground);");
|
|
1371
|
-
lines.push(" --color-accent: var(--accent);");
|
|
1372
|
-
lines.push(" --color-accent-foreground: var(--accent-foreground);");
|
|
1373
|
-
lines.push(" --color-destructive: var(--destructive);");
|
|
1374
|
-
lines.push(" --color-destructive-foreground: var(--destructive-foreground);");
|
|
1375
|
-
lines.push("");
|
|
1376
|
-
lines.push(" /* Utility */");
|
|
1377
|
-
lines.push(" --color-border: var(--border);");
|
|
1378
|
-
lines.push(" --color-input: var(--input);");
|
|
1379
|
-
lines.push(" --color-ring: var(--ring);");
|
|
1380
|
-
lines.push("");
|
|
1381
|
-
lines.push(" /* Sidebar */");
|
|
1382
|
-
lines.push(" --color-sidebar: var(--sidebar);");
|
|
1383
|
-
lines.push(" --color-sidebar-foreground: var(--sidebar-foreground);");
|
|
1384
|
-
lines.push(" --color-sidebar-primary: var(--sidebar-primary);");
|
|
1385
|
-
lines.push(" --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);");
|
|
1386
|
-
lines.push(" --color-sidebar-accent: var(--sidebar-accent);");
|
|
1387
|
-
lines.push(" --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);");
|
|
1388
|
-
lines.push(" --color-sidebar-border: var(--sidebar-border);");
|
|
1389
|
-
lines.push(" --color-sidebar-ring: var(--sidebar-ring);");
|
|
1390
|
-
lines.push("");
|
|
1391
|
-
lines.push(" --radius: 0.5rem;");
|
|
1392
|
-
lines.push("}");
|
|
1393
|
-
lines.push("");
|
|
1394
|
-
const resolveColor = (color) => formatColor(color, colorFormat);
|
|
1395
|
-
function emitLovableMode(mode, selector) {
|
|
1396
|
-
const sem = tokens.semantic[mode];
|
|
1397
|
-
const surf = tokens.surface[mode];
|
|
1398
|
-
const util = tokens.utility[mode];
|
|
1399
|
-
const neutral = sem.neutral;
|
|
1400
|
-
lines.push(`${selector} {`);
|
|
1401
|
-
lines.push(` --background: ${resolveColor(surf.canvas)};`);
|
|
1402
|
-
lines.push(` --foreground: ${resolveColor(surf["canvas-foreground"])};`);
|
|
1403
|
-
lines.push(` --card: ${resolveColor(surf.surface)};`);
|
|
1404
|
-
lines.push(` --card-foreground: ${resolveColor(surf["surface-foreground"])};`);
|
|
1405
|
-
lines.push(` --popover: ${resolveColor(surf.overlay)};`);
|
|
1406
|
-
lines.push(` --popover-foreground: ${resolveColor(surf["overlay-foreground"])};`);
|
|
1407
|
-
lines.push("");
|
|
1408
|
-
lines.push(` --primary: ${resolveColor(sem.primary.DEFAULT)};`);
|
|
1409
|
-
lines.push(` --primary-foreground: ${resolveColor(sem.primary.foreground)};`);
|
|
1410
|
-
lines.push(` --secondary: ${resolveColor(neutral.subdued)};`);
|
|
1411
|
-
lines.push(` --secondary-foreground: ${resolveColor(neutral["subdued-foreground"])};`);
|
|
1412
|
-
lines.push(` --muted: ${resolveColor(sem.muted.DEFAULT)};`);
|
|
1413
|
-
lines.push(` --muted-foreground: ${resolveColor(sem.muted.foreground)};`);
|
|
1414
|
-
lines.push(` --accent: ${resolveColor(neutral.subdued)};`);
|
|
1415
|
-
lines.push(` --accent-foreground: ${resolveColor(neutral["subdued-foreground"])};`);
|
|
1416
|
-
lines.push(` --destructive: ${resolveColor(sem.destructive.DEFAULT)};`);
|
|
1417
|
-
lines.push(` --destructive-foreground: ${resolveColor(sem.destructive.foreground)};`);
|
|
1418
|
-
lines.push("");
|
|
1419
|
-
lines.push(` --border: ${resolveColor(util.border)};`);
|
|
1420
|
-
lines.push(` --input: ${resolveColor(util.input)};`);
|
|
1421
|
-
lines.push(` --ring: ${resolveColor(util.ring)};`);
|
|
1422
|
-
lines.push("");
|
|
1423
|
-
lines.push(` --sidebar: ${resolveColor(surf.surface)};`);
|
|
1424
|
-
lines.push(` --sidebar-foreground: ${resolveColor(surf["surface-foreground"])};`);
|
|
1425
|
-
lines.push(` --sidebar-primary: ${resolveColor(sem.primary.DEFAULT)};`);
|
|
1426
|
-
lines.push(` --sidebar-primary-foreground: ${resolveColor(sem.primary.foreground)};`);
|
|
1427
|
-
lines.push(` --sidebar-accent: ${resolveColor(neutral.subdued)};`);
|
|
1428
|
-
lines.push(` --sidebar-accent-foreground: ${resolveColor(neutral["subdued-foreground"])};`);
|
|
1429
|
-
lines.push(` --sidebar-border: ${resolveColor(util.border)};`);
|
|
1430
|
-
lines.push(` --sidebar-ring: ${resolveColor(util.ring)};`);
|
|
1431
|
-
const chartShade = mode === "light" ? 500 : 400;
|
|
1432
|
-
const chartColors = ["primary", "success", "destructive", "warning", "neutral"];
|
|
1433
|
-
for (let i = 0; i < chartColors.length; i++) {
|
|
1434
|
-
const scale = tokens.primitives[chartColors[i]];
|
|
1435
|
-
if (scale && typeof scale !== "string") {
|
|
1436
|
-
lines.push(` --chart-${i + 1}: ${resolveColor(scale[chartShade])};`);
|
|
1437
|
-
}
|
|
1297
|
+
var SECTIONED_FORMATS = ["css", "tailwind-v4"];
|
|
1298
|
+
function selectTokenSections(tokens, sections) {
|
|
1299
|
+
if (!sections || sections.length === 0) return tokens;
|
|
1300
|
+
const want = sectionSet(sections);
|
|
1301
|
+
const out = {};
|
|
1302
|
+
if (want.has("primitives") || want.has("ramp")) {
|
|
1303
|
+
const rampsOnly = !want.has("primitives");
|
|
1304
|
+
const primitives = {};
|
|
1305
|
+
for (const [name, scale] of Object.entries(tokens.primitives)) {
|
|
1306
|
+
if (typeof scale === "string" && rampsOnly) continue;
|
|
1307
|
+
primitives[name] = scale;
|
|
1438
1308
|
}
|
|
1439
|
-
|
|
1309
|
+
out.primitives = primitives;
|
|
1440
1310
|
}
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
return
|
|
1311
|
+
if (want.has("semantic")) out.semantic = tokens.semantic;
|
|
1312
|
+
if (want.has("surface")) out.surface = tokens.surface;
|
|
1313
|
+
if (want.has("utility")) out.utility = tokens.utility;
|
|
1314
|
+
return out;
|
|
1445
1315
|
}
|
|
1446
1316
|
function exportTokens(tokens, format, options) {
|
|
1447
1317
|
const colorFormat = options?.colorFormat ?? "hex";
|
|
1448
1318
|
const shadeOverrides = options?.shadeOverrides;
|
|
1449
|
-
const
|
|
1319
|
+
const replacePalette = options?.replacePalette === true;
|
|
1320
|
+
const sections = options?.sections;
|
|
1321
|
+
const shades = options?.shades;
|
|
1322
|
+
if (sections && sections.length > 0 && !SECTIONED_FORMATS.includes(format)) {
|
|
1323
|
+
throw new Error(
|
|
1324
|
+
`Format "${format}" cannot be filtered by section; supported: ${SECTIONED_FORMATS.join(", ")}`
|
|
1325
|
+
);
|
|
1326
|
+
}
|
|
1450
1327
|
switch (format) {
|
|
1451
1328
|
case "css":
|
|
1452
|
-
return exportToCss(tokens, colorFormat, shadeOverrides,
|
|
1329
|
+
return exportToCss(tokens, colorFormat, shadeOverrides, sections, shades);
|
|
1453
1330
|
case "tailwind-v3":
|
|
1454
1331
|
return exportToTailwindV3(tokens, colorFormat);
|
|
1455
1332
|
case "tailwind-v4":
|
|
1456
|
-
return exportToTailwindV4(tokens, colorFormat, shadeOverrides,
|
|
1333
|
+
return exportToTailwindV4(tokens, colorFormat, shadeOverrides, replacePalette, sections, shades);
|
|
1457
1334
|
case "dtcg":
|
|
1458
1335
|
return exportToDtcg(tokens);
|
|
1459
|
-
case "lovable":
|
|
1460
|
-
return exportToLovable(tokens, colorFormat);
|
|
1461
1336
|
default:
|
|
1462
1337
|
throw new Error(`Unknown export format: ${format}`);
|
|
1463
1338
|
}
|
|
1464
1339
|
}
|
|
1465
1340
|
|
|
1466
1341
|
export {
|
|
1342
|
+
VALID_SHADES,
|
|
1343
|
+
SHADE_PRESETS,
|
|
1344
|
+
resolveShades,
|
|
1345
|
+
snapShade,
|
|
1467
1346
|
parseToOklch,
|
|
1468
1347
|
oklchToHex,
|
|
1469
1348
|
generateColorScale,
|
|
1349
|
+
generateColorScaleAPCA,
|
|
1470
1350
|
adjustLightness,
|
|
1471
1351
|
adjustChroma,
|
|
1472
1352
|
getRelativeLuminance,
|
|
@@ -1477,7 +1357,6 @@ export {
|
|
|
1477
1357
|
findContrastingColorAPCA,
|
|
1478
1358
|
simulateCVD,
|
|
1479
1359
|
classifyAPCALevel,
|
|
1480
|
-
generateColorScaleAPCA,
|
|
1481
1360
|
formatColorShort,
|
|
1482
1361
|
getOklchString,
|
|
1483
1362
|
formatColorAs,
|
|
@@ -1492,9 +1371,11 @@ export {
|
|
|
1492
1371
|
computeAccessibilityScore,
|
|
1493
1372
|
generateTokens,
|
|
1494
1373
|
exportToCss,
|
|
1374
|
+
TOKEN_SECTIONS,
|
|
1495
1375
|
exportToTailwindV4,
|
|
1496
1376
|
exportToTailwindV3,
|
|
1497
1377
|
exportToDtcg,
|
|
1498
|
-
|
|
1378
|
+
SECTIONED_FORMATS,
|
|
1379
|
+
selectTokenSections,
|
|
1499
1380
|
exportTokens
|
|
1500
1381
|
};
|