Skip to content

Add UI composition size tokens - #335345

Draft
Cherry Wang (chryw) wants to merge 9 commits into
mainfrom
cherwan/ui-composition-token-foundations
Draft

Add UI composition size tokens#335345
Cherry Wang (chryw) wants to merge 9 commits into
mainfrom
cherwan/ui-composition-token-foundations

Conversation

@chryw

@chryw Cherry Wang (chryw) commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Predictable UI composition — 1 of 3: shared token foundation

Stack:

  1. Add UI composition size tokens #335345 — composition tokens (this PR)
  2. Document the UI composition ownership heuristic #335346 — ownership guidance
  3. Give WorkbenchButtonBar ownership of leading-slot spacing #335350WorkbenchButtonBar pilot

Change

Adds shared vocabulary for recurring UI geometry:

  • fine spacing: 1px and 3px, completing the existing 0, 2, 4, 6, ... scale;
  • representation-neutral icon boxes: 12, 16, 20, 24, and 32px;
  • known CSS-variable registration;
  • spacing-validator alignment, including zero-aware nearest-step behavior;
  • family-level registry and validator tests.

Token descriptions are deliberately neutral. The scale provides stable names for values already common in VS Code; individual components still decide which step fits their density and role.

Scope boundary

This PR changes global vocabulary and validation, not product geometry. It does not migrate components, assign settled product meanings to every step, or require raw on-scale values to be replaced mechanically.

The active #335350 pilot consumes the 16px icon box. Other steps remain available for separately reviewed product work without requiring each feature to invent another variable.

Validation

  • 303 build-tool tests pass, including spacing-validator coverage.
  • Registry tests assert the complete spacing and icon-size scales.
  • The active three-PR stack was compared with latest main across 542 related fixtures: 534 are pixel-identical, and only intentional button fixtures change.
  • Editor diagnostics and git diff --check are clean.

Decision requested

Do the recurring 1px/3px spacing values and 12/16/20/24/32 icon sizes form the right neutral shared vocabulary without prematurely prescribing product roles?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The spacing validator omits 0px and conflicts with canonical authoring guidance.

Pull request overview

Adds behavior-neutral icon-size tokens and expands the spacing-token foundation for predictable UI composition.

Changes:

  • Registers icon sizes from 12px to 32px.
  • Adds 1px and 3px spacing tokens.
  • Updates known-variable registration, validation, and focused tests.
File summaries
File Changes and findings
src/vs/platform/theme/test/common/sizeRegistry.test.ts Tests new token registration and values.
src/vs/platform/theme/common/sizes/baseSizes.ts Registers icon-size and spacing tokens.
build/lib/test/designTokens.test.ts Tests spacing validation behavior.
build/lib/stylelint/vscode-known-variables.json Registers generated CSS variables.
build/lib/stylelint/validateDesignTokens.ts Updates the spacing ramp. Moderate (1 vote): include 0px in SPACING_SCALE. Nit (1 vote): align authoring guidance with the expanded ramp.
Review details

Suppressed comments (2)

build/lib/stylelint/validateDesignTokens.ts:357

  • The registered ramp includes spacing.sizeNone (0px), but 0 is missing from SPACING_SCALE. Because snapSpacing uses only this array, an off-scale value such as 0.25px is suggested as 1px instead of the nearest ramp value 0px; include 0 so snapping covers the complete ramp.
const SPACING_SCALE: readonly number[] = [1, 2, 3, 4, 6, 8, 10, 12, 16, 20, 24, 28, 32, 36, 40];

build/lib/stylelint/validateDesignTokens.ts:357

  • This makes 1px and 3px on-scale, but the canonical authoring guidance still defines the ramp as 0, 2, 4, … and explicitly says to snap 1px to 2px and 3px to 4px (.github/instructions/design-tokens.instructions.md:18-41). That leaves the validator and the guidance giving contradictory answers to CSS authors; update the guidance (and mirrored references) as part of this rollout or defer the validator change until it lands.
const SPACING_SCALE: readonly number[] = [1, 2, 3, 4, 6, 8, 10, 12, 16, 20, 24, 28, 32, 36, 40];
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The token additions, registration, validation updates, and tests have no unresolved review comments.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The updated spacing validator conflicts with the repository’s canonical authoring guidance.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread build/lib/stylelint/validateDesignTokens.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Nearest-step validation currently excludes zero from the declared spacing ramp.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread build/lib/stylelint/validateDesignTokens.ts Outdated
@chryw

Copy link
Copy Markdown
Contributor Author

Fixed the nearest-step zero-scale bug in 7c5a6f6: SPACING_SCALE started at 1px, so snapSpacing could never resolve a subpixel value (e.g. 0.4px) to 0 even though it was the closer candidate. Added 0 to the ascending scale (spacingVar(0) already emits var(--vscode-spacing-sizeNone)), and the existing <= tie-break still rounds an exact 0.5px tie up to 1px as documented. Added a regression test covering both cases; npm test in build/ passes (305 tests) and node build/stylelint.ts is otherwise unaffected.

Rebased #335346 and #335350 on top (no content changes there, new heads only). Re-requesting Copilot review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The implementation is coherent, but adopting a global candidate vocabulary whose roles remain unvalidated requires human design review.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Icon token descriptions currently present unvalidated contextual roles as settled guidance.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread src/vs/platform/theme/common/sizes/baseSizes.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The implementation is mechanically consistent, but landing the candidate vocabulary requires the human design-system judgment explicitly requested by the proposal.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cherry Wang (chryw) and others added 6 commits September 10, 2026 15:57
Replace the change-oriented composition token assertion with durable,
family-level coverage for the complete spacing and icon size ramps.
Keep the existing curated registration smoke test unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the existing representative registration smoke test unchanged.
Discover spacing and icon size families by registry prefix so each
complete expected scale is declared only once.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Compare complete registry families as keyed default-value snapshots so
the tests cover membership and values without asserting declaration
order.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
validateSpacingTokens declared its nearest-step scale starting at 1px,
so subpixel values close to zero (e.g. 0.4px) could never snap to
sizeNone: the smallest candidate was always 1px. Add 0 to
SPACING_SCALE so near-zero values resolve to var(--vscode-spacing-sizeNone),
while the existing tie-break (<=) still rounds an exact 0.5px tie up
to 1px as documented.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@chryw
Cherry Wang (chryw) force-pushed the cherwan/ui-composition-token-foundations branch from 762ee7d to 5bafbc2 Compare September 10, 2026 23:04
@chryw Cherry Wang (chryw) changed the title Add UI composition size tokens Add a shared 16px icon box token Sep 10, 2026
@chryw
Cherry Wang (chryw) requested a balanced review from Copilot September 10, 2026 23:13
Cherry Wang (chryw) and others added 2 commits September 10, 2026 16:15
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused token registration, lint integration, and test coverage are consistent and complete.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@chryw Cherry Wang (chryw) changed the title Add a shared 16px icon box token Add UI composition size tokens Sep 10, 2026
@chryw
Cherry Wang (chryw) requested a balanced review from Copilot September 10, 2026 23:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation, registration, and focused tests are consistent with the stated token-foundation scope.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

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