Skip to content

Token metadata#1302

Merged
lukasoppermann merged 6 commits intomainfrom
token-metadata
Jan 29, 2026
Merged

Token metadata#1302
lukasoppermann merged 6 commits intomainfrom
token-metadata

Conversation

@lukasoppermann
Copy link
Collaborator

Add more meta data and update how it is compiled to an md file.

Copilot AI review requested due to automatic review settings January 29, 2026 09:00
@lukasoppermann lukasoppermann requested review from a team as code owners January 29, 2026 09:00
@changeset-bot
Copy link

changeset-bot bot commented Jan 29, 2026

🦋 Changeset detected

Latest commit: 00fefa2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/primitives Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jan 29, 2026

Design Token Diff (CSS)

/css/functional/themes/dark-colorblind-high-contrast.css

+++ /home/runner/work/primitives/primitives/dist/css/functional/themes/dark-colorblind-high-contrast.css	2026-01-29 09:39:35.037247767 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
[data-color-mode="dark"][data-dark-theme="dark_colorblind_high_contrast"],
[data-color-mode="auto"][data-light-theme="dark_colorblind_high_contrast"] {
 --button-primary-bgColor-active: #3685f3;

/css/functional/themes/dark-colorblind.css

+++ /home/runner/work/primitives/primitives/dist/css/functional/themes/dark-colorblind.css	2026-01-29 09:39:35.037247767 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
[data-color-mode="dark"][data-dark-theme="dark_colorblind"],
[data-color-mode="auto"][data-light-theme="dark_colorblind"] {
 --button-primary-bgColor-active: #3685f3;

/css/functional/themes/dark-dimmed-high-contrast.css

+++ /home/runner/work/primitives/primitives/dist/css/functional/themes/dark-dimmed-high-contrast.css	2026-01-29 09:39:35.037247767 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
[data-color-mode="dark"][data-dark-theme="dark_dimmed_high_contrast"],
[data-color-mode="auto"][data-light-theme="dark_dimmed_high_contrast"] {
 --button-danger-fgColor-active: #ffffff;

/css/functional/themes/dark-dimmed.css

+++ /home/runner/work/primitives/primitives/dist/css/functional/themes/dark-dimmed.css	2026-01-29 09:39:35.038247760 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
[data-color-mode="dark"][data-dark-theme="dark_dimmed"],
[data-color-mode="auto"][data-light-theme="dark_dimmed"] {
 --button-danger-fgColor-active: #ffffff;

/css/functional/themes/dark-high-contrast.css

+++ /home/runner/work/primitives/primitives/dist/css/functional/themes/dark-high-contrast.css	2026-01-29 09:39:35.038247760 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
[data-color-mode="dark"][data-dark-theme="dark_high_contrast"],
[data-color-mode="auto"][data-light-theme="dark_high_contrast"] {
 --button-primary-bgColor-active: #109135;

/css/functional/themes/dark-tritanopia-high-contrast.css

+++ /home/runner/work/primitives/primitives/dist/css/functional/themes/dark-tritanopia-high-contrast.css	2026-01-29 09:39:35.038247760 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
[data-color-mode="dark"][data-dark-theme="dark_tritanopia_high_contrast"],
[data-color-mode="auto"][data-light-theme="dark_tritanopia_high_contrast"] {
 --button-outline-bgColor-active: #0d419d;

/css/functional/themes/dark-tritanopia.css

+++ /home/runner/work/primitives/primitives/dist/css/functional/themes/dark-tritanopia.css	2026-01-29 09:39:35.038247760 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
[data-color-mode="dark"][data-dark-theme="dark_tritanopia"],
[data-color-mode="auto"][data-light-theme="dark_tritanopia"] {
 --bgColor-sponsors-muted: #db61a21a; /** Subtle background for GitHub Sponsors content */

/css/functional/themes/dark.css

+++ /home/runner/work/primitives/primitives/dist/css/functional/themes/dark.css	2026-01-29 09:39:35.039247753 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
[data-color-mode="dark"][data-dark-theme="dark"],
[data-color-mode="auto"][data-light-theme="dark"] {
 --button-danger-fgColor-rest: #fa5e55;

/css/functional/themes/light-colorblind-high-contrast.css

+++ /home/runner/work/primitives/primitives/dist/css/functional/themes/light-colorblind-high-contrast.css	2026-01-29 09:39:35.039247753 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
[data-color-mode="light"][data-light-theme="light_colorblind_high_contrast"],
[data-color-mode="auto"][data-light-theme="light_colorblind_high_contrast"] {
 --button-outline-bgColor-active: #033f9d;

/css/functional/themes/light-colorblind.css

+++ /home/runner/work/primitives/primitives/dist/css/functional/themes/light-colorblind.css	2026-01-29 09:39:35.039247753 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
[data-color-mode="light"][data-light-theme="light_colorblind"],
[data-color-mode="auto"][data-light-theme="light_colorblind"] {
 --button-outline-bgColor-active: #0757ba;

/css/functional/themes/light-high-contrast.css

+++ /home/runner/work/primitives/primitives/dist/css/functional/themes/light-high-contrast.css	2026-01-29 09:39:35.039247753 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
[data-color-mode="light"][data-light-theme="light_high_contrast"],
[data-color-mode="auto"][data-light-theme="light_high_contrast"] {
 --button-outline-bgColor-active: #033f9d;

/css/functional/themes/light-tritanopia-high-contrast.css

+++ /home/runner/work/primitives/primitives/dist/css/functional/themes/light-tritanopia-high-contrast.css	2026-01-29 09:39:35.040247746 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
[data-color-mode="light"][data-light-theme="light_tritanopia_high_contrast"],
[data-color-mode="auto"][data-light-theme="light_tritanopia_high_contrast"] {
 --button-outline-bgColor-active: #033f9d;

/css/functional/themes/light-tritanopia.css

+++ /home/runner/work/primitives/primitives/dist/css/functional/themes/light-tritanopia.css	2026-01-29 09:39:35.041247739 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
[data-color-mode="light"][data-light-theme="light_tritanopia"],
[data-color-mode="auto"][data-light-theme="light_tritanopia"] {
 --button-outline-bgColor-active: #0757ba;

/css/functional/themes/light.css

+++ /home/runner/work/primitives/primitives/dist/css/functional/themes/light.css	2026-01-29 09:39:35.041247739 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
[data-color-mode="light"][data-light-theme="light"],
[data-color-mode="auto"][data-light-theme="light"] {
 --bgColor-success-emphasis: #1f883d; /** Strong success background for prominent positive actions */

/css/primitives.css

+++ /home/runner/work/primitives/primitives/dist/css/primitives.css	2026-01-29 09:39:35.036247774 +0000
@@ -1,3 +1,7 @@
+/**
+ * @spec See /DESIGN_TOKENS_SPEC.md for naming logic and semantic pairings.
+ * @rule Never use raw values (hex/px). Use semantic tokens ONLY.
+ */
@import './base/motion/motion.css';
@import './base/size/size.css';
@import './base/typography/typography.css';

@github-actions github-actions bot temporarily deployed to Preview (Storybook) January 29, 2026 09:03 Inactive
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the generated LLM/design-token documentation output to include richer metadata and a more compact, “spec-like” markdown format, and wires a new build step to produce that spec file.

Changes:

  • Refactors markdownLlmGuidelines output structure (Semantic Key section, category metadata, typography tables, pattern compression, shorthand fields).
  • Introduces a dedicated build:llm script to generate DESIGN_TOKENS_SPEC.md and updates packaging/gitignore accordingly.
  • Adds a CSS header referencing the spec file to primitives.css and theme CSS outputs.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/formats/markdownLlmGuidelines.ts Major rewrite of the markdown generator (semantic metadata tables, compression/grouping logic, new output format).
src/formats/markdownLlmGuidelines.test.ts Updates/adds unit tests for the new output shape and shorthands.
scripts/buildTokens.ts Removes combined LLM build and adds spec header injection into CSS outputs.
scripts/buildLlm.ts New script to generate DESIGN_TOKENS_SPEC.md via Style Dictionary platform.
package.json Adds build:llm step to build and includes DESIGN_TOKENS_SPEC.md in published files.
.gitignore Ignores generated DESIGN_TOKENS_SPEC.md.
Comments suppressed due to low confidence (7)

src/formats/markdownLlmGuidelines.ts:631

  • createCrossCategyBracketNotation is unused and will fail lint under @typescript-eslint/no-unused-vars. Also, the name appears to have a typo ("Categy" -> "Category"), which will be confusing if/when it is used. Either remove it or rename+use it for the wildcard semantic pattern output.
function createCrossCategyBracketNotation(
  entries: {subcategory: string; variant: string; guideline: LlmGuideline}[],
): {name: string; guideline: LlmGuideline}[] {
  // Group by subcategory + description + rules (normalized)
  const groups: Map<string, {subcategory: string; variants: string[]; guideline: LlmGuideline}> = new Map()

src/formats/markdownLlmGuidelines.ts:678

  • The formatter now always emits the full document header/Legend/Semantic Key even when guidelines is empty (no tokens with org.primer.llm). Existing unit tests in this repo expect an early return with only the header in that case. Either reintroduce an early return when guidelines.length === 0, or update the tests to match the new intended behavior.
export const markdownLlmGuidelines: FormatFn = async ({dictionary}: FormatFnArguments) => {
  const tokens = dictionary.allTokens.sort(sortByName)

  const guidelines: LlmGuideline[] = []

src/formats/markdownLlmGuidelines.ts:431

  • guideline.usage?.sort() mutates the usage array in-place. Since usage is later rendered, this can silently reorder usage items and also couples key creation with output ordering. Use a non-mutating sort (e.g. sort a copy) when building grouping keys.
function createGuidelineKey(guideline: LlmGuideline): string {
  return JSON.stringify({
    category: guideline.category,
    description: guideline.description || '',
    usage: guideline.usage?.sort() || [],

src/formats/markdownLlmGuidelines.test.ts:248

  • CATEGORY_INFO.fgColor.name is Foreground Colors, but this assertion expects ## Text. Update the expected heading (or adjust CATEGORY_INFO.fgColor.name if Text is the intended label).
    expect(result).toContain('## Text')

src/formats/markdownLlmGuidelines.ts:387

  • getTypographyRole is declared but never used in this file. With @typescript-eslint/no-unused-vars enabled, this will fail npm run lint. Either use it in the typography output logic or remove it.
function getTypographyRole(tokenName: string): string | null {
  for (const {role, patterns} of TYPOGRAPHY_ROLES) {
    if (patterns.some(pattern => tokenName.startsWith(pattern))) {
      return role
    }

src/formats/markdownLlmGuidelines.ts:581

  • createBracketNotation is declared but never used. With @typescript-eslint/no-unused-vars enabled, this will fail lint. Either wire it into the semantic token rendering (which also aligns with the bracket-notation expectations in tests) or remove it.
function createBracketNotation(tokens: LlmGuideline[]): {name: string; guideline: LlmGuideline}[] {
  // Group by category + subcategory + description + rules
  const groups: Map<string, LlmGuideline[]> = new Map()

  for (const token of tokens) {

src/formats/markdownLlmGuidelines.test.ts:31

  • These expectations appear out of sync with the formatter output after this PR: the formatter now emits # Primer Design Token Guidelines and category headings like ## Border Width (with a space) rather than # Token Guidelines / ## BorderWidth. Update the assertions to match the new output so the unit test reflects the intended format.
    expect(result).toContain('# Token Guidelines')
    expect(result).toContain('## BorderWidth')
    expect(result).toContain('### borderWidth-thick')
    expect(result).toContain('Thick 2px border for emphasis')
    expect(result).toContain('**U:** focus-indicator, selected-state')

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions bot temporarily deployed to Preview (Storybook) January 29, 2026 09:40 Inactive
@lukasoppermann lukasoppermann merged commit d5a7908 into main Jan 29, 2026
29 checks passed
@lukasoppermann lukasoppermann deleted the token-metadata branch January 29, 2026 10:10
@primer primer bot mentioned this pull request Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants