Skip to content

feat: token name builder prototype and component-anatomy registry#813

Open
GarthDB wants to merge 5 commits into
mainfrom
tools/token-name-builder
Open

feat: token name builder prototype and component-anatomy registry#813
GarthDB wants to merge 5 commits into
mainfrom
tools/token-name-builder

Conversation

@GarthDB
Copy link
Copy Markdown
Member

@GarthDB GarthDB commented Apr 6, 2026

Description

Adds a Token Name Builder — an interactive web tool for constructing valid Spectrum design token names using the design data spec taxonomy. Also introduces a component-anatomy registry extracted from S2 documentation, which powers the tool's component-aware anatomy filtering.

Token Name Builder (tools/token-name-builder/)

A Lit + Vite web app that guides users through building a structured token name object:

  • Smart form with 3 field groups: Identity (property, component, structure, substructure, anatomy, object), Modifiers (variant, state, size, orientation, position, density, shape), and Dimensions (colorScheme, scale, contrast)
  • Registry-driven dropdowns populated from design-system-registry JSON files
  • Component-aware filtering — selecting a component shows its valid anatomy/variant/state/size values first in optgroups
  • Live preview showing the serialized name in 4 formats (kebab-case, camelCase, CSS custom property, CONSTANT_CASE)
  • Two-tier validation — advisory warnings for non-registry semantic values, strict errors for invalid dimensions
  • URL hash persistence for shareable links
  • Accessibility — fieldset/legend, aria-live, aria-labelledby on all inputs

Component-Anatomy Registry (packages/design-system-registry/)

  • Extraction script parses ## Anatomy sections from all 67 S2 doc markdown files
  • Generated registry (component-anatomy.json) maps 65 components to 282 anatomy parts
  • Curation layer (component-anatomy-curation.json) documents all divergences between raw S2 docs and the curated registry with human-readable reasons:
    • Removals: numbering artifacts, token objects misclassified as anatomy
    • Renames: -area suffix alignment, size qualifier normalization
    • Tags: 17 composite anatomy parts (components used as named parts) tagged per spec tier 2

Related Issue

Relates to the taxonomy/glossary backbone initiative and Nate Baldwin's Foundry prototype for design data authoring.

Motivation and Context

Naming tokens correctly requires knowing which fields to use, what values are valid, and how names serialize per platform. This tool makes that process interactive and guided. The component-anatomy registry fills a critical data gap — the existing anatomy-terms.json had only 15 terms with no component mapping, while S2 docs have rich per-component anatomy data for 65+ components.

How Has This Been Tested?

  • 25 token-name-builder tests (AVA): serializer formats, validator rules, edge cases
  • 91 design-system-registry tests (AVA): extraction parsing, curation rules, generated output validation
  • TypeScript type checking passes with no errors
  • Manual testing via pnpm --filter @adobe/token-name-builder dev

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

GarthDB and others added 4 commits April 6, 2026 12:06
Interactive web tool for building Spectrum design token names. Includes:
- Core logic: name-object types, serializer (kebab/camel/CSS var/CONST),
  and validator (advisory semantic + strict dimension validation)
- Registry-driven form UI with Lit web components
- Live preview, platform format comparison, JSON output, copy buttons
- 25 passing tests for serializer and validator

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…en-name-builder

- Add component-awareness.ts: dynamically loads component schemas via
  import.meta.glob and extracts valid anatomy/variant/state/size options
- Update token-name-builder: component-aware optgroups on select fields
  show component-specific values first when a component is selected
- Add URL hash persistence: field state encoded as URLSearchParams in
  hash for shareable links; restored on page load
- Improve accessibility: fieldset/legend for sections, aria-live on
  preview and validation, aria-labelledby on all form inputs
- Add Share button to copy the current URL
- Fix tsconfig: add vite/client types for import.meta.glob and path
  mappings for @registry/* and @component-schemas/* aliases
- Add token-name-builder to site web tools config and regenerate tools.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add extraction script that parses anatomy sections from all 67 S2 doc
markdown files and generates a structured component-anatomy.json
mapping 65 components to their 288 anatomy parts.

- Parse fenced code blocks under ## Anatomy headings
- Handle compound lines (", " / " or " / " and " / " / " separators)
- Handle optional annotations, camelCase→kebab conversion, dedup
- Wire into token-name-builder: anatomy dropdown now shows real S2 docs
  anatomy parts per component (was ~4 matches, now 65 components)
- 24 new tests for extraction logic + generated output validation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add component-anatomy-curation.json that documents and applies rules
for divergences between raw S2 docs extraction and the curated registry:

- Removals: action-button-1/2 (numbering artifacts), background
  (token object, not anatomy)
- Renames: body-area→body, header-area→header, footer-area→footer,
  small-divider→divider (align with existing anatomy-terms registry)
- Tags: 17 composite anatomy parts (components used as named parts)
  tagged with tier: "composite" per spec anatomy tier 2

The curation config is the single source of truth for why the registry
diverges from the S2 docs. Re-running the extraction script applies
all rules automatically.

Result: 65 components, 282 parts (was 288 before curation)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 6, 2026

⚠️ No Changeset found

Latest commit: 05772f5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@GarthDB
Copy link
Copy Markdown
Member Author

GarthDB commented Apr 6, 2026

Run report for 05772f51

Total time: 1m 35s | Comparison time: 4m 5s | Estimated savings: 2m 30s (61.2% faster)

Action Time Status Info
⬛️ SetupProto(0.51.4) 0.1ms Skipped
🟩 SyncWorkspace 7.5ms Passed
🟩 SyncProject(componentSchemas) 1.2s Passed
🟩 SyncProject(sdk) 1.2s Passed
🟩 SyncProject(design-system-registry) 0.5ms Passed
🟩 SyncProject(tokens) 0.4ms Passed
🟩 SyncProject(markdown-generator) 0.3ms Passed
🟩 SyncProject(site) 0.3ms Passed
⬛️ SetupToolchain(node:20.17.0) 2.4s Skipped
🟩 RunTask(site:copySpec) 1.3s Passed
🟩 SetupToolchain(rust:1.85.0) 17.3s Passed
🟩 InstallWorkspaceDeps(rust:1.85.0, sdk) 647.9ms Passed
🟩 InstallProjectDeps(node:20.17.0, sdk) 15.8s Passed
🟩 RunTask(sdk:codegen) 223.9ms Passed
🟩 RunTask(sdk:codegen-check) 245.5ms Passed
🟩 InstallWorkspaceDeps(node:20.17.0) 16.2s Passed
🟥 RunTask(design-system-registry:validate) 251.9ms Failed
🟩 RunTask(tokens:buildManifest) 220.3ms Passed
🟩 RunTask(site:generateToolsPage) 702.3ms Passed
🟩 RunTask(componentSchemas:test) 4.1s Passed
And 13 more...
Expanded report
Action Time Status Info
🟩 RunTask(design-system-registry:test) 2.5s Passed
🟩 RunTask(sdk:build) 1m Passed
🟩 RunTask(tokens:verifyDesignDataSnapshot) 2.3s Passed
🟩 RunTask(tokens:validateDesignData) 2.5s Passed
🟩 RunTask(tokens:verifyLegacyRoundtrip) 1.1s Passed
🟩 RunTask(sdk:test) 1m 11s Passed
🟩 RunTask(tokens:buildTokens) 1m 11s Passed
🟩 RunTask(tokens:build) 14.9ms Passed
🟩 RunTask(markdown-generator:generate) 341.1ms Passed
🟩 RunTask(site:copyContent) 75.7ms Passed
🟩 RunTask(tokens:test) 4.4s Passed
🟩 RunTask(site:build) 4.4s Passed
🟩 RunTask(site:export) 7.7ms Passed
Touched files
docs/site/scripts/generate-tools-page.js
docs/site/src/tools.md
packages/design-system-registry/index.js
packages/design-system-registry/registry/component-anatomy-curation.json
packages/design-system-registry/registry/component-anatomy.json
packages/design-system-registry/scripts/extract-component-anatomy.js
packages/design-system-registry/test/component-anatomy.test.js
pnpm-lock.yaml
tools/token-name-builder/ava.config.js
tools/token-name-builder/index.html
tools/token-name-builder/moon.yml
tools/token-name-builder/package.json
tools/token-name-builder/src/component-awareness.ts
tools/token-name-builder/src/main.ts
tools/token-name-builder/src/name-object.ts
tools/token-name-builder/src/registry-data.ts
tools/token-name-builder/src/serializer.ts
tools/token-name-builder/src/styles/main.css
tools/token-name-builder/src/token-name-builder.ts
tools/token-name-builder/src/validator.ts
tools/token-name-builder/test/serializer.test.js
tools/token-name-builder/test/validator.test.js
tools/token-name-builder/tsconfig.json
tools/token-name-builder/vite.config.ts

…on-group numbering

[P1] Anatomy validation now checks both anatomy-terms.json and the
component-anatomy registry. Values like "fill", "title", "value" that
come from S2 docs no longer trigger false "not in registry" warnings.

[P2] Curation config changed action-button-1/2 from removals to renames
(→ action-button), so action-group retains its anatomy data instead of
being left with only action-menu.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant