@primer/primitives 11.4.1-rc.eb8ee149 → 11.5.0-rc.14eaeb12
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/DESIGN_TOKENS_GUIDE.md +185 -0
- package/DESIGN_TOKENS_SPEC.md +136 -8
- package/dist/build/formats/jsonFigma.js +8 -1
- package/dist/build/formats/markdownLlmGuidelines.js +349 -0
- package/dist/build/schemas/borderToken.d.ts +61 -5
- package/dist/build/schemas/borderToken.js +2 -1
- package/dist/build/schemas/colorToken.d.ts +639 -30
- package/dist/build/schemas/colorToken.js +3 -2
- package/dist/build/schemas/colorW3cValue.d.ts +28 -0
- package/dist/build/schemas/colorW3cValue.js +42 -0
- package/dist/build/schemas/cubicBezierToken.d.ts +1 -1
- package/dist/build/schemas/dimensionToken.d.ts +9 -2
- package/dist/build/schemas/dimensionValue.d.ts +12 -1
- package/dist/build/schemas/dimensionValue.js +10 -13
- package/dist/build/schemas/durationToken.d.ts +8 -2
- package/dist/build/schemas/durationValue.d.ts +11 -1
- package/dist/build/schemas/durationValue.js +13 -3
- package/dist/build/schemas/fontFamilyToken.d.ts +1 -1
- package/dist/build/schemas/fontWeightToken.d.ts +1 -1
- package/dist/build/schemas/gradientToken.d.ts +23 -2
- package/dist/build/schemas/gradientToken.js +2 -1
- package/dist/build/schemas/numberToken.d.ts +1 -1
- package/dist/build/schemas/shadowToken.d.ts +1751 -127
- package/dist/build/schemas/shadowToken.js +8 -2
- package/dist/build/schemas/stringToken.d.ts +1 -1
- package/dist/build/schemas/stringToken.js +1 -1
- package/dist/build/schemas/tokenType.d.ts +1 -1
- package/dist/build/schemas/transitionToken.d.ts +15 -3
- package/dist/build/schemas/typographyToken.d.ts +19 -5
- package/dist/build/schemas/typographyToken.js +1 -1
- package/dist/build/schemas/validTokenType.d.ts +1 -1
- package/dist/build/schemas/validTokenType.js +1 -1
- package/dist/build/schemas/viewportRangeToken.d.ts +1 -1
- package/dist/build/transformers/borderToCss.js +19 -1
- package/dist/build/transformers/colorAlphaToCss.js +6 -3
- package/dist/build/transformers/colorToHex.js +5 -2
- package/dist/build/transformers/colorToRgbAlpha.js +5 -2
- package/dist/build/transformers/colorToRgbaFloat.js +5 -0
- package/dist/build/transformers/dimensionToPixelUnitless.d.ts +3 -2
- package/dist/build/transformers/dimensionToPixelUnitless.js +22 -26
- package/dist/build/transformers/dimensionToRem.d.ts +2 -1
- package/dist/build/transformers/dimensionToRem.js +21 -22
- package/dist/build/transformers/dimensionToRemPxArray.d.ts +2 -1
- package/dist/build/transformers/dimensionToRemPxArray.js +21 -22
- package/dist/build/transformers/durationToCss.d.ts +2 -1
- package/dist/build/transformers/durationToCss.js +19 -12
- package/dist/build/transformers/gradientToCss.js +2 -1
- package/dist/build/transformers/shadowToCss.js +15 -1
- package/dist/build/transformers/utilities/normalizeColorValue.d.ts +23 -0
- package/dist/build/transformers/utilities/normalizeColorValue.js +74 -0
- package/dist/build/transformers/utilities/parseDimension.d.ts +12 -0
- package/dist/build/transformers/utilities/parseDimension.js +31 -0
- package/dist/build/types/borderTokenValue.d.ts +5 -2
- package/dist/build/types/dimensionTokenValue.d.ts +9 -0
- package/dist/build/types/shadowTokenValue.d.ts +8 -5
- package/dist/css/base/motion/motion.css +1 -1
- package/dist/css/functional/size/radius.css +1 -1
- package/dist/css/functional/size/size-coarse.css +1 -0
- package/dist/css/functional/size/size-fine.css +1 -0
- package/dist/css/functional/size/size.css +5 -0
- package/dist/css/functional/themes/dark-colorblind-high-contrast.css +42 -30
- package/dist/css/functional/themes/dark-colorblind.css +42 -30
- package/dist/css/functional/themes/dark-dimmed-high-contrast.css +42 -30
- package/dist/css/functional/themes/dark-dimmed.css +42 -30
- package/dist/css/functional/themes/dark-high-contrast.css +42 -30
- package/dist/css/functional/themes/dark-tritanopia-high-contrast.css +42 -30
- package/dist/css/functional/themes/dark-tritanopia.css +42 -30
- package/dist/css/functional/themes/dark.css +42 -30
- package/dist/css/functional/themes/light-colorblind-high-contrast.css +42 -30
- package/dist/css/functional/themes/light-colorblind.css +42 -30
- package/dist/css/functional/themes/light-high-contrast.css +42 -30
- package/dist/css/functional/themes/light-tritanopia-high-contrast.css +42 -30
- package/dist/css/functional/themes/light-tritanopia.css +42 -30
- package/dist/css/functional/themes/light.css +42 -30
- package/dist/docs/base/motion/motion.json +96 -24
- package/dist/docs/base/size/size.json +76 -19
- package/dist/docs/base/typography/typography.json +24 -6
- package/dist/docs/functional/size/border.json +26 -11
- package/dist/docs/functional/size/breakpoints.json +24 -6
- package/dist/docs/functional/size/radius.json +18 -6
- package/dist/docs/functional/size/size-coarse.json +55 -2
- package/dist/docs/functional/size/size-fine.json +55 -2
- package/dist/docs/functional/size/size.json +195 -15
- package/dist/docs/functional/themes/dark-colorblind-high-contrast.json +3921 -714
- package/dist/docs/functional/themes/dark-colorblind.json +3911 -712
- package/dist/docs/functional/themes/dark-dimmed-high-contrast.json +3774 -547
- package/dist/docs/functional/themes/dark-dimmed.json +3801 -554
- package/dist/docs/functional/themes/dark-high-contrast.json +3926 -715
- package/dist/docs/functional/themes/dark-tritanopia-high-contrast.json +3936 -717
- package/dist/docs/functional/themes/dark-tritanopia.json +3769 -546
- package/dist/docs/functional/themes/dark.json +3920 -713
- package/dist/docs/functional/themes/light-colorblind-high-contrast.json +3780 -553
- package/dist/docs/functional/themes/light-colorblind.json +3767 -548
- package/dist/docs/functional/themes/light-high-contrast.json +3785 -554
- package/dist/docs/functional/themes/light-tritanopia-high-contrast.json +3785 -554
- package/dist/docs/functional/themes/light-tritanopia.json +3777 -550
- package/dist/docs/functional/themes/light.json +3782 -551
- package/dist/docs/functional/typography/typography.json +8 -2
- package/dist/fallbacks/base/motion/motion.json +48 -12
- package/dist/fallbacks/functional/size/size-coarse.json +2 -1
- package/dist/fallbacks/functional/size/size-fine.json +2 -1
- package/dist/fallbacks/functional/size/size.json +5 -0
- package/dist/figma/dimension/dimension.json +56 -1
- package/dist/figma/themes/dark-colorblind.json +49 -1
- package/dist/figma/themes/dark-dimmed.json +51 -3
- package/dist/figma/themes/dark-high-contrast.json +49 -1
- package/dist/figma/themes/dark-tritanopia.json +49 -1
- package/dist/figma/themes/dark.json +49 -1
- package/dist/figma/themes/light-colorblind.json +53 -5
- package/dist/figma/themes/light-high-contrast.json +53 -5
- package/dist/figma/themes/light-tritanopia.json +53 -5
- package/dist/figma/themes/light.json +53 -5
- package/dist/internalCss/dark-colorblind-high-contrast.css +42 -30
- package/dist/internalCss/dark-colorblind.css +42 -30
- package/dist/internalCss/dark-dimmed-high-contrast.css +42 -30
- package/dist/internalCss/dark-dimmed.css +42 -30
- package/dist/internalCss/dark-high-contrast.css +42 -30
- package/dist/internalCss/dark-tritanopia-high-contrast.css +42 -30
- package/dist/internalCss/dark-tritanopia.css +42 -30
- package/dist/internalCss/dark.css +42 -30
- package/dist/internalCss/light-colorblind-high-contrast.css +42 -30
- package/dist/internalCss/light-colorblind.css +42 -30
- package/dist/internalCss/light-high-contrast.css +42 -30
- package/dist/internalCss/light-tritanopia-high-contrast.css +42 -30
- package/dist/internalCss/light-tritanopia.css +42 -30
- package/dist/internalCss/light.css +42 -30
- package/dist/styleLint/base/motion/motion.json +96 -24
- package/dist/styleLint/base/size/size.json +76 -19
- package/dist/styleLint/base/typography/typography.json +30 -12
- package/dist/styleLint/functional/size/border.json +27 -12
- package/dist/styleLint/functional/size/breakpoints.json +24 -6
- package/dist/styleLint/functional/size/radius.json +19 -7
- package/dist/styleLint/functional/size/size-coarse.json +60 -7
- package/dist/styleLint/functional/size/size-fine.json +60 -7
- package/dist/styleLint/functional/size/size.json +246 -66
- package/dist/styleLint/functional/themes/dark-colorblind-high-contrast.json +4060 -733
- package/dist/styleLint/functional/themes/dark-colorblind.json +4050 -731
- package/dist/styleLint/functional/themes/dark-dimmed-high-contrast.json +3914 -567
- package/dist/styleLint/functional/themes/dark-dimmed.json +3941 -574
- package/dist/styleLint/functional/themes/dark-high-contrast.json +4065 -734
- package/dist/styleLint/functional/themes/dark-tritanopia-high-contrast.json +4075 -736
- package/dist/styleLint/functional/themes/dark-tritanopia.json +4079 -736
- package/dist/styleLint/functional/themes/dark.json +4059 -732
- package/dist/styleLint/functional/themes/light-colorblind-high-contrast.json +4091 -744
- package/dist/styleLint/functional/themes/light-colorblind.json +4078 -739
- package/dist/styleLint/functional/themes/light-high-contrast.json +4096 -745
- package/dist/styleLint/functional/themes/light-tritanopia-high-contrast.json +4096 -745
- package/dist/styleLint/functional/themes/light-tritanopia.json +4088 -741
- package/dist/styleLint/functional/themes/light.json +4093 -742
- package/dist/styleLint/functional/typography/typography.json +28 -22
- package/package.json +5 -4
- package/src/tokens/base/color/dark/dark.dimmed.json5 +405 -81
- package/src/tokens/base/color/dark/dark.high-contrast.json5 +405 -81
- package/src/tokens/base/color/dark/dark.json5 +475 -95
- package/src/tokens/base/color/dark/display-dark.json5 +960 -192
- package/src/tokens/base/color/light/display-light.json5 +960 -192
- package/src/tokens/base/color/light/light.high-contrast.json5 +405 -81
- package/src/tokens/base/color/light/light.json5 +475 -95
- package/src/tokens/base/motion/timing.json5 +12 -12
- package/src/tokens/base/size/size.json5 +194 -194
- package/src/tokens/base/typography/typography.json5 +6 -6
- package/src/tokens/component/avatar.json5 +72 -44
- package/src/tokens/component/button.json5 +1846 -1191
- package/src/tokens/component/reactionButton.json5 +20 -4
- package/src/tokens/functional/border/border.json5 +33 -2
- package/src/tokens/functional/color/bgColor.json5 +18 -2
- package/src/tokens/functional/color/borderColor.json5 +8 -1
- package/src/tokens/functional/color/control.json5 +160 -32
- package/src/tokens/functional/color/display.json5 +7 -0
- package/src/tokens/functional/color/fgColor.json5 +13 -1
- package/src/tokens/functional/color/syntax.json5 +24 -2
- package/src/tokens/functional/shadow/shadow.json5 +1254 -163
- package/src/tokens/functional/size/border.json5 +8 -8
- package/src/tokens/functional/size/breakpoints.json5 +6 -6
- package/src/tokens/functional/size/radius.json5 +5 -5
- package/src/tokens/functional/size/size-coarse.json5 +15 -0
- package/src/tokens/functional/size/size-fine.json5 +15 -0
- package/src/tokens/functional/size/size.json5 +65 -15
- package/src/tokens/functional/typography/typography.json5 +8 -4
- package/dist/build/parsers/index.d.ts +0 -1
- package/dist/build/parsers/index.js +0 -1
- package/dist/build/parsers/w3cJsonParser.d.ts +0 -6
- package/dist/build/parsers/w3cJsonParser.js +0 -25
- package/dist/removed/testing.json5 +0 -4
- package/guidelines/color.llm.md +0 -16
- package/guidelines/guidelines.llm.md +0 -34
- package/guidelines/motion.llm.md +0 -41
- package/guidelines/spacing.llm.md +0 -20
- package/guidelines/typography.llm.md +0 -14
- package/src/tokens/removed/testing.json5 +0 -4
|
@@ -296,6 +296,239 @@ function outputPatternCompressedCategory(category, tokens, config, lines) {
|
|
|
296
296
|
lines.push('');
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Outputs pattern-compressed display color tokens
|
|
301
|
+
* Extracts unique colors and properties to show as display-[color]-[property] pattern
|
|
302
|
+
*/
|
|
303
|
+
function outputDisplayColorPattern(tokens, lines) {
|
|
304
|
+
const tokenNames = tokens.map(t => t.name);
|
|
305
|
+
// Extract unique colors and properties
|
|
306
|
+
const colors = new Set();
|
|
307
|
+
const properties = new Set();
|
|
308
|
+
const hasScale = new Set();
|
|
309
|
+
for (const name of tokenNames) {
|
|
310
|
+
// Parse: display-{color}-{property} or display-{color}-scale-{n}
|
|
311
|
+
const parts = name.replace('display-', '').split('-');
|
|
312
|
+
if (parts.length < 2)
|
|
313
|
+
continue;
|
|
314
|
+
const color = parts[0];
|
|
315
|
+
colors.add(color);
|
|
316
|
+
// Check for scale tokens (display-blue-scale-0)
|
|
317
|
+
if (parts[1] === 'scale' && parts.length >= 3) {
|
|
318
|
+
hasScale.add(parts[2]);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
// Property tokens (display-blue-bgColor-emphasis, display-blue-fgColor)
|
|
322
|
+
const property = parts.slice(1).join('-');
|
|
323
|
+
properties.add(property);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
// Sort colors alphabetically
|
|
327
|
+
const sortedColors = [...colors].sort();
|
|
328
|
+
const sortedProperties = [...properties].sort((a, b) => {
|
|
329
|
+
// Sort by type first (bgColor, borderColor, fgColor)
|
|
330
|
+
const typeOrder = ['bgColor-emphasis', 'bgColor-muted', 'borderColor-emphasis', 'borderColor-muted', 'fgColor'];
|
|
331
|
+
const aIdx = typeOrder.indexOf(a);
|
|
332
|
+
const bIdx = typeOrder.indexOf(b);
|
|
333
|
+
if (aIdx !== -1 && bIdx !== -1)
|
|
334
|
+
return aIdx - bIdx;
|
|
335
|
+
if (aIdx !== -1)
|
|
336
|
+
return -1;
|
|
337
|
+
if (bIdx !== -1)
|
|
338
|
+
return 1;
|
|
339
|
+
return a.localeCompare(b);
|
|
340
|
+
});
|
|
341
|
+
// Output pattern with variables
|
|
342
|
+
lines.push('**Pattern:** `display-[color]-[property]`');
|
|
343
|
+
lines.push('');
|
|
344
|
+
lines.push('**Variables:**');
|
|
345
|
+
lines.push(`- **color:** ${sortedColors.join(' | ')}`);
|
|
346
|
+
lines.push(`- **property:** ${sortedProperties.join(' | ')}`);
|
|
347
|
+
lines.push('');
|
|
348
|
+
// Output scale pattern if present
|
|
349
|
+
if (hasScale.size > 0) {
|
|
350
|
+
const sortedScales = [...hasScale].sort((a, b) => parseInt(a) - parseInt(b));
|
|
351
|
+
lines.push('**Scale pattern:** `display-[color]-scale-[n]`');
|
|
352
|
+
lines.push(`- **n:** ${sortedScales.join(' | ')}`);
|
|
353
|
+
lines.push('');
|
|
354
|
+
lines.push('*Scale 0-2: lighter (backgrounds), 3-5: mid-tones, 6-9: darker (foregrounds/borders)*');
|
|
355
|
+
lines.push('');
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Outputs pattern-compressed data visualization tokens
|
|
360
|
+
* Extracts unique colors and variants to show as data-[color]-color-[variant] pattern
|
|
361
|
+
*/
|
|
362
|
+
function outputDataVisColorPattern(tokens, lines) {
|
|
363
|
+
const tokenNames = tokens.map(t => t.name);
|
|
364
|
+
// Extract unique colors and variants
|
|
365
|
+
const colors = new Set();
|
|
366
|
+
const variants = new Set();
|
|
367
|
+
for (const name of tokenNames) {
|
|
368
|
+
// Parse: data-{color}-color-{variant}
|
|
369
|
+
const parts = name.replace('data-', '').split('-');
|
|
370
|
+
if (parts.length < 3)
|
|
371
|
+
continue;
|
|
372
|
+
const color = parts[0];
|
|
373
|
+
colors.add(color);
|
|
374
|
+
// Variant is the last part (emphasis, muted)
|
|
375
|
+
// Format: color-color-variant -> parts[1] is 'color', parts[2] is variant
|
|
376
|
+
if (parts[1] === 'color' && parts.length >= 3) {
|
|
377
|
+
variants.add(parts[2]);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
// Sort colors alphabetically
|
|
381
|
+
const sortedColors = [...colors].sort();
|
|
382
|
+
const sortedVariants = [...variants].sort((a, b) => {
|
|
383
|
+
// emphasis first, then muted
|
|
384
|
+
const order = ['emphasis', 'muted'];
|
|
385
|
+
return order.indexOf(a) - order.indexOf(b);
|
|
386
|
+
});
|
|
387
|
+
// Output pattern with variables
|
|
388
|
+
lines.push('**Pattern:** `data-[color]-color-[variant]`');
|
|
389
|
+
lines.push('');
|
|
390
|
+
lines.push('**Variables:**');
|
|
391
|
+
lines.push(`- **color:** ${sortedColors.join(' | ')}`);
|
|
392
|
+
lines.push(`- **variant:** ${sortedVariants.join(' | ')}`);
|
|
393
|
+
lines.push('');
|
|
394
|
+
// Add usage guidance
|
|
395
|
+
lines.push('**Variant usage:**');
|
|
396
|
+
lines.push('- **emphasis:** Lines, bars, borders, data points');
|
|
397
|
+
lines.push('- **muted:** Area fills, backgrounds, subtle regions');
|
|
398
|
+
lines.push('');
|
|
399
|
+
lines.push('*Pair emphasis with muted variants of the same color for cohesive chart styling.*');
|
|
400
|
+
lines.push('');
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Outputs pattern-compressed ANSI color tokens
|
|
404
|
+
* Extracts unique colors and variants (default/bright) to show as color-ansi-[color]-[variant] pattern
|
|
405
|
+
*/
|
|
406
|
+
function outputAnsiColorPattern(tokens, lines) {
|
|
407
|
+
const tokenNames = tokens.map(t => t.name);
|
|
408
|
+
// Extract unique colors and variants
|
|
409
|
+
const colors = new Set();
|
|
410
|
+
const hasVariants = new Set();
|
|
411
|
+
for (const name of tokenNames) {
|
|
412
|
+
// Parse: color-ansi-{color} or color-ansi-{color}-bright
|
|
413
|
+
const parts = name.replace('color-ansi-', '').split('-');
|
|
414
|
+
if (parts.length < 1)
|
|
415
|
+
continue;
|
|
416
|
+
const color = parts[0];
|
|
417
|
+
colors.add(color);
|
|
418
|
+
// Check for bright variant
|
|
419
|
+
if (parts.length > 1 && parts[1] === 'bright') {
|
|
420
|
+
hasVariants.add('bright');
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
hasVariants.add('default');
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
// Sort colors in ANSI order
|
|
427
|
+
const ansiOrder = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'gray'];
|
|
428
|
+
const sortedColors = [...colors].sort((a, b) => {
|
|
429
|
+
const aIdx = ansiOrder.indexOf(a);
|
|
430
|
+
const bIdx = ansiOrder.indexOf(b);
|
|
431
|
+
if (aIdx !== -1 && bIdx !== -1)
|
|
432
|
+
return aIdx - bIdx;
|
|
433
|
+
if (aIdx !== -1)
|
|
434
|
+
return -1;
|
|
435
|
+
if (bIdx !== -1)
|
|
436
|
+
return 1;
|
|
437
|
+
return a.localeCompare(b);
|
|
438
|
+
});
|
|
439
|
+
// Output pattern with variables
|
|
440
|
+
lines.push('**Pattern:** `color-ansi-[color]` or `color-ansi-[color]-bright`');
|
|
441
|
+
lines.push('');
|
|
442
|
+
lines.push('**Variables:**');
|
|
443
|
+
lines.push(`- **color:** ${sortedColors.join(' | ')}`);
|
|
444
|
+
if (hasVariants.has('bright')) {
|
|
445
|
+
lines.push('- **variant:** default (no suffix) | bright');
|
|
446
|
+
}
|
|
447
|
+
lines.push('');
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Outputs pattern-compressed prettylights syntax tokens using prefix grouping
|
|
451
|
+
* Groups tokens by their primary element category
|
|
452
|
+
*/
|
|
453
|
+
function outputPrettylightsPattern(tokens, lines) {
|
|
454
|
+
const tokenNames = tokens.map(t => t.name);
|
|
455
|
+
// Common single-word elements (no sub-variants)
|
|
456
|
+
const simpleElements = [];
|
|
457
|
+
// Grouped elements with sub-variants (markup-*, brackethighlighter-*, etc.)
|
|
458
|
+
const groupedElements = new Map();
|
|
459
|
+
// Elements with bg/text variants - track the base name and which suffixes exist
|
|
460
|
+
const bgTextVariants = new Map();
|
|
461
|
+
for (const name of tokenNames) {
|
|
462
|
+
// Parse: color-prettylights-syntax-{element} or color-prettylights-syntax-{group}-{sub}
|
|
463
|
+
const element = name.replace('color-prettylights-syntax-', '');
|
|
464
|
+
const parts = element.split('-');
|
|
465
|
+
if (parts.length === 1) {
|
|
466
|
+
// Simple element: comment, constant, entity, keyword, string, variable
|
|
467
|
+
simpleElements.push(parts[0]);
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
const group = parts[0];
|
|
471
|
+
const rest = parts.slice(1).join('-');
|
|
472
|
+
// Check for bg/text suffix patterns (e.g., markup-changed-bg, markup-changed-text)
|
|
473
|
+
if (rest.endsWith('-bg') || rest.endsWith('-text')) {
|
|
474
|
+
const baseName = rest.replace(/-bg$/, '').replace(/-text$/, '');
|
|
475
|
+
const suffix = rest.endsWith('-bg') ? 'bg' : 'text';
|
|
476
|
+
const key = `${group}:${baseName}`; // Use colon to separate group from base
|
|
477
|
+
if (!bgTextVariants.has(key)) {
|
|
478
|
+
bgTextVariants.set(key, new Set());
|
|
479
|
+
}
|
|
480
|
+
bgTextVariants.get(key).add(suffix);
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
// Regular grouped element
|
|
484
|
+
if (!groupedElements.has(group)) {
|
|
485
|
+
groupedElements.set(group, new Set());
|
|
486
|
+
}
|
|
487
|
+
groupedElements.get(group).add(rest);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
// Output pattern
|
|
492
|
+
lines.push('**Pattern:** `color-prettylights-syntax-[element]`');
|
|
493
|
+
lines.push('');
|
|
494
|
+
// Output simple elements
|
|
495
|
+
if (simpleElements.length > 0) {
|
|
496
|
+
const sorted = [...new Set(simpleElements)].sort();
|
|
497
|
+
lines.push(`**Core elements:** ${sorted.join(', ')}`);
|
|
498
|
+
}
|
|
499
|
+
// Merge bg/text variants into grouped elements for cleaner output
|
|
500
|
+
// Group bg/text variants by their prefix group
|
|
501
|
+
const bgTextByGroup = new Map();
|
|
502
|
+
for (const [key] of bgTextVariants) {
|
|
503
|
+
const [group, baseName] = key.split(':');
|
|
504
|
+
if (!bgTextByGroup.has(group)) {
|
|
505
|
+
bgTextByGroup.set(group, []);
|
|
506
|
+
}
|
|
507
|
+
bgTextByGroup.get(group).push(baseName);
|
|
508
|
+
}
|
|
509
|
+
// Output grouped elements
|
|
510
|
+
if (groupedElements.size > 0 || bgTextByGroup.size > 0) {
|
|
511
|
+
lines.push('');
|
|
512
|
+
lines.push('**Compound elements:**');
|
|
513
|
+
// Get all groups (both regular and bg/text)
|
|
514
|
+
const allGroups = new Set([...groupedElements.keys(), ...bgTextByGroup.keys()]);
|
|
515
|
+
for (const group of [...allGroups].sort()) {
|
|
516
|
+
const regularSubs = groupedElements.get(group) || new Set();
|
|
517
|
+
const bgTextBases = bgTextByGroup.get(group) || [];
|
|
518
|
+
// Combine regular subs
|
|
519
|
+
if (regularSubs.size > 0) {
|
|
520
|
+
const uniqueSubs = [...regularSubs].sort();
|
|
521
|
+
lines.push(`- \`${group}-[${uniqueSubs.join(', ')}]\``);
|
|
522
|
+
}
|
|
523
|
+
// Output bg/text variants separately for clarity
|
|
524
|
+
if (bgTextBases.length > 0) {
|
|
525
|
+
const uniqueBases = [...new Set(bgTextBases)].sort();
|
|
526
|
+
lines.push(`- \`${group}-[${uniqueBases.join(', ')}]-[bg, text]\``);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
lines.push('');
|
|
531
|
+
}
|
|
299
532
|
// Human-readable category names and descriptions
|
|
300
533
|
const CATEGORY_INFO = {
|
|
301
534
|
bgColor: {
|
|
@@ -330,6 +563,10 @@ const CATEGORY_INFO = {
|
|
|
330
563
|
name: 'Data Visualization',
|
|
331
564
|
description: 'Color tokens for charts, graphs, and diagrams. Use emphasis variants for lines/bars, muted variants for fills.',
|
|
332
565
|
},
|
|
566
|
+
display: {
|
|
567
|
+
name: 'Display Colors',
|
|
568
|
+
description: 'Decorative colors for categorization without semantic meaning. Use for labels, tags, avatars, and user-assigned colors. Do NOT use for success/error/warning—use semantic colors instead.',
|
|
569
|
+
},
|
|
333
570
|
easing: { name: 'Easing', description: 'Animation easing function tokens.' },
|
|
334
571
|
focus: { name: 'Focus', description: 'Focus ring and outline tokens for keyboard navigation accessibility.' },
|
|
335
572
|
fontStack: { name: 'Font Stacks', description: 'Font family tokens.' },
|
|
@@ -555,6 +792,8 @@ export const markdownLlmGuidelines = (_a) => __awaiter(void 0, [_a], void 0, fun
|
|
|
555
792
|
const lines = [
|
|
556
793
|
'# Primer Design Token Guidelines',
|
|
557
794
|
'',
|
|
795
|
+
'> Metadata: This file is a Dictionary of tokens. For usage rules, contrast requirements, and motion logic, refer to DESIGN_TOKENS_GUIDE.md.',
|
|
796
|
+
'',
|
|
558
797
|
'Reference for using GitHub Primer design tokens.',
|
|
559
798
|
'',
|
|
560
799
|
'## Legend',
|
|
@@ -675,6 +914,116 @@ export const markdownLlmGuidelines = (_a) => __awaiter(void 0, [_a], void 0, fun
|
|
|
675
914
|
outputTypographyByRole(nonSemanticTokens, lines);
|
|
676
915
|
continue;
|
|
677
916
|
}
|
|
917
|
+
// Special handling for data visualization colors - use pattern compression
|
|
918
|
+
if (category === 'data') {
|
|
919
|
+
const categoryDesc = getCategoryDescription(category);
|
|
920
|
+
if (categoryDesc) {
|
|
921
|
+
lines.push('');
|
|
922
|
+
lines.push(categoryDesc);
|
|
923
|
+
}
|
|
924
|
+
lines.push('');
|
|
925
|
+
// Get usage and rules from the first token with LLM metadata
|
|
926
|
+
const firstWithMeta = nonSemanticTokens.find(t => t.usage || t.rules);
|
|
927
|
+
if (firstWithMeta) {
|
|
928
|
+
if (firstWithMeta.usage && firstWithMeta.usage.length > 0) {
|
|
929
|
+
lines.push(`**U:** ${firstWithMeta.usage.join(', ')}`);
|
|
930
|
+
}
|
|
931
|
+
if (firstWithMeta.rules) {
|
|
932
|
+
lines.push(`**R:** ${firstWithMeta.rules}`);
|
|
933
|
+
}
|
|
934
|
+
lines.push('');
|
|
935
|
+
}
|
|
936
|
+
outputDataVisColorPattern(nonSemanticTokens, lines);
|
|
937
|
+
continue;
|
|
938
|
+
}
|
|
939
|
+
// Special handling for display colors - use pattern compression
|
|
940
|
+
if (category === 'display') {
|
|
941
|
+
const categoryDesc = getCategoryDescription(category);
|
|
942
|
+
if (categoryDesc) {
|
|
943
|
+
lines.push('');
|
|
944
|
+
lines.push(categoryDesc);
|
|
945
|
+
}
|
|
946
|
+
lines.push('');
|
|
947
|
+
// Get usage and rules from the first token with LLM metadata
|
|
948
|
+
const firstWithMeta = nonSemanticTokens.find(t => t.usage || t.rules);
|
|
949
|
+
if (firstWithMeta) {
|
|
950
|
+
if (firstWithMeta.usage && firstWithMeta.usage.length > 0) {
|
|
951
|
+
lines.push(`**U:** ${firstWithMeta.usage.join(', ')}`);
|
|
952
|
+
}
|
|
953
|
+
if (firstWithMeta.rules) {
|
|
954
|
+
lines.push(`**R:** ${firstWithMeta.rules}`);
|
|
955
|
+
}
|
|
956
|
+
lines.push('');
|
|
957
|
+
}
|
|
958
|
+
outputDisplayColorPattern(nonSemanticTokens, lines);
|
|
959
|
+
continue;
|
|
960
|
+
}
|
|
961
|
+
// Special handling for color category (ansi, prettylights subcategories)
|
|
962
|
+
if (category === 'color') {
|
|
963
|
+
// Separate tokens by subcategory
|
|
964
|
+
const ansiTokens = nonSemanticTokens.filter(t => t.name.startsWith('color-ansi-'));
|
|
965
|
+
const prettylightsTokens = nonSemanticTokens.filter(t => t.name.startsWith('color-prettylights-'));
|
|
966
|
+
const otherTokens = nonSemanticTokens.filter(t => !t.name.startsWith('color-ansi-') && !t.name.startsWith('color-prettylights-'));
|
|
967
|
+
// Output ANSI tokens with pattern compression
|
|
968
|
+
if (ansiTokens.length > 0) {
|
|
969
|
+
lines.push('### ANSI Terminal Colors');
|
|
970
|
+
lines.push('');
|
|
971
|
+
const ansiMeta = ansiTokens.find(t => t.description);
|
|
972
|
+
if (ansiMeta === null || ansiMeta === void 0 ? void 0 : ansiMeta.description) {
|
|
973
|
+
lines.push(ansiMeta.description);
|
|
974
|
+
lines.push('');
|
|
975
|
+
}
|
|
976
|
+
const ansiWithMeta = ansiTokens.find(t => t.usage || t.rules);
|
|
977
|
+
if (ansiWithMeta) {
|
|
978
|
+
if (ansiWithMeta.usage && ansiWithMeta.usage.length > 0) {
|
|
979
|
+
lines.push(`**U:** ${ansiWithMeta.usage.join(', ')}`);
|
|
980
|
+
}
|
|
981
|
+
if (ansiWithMeta.rules) {
|
|
982
|
+
lines.push(`**R:** ${ansiWithMeta.rules}`);
|
|
983
|
+
}
|
|
984
|
+
lines.push('');
|
|
985
|
+
}
|
|
986
|
+
outputAnsiColorPattern(ansiTokens, lines);
|
|
987
|
+
}
|
|
988
|
+
// Output prettylights tokens with prefix grouping
|
|
989
|
+
if (prettylightsTokens.length > 0) {
|
|
990
|
+
lines.push('### Syntax Highlighting (prettylights)');
|
|
991
|
+
lines.push('');
|
|
992
|
+
const plMeta = prettylightsTokens.find(t => t.description);
|
|
993
|
+
if (plMeta === null || plMeta === void 0 ? void 0 : plMeta.description) {
|
|
994
|
+
lines.push(plMeta.description);
|
|
995
|
+
lines.push('');
|
|
996
|
+
}
|
|
997
|
+
const plWithMeta = prettylightsTokens.find(t => t.usage || t.rules);
|
|
998
|
+
if (plWithMeta) {
|
|
999
|
+
if (plWithMeta.usage && plWithMeta.usage.length > 0) {
|
|
1000
|
+
lines.push(`**U:** ${plWithMeta.usage.join(', ')}`);
|
|
1001
|
+
}
|
|
1002
|
+
if (plWithMeta.rules) {
|
|
1003
|
+
lines.push(`**R:** ${plWithMeta.rules}`);
|
|
1004
|
+
}
|
|
1005
|
+
lines.push('');
|
|
1006
|
+
}
|
|
1007
|
+
outputPrettylightsPattern(prettylightsTokens, lines);
|
|
1008
|
+
}
|
|
1009
|
+
// Output any other color tokens normally
|
|
1010
|
+
if (otherTokens.length > 0) {
|
|
1011
|
+
for (const token of otherTokens) {
|
|
1012
|
+
lines.push(`### ${token.name}`);
|
|
1013
|
+
if (token.description) {
|
|
1014
|
+
lines.push(token.description);
|
|
1015
|
+
}
|
|
1016
|
+
if (token.usage && token.usage.length > 0) {
|
|
1017
|
+
lines.push(`**U:** ${token.usage.join(', ')}`);
|
|
1018
|
+
}
|
|
1019
|
+
if (token.rules) {
|
|
1020
|
+
lines.push(`**R:** ${token.rules}`);
|
|
1021
|
+
}
|
|
1022
|
+
lines.push('');
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
continue;
|
|
1026
|
+
}
|
|
678
1027
|
// Special handling for pattern-compressed categories (control, overlay, stack, spinner)
|
|
679
1028
|
if (category in PATTERN_COMPRESSED_CATEGORIES) {
|
|
680
1029
|
const categoryDesc = getCategoryDescription(category);
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const borderValue: z.ZodObject<{
|
|
3
|
-
color: z.ZodUnion<readonly [z.ZodString, z.
|
|
3
|
+
color: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
4
|
+
colorSpace: z.ZodEnum<{
|
|
5
|
+
"display-p3": "display-p3";
|
|
6
|
+
srgb: "srgb";
|
|
7
|
+
rec2020: "rec2020";
|
|
8
|
+
"srgb-linear": "srgb-linear";
|
|
9
|
+
hsl: "hsl";
|
|
10
|
+
hwb: "hwb";
|
|
11
|
+
lab: "lab";
|
|
12
|
+
lch: "lch";
|
|
13
|
+
oklab: "oklab";
|
|
14
|
+
oklch: "oklch";
|
|
15
|
+
"a98-rgb": "a98-rgb";
|
|
16
|
+
"prophoto-rgb": "prophoto-rgb";
|
|
17
|
+
xyz: "xyz";
|
|
18
|
+
"xyz-d50": "xyz-d50";
|
|
19
|
+
"xyz-d65": "xyz-d65";
|
|
20
|
+
}>;
|
|
21
|
+
components: z.ZodTuple<[z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"none">]>, z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"none">]>, z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"none">]>], null>;
|
|
22
|
+
alpha: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
hex: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strict>, z.ZodString]>;
|
|
4
25
|
style: z.ZodEnum<{
|
|
5
26
|
inset: "inset";
|
|
6
27
|
solid: "solid";
|
|
@@ -11,13 +32,41 @@ export declare const borderValue: z.ZodObject<{
|
|
|
11
32
|
ridge: "ridge";
|
|
12
33
|
outset: "outset";
|
|
13
34
|
}>;
|
|
14
|
-
width: z.ZodUnion<readonly [z.
|
|
35
|
+
width: z.ZodUnion<readonly [z.ZodObject<{
|
|
36
|
+
value: z.ZodNumber;
|
|
37
|
+
unit: z.ZodEnum<{
|
|
38
|
+
em: "em";
|
|
39
|
+
px: "px";
|
|
40
|
+
rem: "rem";
|
|
41
|
+
}>;
|
|
42
|
+
}, z.core.$strict>, z.ZodString]>;
|
|
15
43
|
}, z.core.$strip>;
|
|
16
44
|
export declare const borderToken: z.ZodObject<{
|
|
17
45
|
$description: z.ZodOptional<z.ZodString>;
|
|
18
46
|
$deprecated: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
19
47
|
$value: z.ZodUnion<readonly [z.ZodObject<{
|
|
20
|
-
color: z.ZodUnion<readonly [z.ZodString, z.
|
|
48
|
+
color: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
49
|
+
colorSpace: z.ZodEnum<{
|
|
50
|
+
"display-p3": "display-p3";
|
|
51
|
+
srgb: "srgb";
|
|
52
|
+
rec2020: "rec2020";
|
|
53
|
+
"srgb-linear": "srgb-linear";
|
|
54
|
+
hsl: "hsl";
|
|
55
|
+
hwb: "hwb";
|
|
56
|
+
lab: "lab";
|
|
57
|
+
lch: "lch";
|
|
58
|
+
oklab: "oklab";
|
|
59
|
+
oklch: "oklch";
|
|
60
|
+
"a98-rgb": "a98-rgb";
|
|
61
|
+
"prophoto-rgb": "prophoto-rgb";
|
|
62
|
+
xyz: "xyz";
|
|
63
|
+
"xyz-d50": "xyz-d50";
|
|
64
|
+
"xyz-d65": "xyz-d65";
|
|
65
|
+
}>;
|
|
66
|
+
components: z.ZodTuple<[z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"none">]>, z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"none">]>, z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"none">]>], null>;
|
|
67
|
+
alpha: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
hex: z.ZodOptional<z.ZodString>;
|
|
69
|
+
}, z.core.$strict>, z.ZodString]>;
|
|
21
70
|
style: z.ZodEnum<{
|
|
22
71
|
inset: "inset";
|
|
23
72
|
solid: "solid";
|
|
@@ -28,9 +77,16 @@ export declare const borderToken: z.ZodObject<{
|
|
|
28
77
|
ridge: "ridge";
|
|
29
78
|
outset: "outset";
|
|
30
79
|
}>;
|
|
31
|
-
width: z.ZodUnion<readonly [z.
|
|
80
|
+
width: z.ZodUnion<readonly [z.ZodObject<{
|
|
81
|
+
value: z.ZodNumber;
|
|
82
|
+
unit: z.ZodEnum<{
|
|
83
|
+
em: "em";
|
|
84
|
+
px: "px";
|
|
85
|
+
rem: "rem";
|
|
86
|
+
}>;
|
|
87
|
+
}, z.core.$strict>, z.ZodString]>;
|
|
32
88
|
}, z.core.$strip>, z.ZodString]>;
|
|
33
|
-
$type: z.ZodLiteral<"
|
|
89
|
+
$type: z.ZodLiteral<"number" | "border" | "color" | "fontFamily" | "fontWeight" | "transition" | "duration" | "dimension" | "gradient" | "shadow" | "typography" | "cubicBezier" | "custom-viewportRange" | "custom-string">;
|
|
34
90
|
$extensions: z.ZodOptional<z.ZodObject<{
|
|
35
91
|
'org.primer.llm': z.ZodOptional<z.ZodObject<{
|
|
36
92
|
usage: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -2,11 +2,12 @@ import { z } from 'zod';
|
|
|
2
2
|
import { baseToken } from './baseToken.js';
|
|
3
3
|
import { referenceValue } from './referenceValue.js';
|
|
4
4
|
import { colorHexValue } from './colorHexValue.js';
|
|
5
|
+
import { colorW3cValue } from './colorW3cValue.js';
|
|
5
6
|
import { dimensionValue } from './dimensionValue.js';
|
|
6
7
|
import { tokenType } from './tokenType.js';
|
|
7
8
|
import { llmExtension } from './llmExtension.js';
|
|
8
9
|
export const borderValue = z.object({
|
|
9
|
-
color: z.union([colorHexValue, referenceValue]),
|
|
10
|
+
color: z.union([colorHexValue, colorW3cValue, referenceValue]),
|
|
10
11
|
style: z.enum(['solid', 'dashed', 'dotted', 'double', 'groove', 'ridge', 'outset', 'inset']),
|
|
11
12
|
width: z.union([dimensionValue, referenceValue]),
|
|
12
13
|
});
|