Skip to content

fix(Badge): replace hardcoded height with spacing token - #653

Merged
cixzhang merged 2 commits into
mainfrom
navi/theme-audit/badge
Mar 18, 2026
Merged

cixzhang merged 2 commits into
mainfrom
navi/theme-audit/badge

Conversation

@cixzhang

@cixzhang cixzhang commented Mar 17, 2026 •

Copy link
Copy Markdown
Contributor

Theme Audit — Badge

Replace hardcoded height: '20px' with spacingVars['--spacing-5'] (which resolves to 20px) so the badge height respects theme overrides.

Changes

  • packages/core/src/Badge/XDSBadge.tsx: height: '20px' → height: spacingVars['--spacing-5']

Needs Review

  • letterSpacing: '-0.24px' (line 46): This is also a hardcoded value, but no letter-spacing token currently exists in the token system. Adding one is a broader design decision — flagging for human input on whether this warrants a new token or should stay hardcoded.

Related audit notes (no fix needed)

  • Avatar inline SVG: DefaultIcon in XDSAvatar.tsx renders an inline SVG for the default person icon rather than using XDSIcon + the registry. However, no person icon exists in XDSIconName. Adding it would be feature work (new registry entry + default icon). Flagging for future consideration.
  • AspectRatio, Banner, Breadcrumbs: All clean — proper token usage, correct xdsClassName placement, and appropriate primitive reuse (Banner uses XDSButton + XDSIcon for close/expand buttons).

@cixzhang cixzhang added theming Theming system, design tokens, createTheme hardening Component hardening and quality sweep labels Mar 17, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 17, 2026
@github-actions

github-actions Bot commented Mar 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

Badge · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 203B N/A
Lines of Code N/A 132 -
Complexity N/A Low (3) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 10.2KB 16.3KB 2.5KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang

Copy link
Copy Markdown
Contributor Author

@ernestt is the letter spacing here necessary? I think this came from the badge internally. Probably wouldn't make sense to tokenize so if we want to keep it I might make it a component override in the default theme instead of having a non themeable value in the base component.

@ernestt

ernestt commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Unclear to me why it was applied in the first place. We can just remove it.

height: '20px' → spacingVars['--spacing-5'] (20px via token)
so themes that override the spacing scale affect the badge chip height.

letterSpacing: '-0.24px' is left as-is — no letter-spacing token exists
in the XDS token system yet. See PR description for discussion.

Night Watch — Theme Auditor

Co-authored-by: Navi <[email protected]>
@cixzhang
cixzhang force-pushed the navi/theme-audit/badge branch from dc68f6f to 0707aec Compare March 18, 2026 00:03
Remove letterSpacing: '-0.24px' from Badge base styles per review
feedback. The value was carried over from the internal version with
no clear reason to keep it.

Co-authored-by: Navi <[email protected]>
@cixzhang
cixzhang merged commit 7d9343a into main Mar 18, 2026
11 checks passed
@cixzhang
cixzhang deleted the navi/theme-audit/badge branch March 18, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. hardening Component hardening and quality sweep theming Theming system, design tokens, createTheme

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants