Skip to content

feat(tokens): rename design tokens per naming audit - #698

Merged
cixzhang merged 7 commits into
mainfrom
navi/feat/token-renames
Mar 19, 2026
Merged

cixzhang merged 7 commits into
mainfrom
navi/feat/token-renames

Conversation

@cixzhang

@cixzhang cixzhang commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Token Naming Audit — Full Rename + Codemod

Implements the finalized token names from the naming review spreadsheet, and adds a codemod so consumers can auto-migrate.

Summary

Type Count
Tokens renamed 32
Tokens removed 3
Files updated 96
Codemod tests 22

Color Renames

Semantic clarity:

  • --color-accent → --color-primary
  • --color-positive → --color-success
  • --color-negative → --color-error
  • --color-educational → --color-info
  • *-deemphasized → *-muted (all status tokens)

Noun-first grammar (thing → modifier):

  • --color-hover-overlay → --color-overlay-hover
  • --color-focus-outline-* → --color-ring-focus-*

Border/divider consolidation:

  • --color-divider → --color-border
  • --color-divider-high-contrast → --color-border-strong

Effects:

  • --color-glimmer → --color-skeleton
  • --color-shadow-elevation → --color-shadow

Token Removals

Removed Replacement
--color-accent-text --color-text-link
--color-text-placeholder --color-text-secondary
--color-icon-tertiary --color-icon-secondary

Codemod

Consumers can auto-migrate with:

npx @xds/cli upgrade --from 0.0.4 --to 0.0.5 --apply
# or run just this codemod:
npx @xds/cli upgrade --codemod migrate-token-names --apply

The migrate-token-names codemod handles:

  • String literals (colorVars["--color-accent"])
  • var() references ("var(--color-divider)")
  • Template literals (`var(--color-accent)`)
  • defineTheme token objects
  • Longest-match-first to prevent partial replacements

22 test cases covering all renames, edge cases, and partial match safety.


@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 18, 2026
@github-actions

github-actions Bot commented Mar 18, 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

AppShell · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 801B N/A
Lines of Code N/A 544 -
Complexity N/A Very High (88) -
Avatar · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 249B N/A
Lines of Code N/A 322 -
Complexity N/A High (29) -
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) -
Banner · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 429B N/A
Lines of Code N/A 276 -
Complexity N/A High (21) -
Button · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 333B N/A
Lines of Code N/A 292 -
Complexity N/A High (22) -
Calendar · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 901B N/A
Lines of Code N/A 925 -
Complexity N/A Very High (122) -
Card · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 265B N/A
Lines of Code N/A 113 -
Complexity N/A Medium (10) -
CheckboxInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 443B N/A
Lines of Code N/A 357 -
Complexity N/A High (30) -
Collapsible · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 4.6KB N/A
Lines of Code N/A 244 -
Complexity N/A High (18) -
DateInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 755B N/A
Lines of Code N/A 387 -
Complexity N/A Very High (47) -
Dialog · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 595B N/A
Lines of Code N/A 317 -
Complexity N/A Very High (38) -
Divider · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 239B N/A
Lines of Code N/A 138 -
Complexity N/A Medium (9) -
DropdownMenu · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 687B N/A
Lines of Code N/A 506 -
Complexity N/A Very High (63) -
Field · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 818B N/A
Lines of Code N/A 504 -
Complexity N/A High (19) -
HoverCard · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 217B N/A
Lines of Code N/A 428 -
Complexity N/A Very High (44) -
Icon · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 325B N/A
Lines of Code N/A 304 -
Complexity N/A Low (4) -
Kbd · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 199B N/A
Lines of Code N/A 81 -
Complexity N/A Low (4) -
Layout · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 1.0KB N/A
Lines of Code N/A 899 -
Complexity N/A Very High (66) -
Link · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 581B N/A
Lines of Code N/A 228 -
Complexity N/A Medium (11) -
List · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 231B N/A
Lines of Code N/A 408 -
Complexity N/A Very High (37) -
MobileNav · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 615B N/A
Lines of Code N/A 322 -
Complexity N/A Very High (32) -
MoreMenu · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 625B N/A
Lines of Code N/A 372 -
Complexity N/A Very High (49) -
NavIcon
Metric Before After Delta
Bundle Size (ESM) N/A 207B N/A
Lines of Code N/A 47 -
Complexity N/A Low (1) -
NavItem
Metric Before After Delta
Bundle Size (ESM) N/A 181B N/A
Lines of Code N/A 58 -
Complexity N/A Low (1) -
NumberInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 471B N/A
Lines of Code N/A 357 -
Complexity N/A Very High (52) -
Pagination · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 799B N/A
Lines of Code N/A 383 -
Complexity N/A Very High (49) -
Popover · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 345B N/A
Lines of Code N/A 469 -
Complexity N/A Very High (42) -
ProgressBar · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 215B N/A
Lines of Code N/A 215 -
Complexity N/A Medium (13) -
RadioList · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 475B N/A
Lines of Code N/A 406 -
Complexity N/A High (28) -
Section · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 271B N/A
Lines of Code N/A 144 -
Complexity N/A High (16) -
Selector · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 1.1KB N/A
Lines of Code N/A 925 -
Complexity N/A Very High (47) -
SideNav · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 1.1KB N/A
Lines of Code N/A 1338 -
Complexity N/A Very High (133) -
Skeleton · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 209B N/A
Lines of Code N/A 105 -
Complexity N/A Low (3) -
Slider · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 429B N/A
Lines of Code N/A 615 -
Complexity N/A Very High (75) -
Spinner · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 207B N/A
Lines of Code N/A 110 -
Complexity N/A Medium (8) -
StatusDot · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 211B N/A
Lines of Code N/A 107 -
Complexity N/A Low (3) -
Switch · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 429B N/A
Lines of Code N/A 320 -
Complexity N/A High (28) -
TabList · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 479B N/A
Lines of Code N/A 559 -
Complexity N/A High (26) -
Table · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 863B N/A
Lines of Code N/A 847 -
Complexity N/A Very High (54) -
Text · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 335B N/A
Lines of Code N/A 484 -
Complexity N/A Very High (44) -
TextArea · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 497B N/A
Lines of Code N/A 235 -
Complexity N/A High (27) -
TextInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 499B N/A
Lines of Code N/A 222 -
Complexity N/A High (25) -
TimeInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 499B N/A
Lines of Code N/A 379 -
Complexity N/A Very High (54) -
Token · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 267B N/A
Lines of Code N/A 357 -
Complexity N/A Medium (14) -
Tokenizer · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 531B N/A
Lines of Code N/A 372 -
Complexity N/A Very High (50) -
Tooltip · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 241B N/A
Lines of Code N/A 405 -
Complexity N/A Very High (47) -
TopNav · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 1.2KB N/A
Lines of Code N/A 1505 -
Complexity N/A Very High (92) -
TreeList · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 241B N/A
Lines of Code N/A 678 -
Complexity N/A Very High (60) -
Typeahead · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 619B N/A
Lines of Code N/A 863 -
Complexity N/A Very High (119) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 10.7KB 17.0KB 2.6KB

Accessibility Audit

Status: 13 accessibility violation(s) found — 1 critical, 10 serious, 2 moderate.

XDSAvatar - 1 issue(s)
  • 🟠 serious: Ensure ARIA attributes are not prohibited for an element's role
    • Rule: aria-prohibited-attr · Affects 3/12 stories · Learn more
    • WCAG: 4.1.2 (Level A)
XDSBanner - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/15 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
XDSCalendar - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 10/11 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
XDSCheckboxInput - 1 issue(s)
  • 🟠 serious: Ensure ARIA attributes are used as described in the specification of the element's role
    • Rule: aria-conditional-attr · Affects 2/16 stories · Learn more
    • WCAG: 4.1.2 (Level A)
XDSIcon - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/16 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
XDSLayout - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 4/10 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
XDSList - 1 issue(s)
  • 🔴 critical: Ensure an element's role supports its ARIA attributes
    • Rule: aria-allowed-attr · Affects 1/10 stories · Learn more
    • WCAG: 4.1.2 (Level A)
XDSPagination - 1 issue(s)
  • 🟡 moderate: Ensure landmarks are unique
    • Rule: landmark-unique · Affects 1/14 stories · Learn more
XDSSideNav - 1 issue(s)
  • 🟠 serious: Ensure links have discernible text
    • Rule: link-name · Affects 1/8 stories · Learn more
    • WCAG: 2.4.4, 4.1.2 (Level A)
XDSTabList - 1 issue(s)
  • 🟡 moderate: Ensure landmarks are unique
    • Rule: landmark-unique · Affects 1/5 stories · Learn more
Selection - 1 issue(s)
  • 🟠 serious: Ensure ARIA attributes are used as described in the specification of the element's role
    • Rule: aria-conditional-attr · Affects 1/7 stories · Learn more
    • WCAG: 4.1.2 (Level A)
XDSText - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/22 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
XDSToken - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/9 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

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

@rubyycheung

Copy link
Copy Markdown
Contributor

Context on naming positive and negative #683

Navi and others added 4 commits March 19, 2026 01:30
Comprehensive token rename based on the token naming review spreadsheet.
Removes 3 redundant tokens, renames 32 tokens for consistency.

Semantic clarity:
- --color-accent → --color-primary
- --color-accent-deemphasized → --color-primary-muted
- --color-deemphasized → --color-muted
- --color-positive → --color-success
- --color-negative → --color-error
- --color-educational → --color-info
- *-deemphasized → *-muted (across all status tokens)

Noun-first grammar (thing → modifier):
- --color-hover-overlay → --color-overlay-hover
- --color-pressed-overlay → --color-overlay-pressed
- --color-disabled-overlay → --color-overlay-disabled
- --color-focus-outline-* → --color-ring-focus-*

Border/divider consolidation:
- --color-divider → --color-border
- --color-divider-high-contrast → --color-border-strong
- --color-divider-emphasized → --color-border-emphasized

Effects:
- --color-glimmer → --color-skeleton
- --color-glimmer-high-contrast → --color-skeleton-strong
- --color-shadow-elevation → --color-shadow

Media:
- --color-text-on-media → --color-text-on-dark-media
- --color-icon-on-media → --color-icon-on-dark-media

- --color-accent-text → use --color-text-link
- --color-text-placeholder → use --color-text-secondary
- --color-icon-tertiary → use --color-icon-secondary

- --radius-inner → --radius-0
- --radius-content → --radius-1
- --radius-element → --radius-2
- --radius-container → --radius-3
- --radius-page → --radius-4

Fixes radius codemod to use old→new semantic names.
Updates all components, themes, docs, stories, and tests.

Co-authored-by: Navi <[email protected]>
Adds a jscodeshift codemod that migrates all color/effect token names
from the v0.0.5 naming audit. Handles string literals, template literals,
and property access patterns.

28 token renames covering:
- Semantic clarity (accent→primary, positive→success, negative→error, educational→info)
- Noun-first grammar (hover-overlay→overlay-hover, focus-outline→ring-focus)
- Border consolidation (divider→border)
- Effects (glimmer→skeleton, shadow-elevation→shadow)
- Media (on-media→on-dark-media)
- Removals (accent-text→text-link, text-placeholder→text-secondary, icon-tertiary→icon-secondary)

22 tests covering all renames, edge cases, and partial match safety.

Co-authored-by: Navi <[email protected]>
Keep --color-accent instead of --color-primary to avoid ambiguity
with --color-text-primary and --color-icon-primary.

Vibe test showed that 'primary' as both the brand color AND the
highest-emphasis foreground tier causes confusion — LLMs reaching
for --color-primary when they mean --color-text-primary (body text).
With --color-accent, there's zero collision.

All other renames (success/error/info/border/skeleton/etc.) stay.

- --color-accent (kept, not renamed)
- --color-accent-deemphasized → --color-accent-muted (muted suffix only)
- Codemod updated: removed accent→primary mapping
- 22 codemod tests updated and passing

Co-authored-by: Navi <[email protected]>
New semantic token for secondary interactive elements:
  light-dark(rgba(5, 54, 89, 0.1), rgba(223, 226, 229, 0.2))

Uses the same value as the existing secondary button override color.
Applied to Button (secondary variant), Badge (neutral variant), and
Token (default color) — replacing --color-muted which is now reserved
for general deemphasized backgrounds.

This lets themes override the secondary interactive color independently
from the muted background color.

Co-authored-by: Navi <[email protected]>
@cixzhang
cixzhang force-pushed the navi/feat/token-renames branch from 6f52d5a to 1758cd5 Compare March 19, 2026 01:31
cixzhang and others added 3 commits March 19, 2026 01:36
Adds --color-secondary token:
  light-dark(rgba(5, 54, 89, 0.1), rgba(223, 226, 229, 0.2))
Used for Button (secondary), Badge (neutral), Token (default) —
distinct from --color-muted which is for general deemphasized bgs.

Removes --color-skeleton-strong — Skeleton now derives its
high-contrast variant using color-mix() with --color-text-primary,
adapting to any theme automatically.

Co-authored-by: Navi <[email protected]>
Aligns token names closer to Tailwind CSS conventions:
- --insetshadow-border-* → --inset-shadow-border-*
- --easing-standard → --ease-standard
- easingVars/easingDefaults/EasingVarName → easeVars/easeDefaults/EaseVarName

Updates shadow codemod to output --inset-shadow-border-* names.
All 68 codemod tests passing.

Co-authored-by: Navi <[email protected]>
Adds the Tailwind-alignment renames to migrate-token-names codemod:
- --insetshadow-border-* → --inset-shadow-border-*
- --easing-standard → --ease-standard

2 new test cases (24 total). All 70 codemod tests passing.

Co-authored-by: Navi <[email protected]>
@cixzhang
cixzhang merged commit f168730 into main Mar 19, 2026
10 checks passed
rubyycheung added a commit that referenced this pull request Mar 19, 2026
Tokens were renamed on main (PR #698). Updated all references:
- accent-deemphasized → accent-muted
- hover-overlay → overlay-hover, pressed-overlay → overlay-pressed
- focus-outline → ring-focus (and error/success/warning variants)
- deemphasized → muted
- text-on-media → text-on-dark-media, icon-on-media → icon-on-dark-media
- divider → border, divider-high-contrast → border-strong, divider-emphasized → border-emphasized
- positive → success, negative → error (and muted variants)
- educational → info (and muted variant)
- glimmer → skeleton, shadow-elevation → shadow

Removed tokens no longer in core:
- accent-text, text-placeholder, icon-tertiary, glimmer-high-contrast
cixzhang added a commit that referenced this pull request Mar 19, 2026
PR #698 renamed --color-divider to --color-border across the codebase.
Updated the popoverSurface borderColor to use the new token name.

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Mar 20, 2026
* feat(SideNav): popover for collapsed items with children

When the SideNav is collapsed to icon-only mode, items with sub-items
now show a popover on click:

- Appears to the end (right in LTR) of the icon-only trigger
- Contains children rendered in expanded form (not collapsed) via
  XDSSideNavCollapseProvider wrapping with isCollapsed: false
- Closes on click outside, escape, or clicking a child item
- Shows the parent label as a header in the popover
- Uses XDS design tokens for surface, border, elevation, and radius

Items without children in collapsed mode render as icon-only
link/button with tooltip (existing behavior, cleaned up).

Changes:
- XDSSideNavCollapseContext.ts → .tsx with XDSSideNavCollapseProvider
- XDSSideNavItem: collapsed render path with useXDSPopover
- Removed dead isCollapsed references in expanded render path
- 8 new tests for collapsed mode behavior

Co-authored-by: Navi <[email protected]>

* feat: hover to open collapsed subnav popover

Popover now opens on hover (150ms delay) in addition to click,
matching TopNavMenu behavior. Hovering the popover content keeps
it open; leaving both trigger and panel closes after 200ms.

Co-authored-by: Navi <[email protected]>

* refactor: remove XDSSideNavCollapseProvider, use context directly

React 19 supports <Context value={...}> without .Provider. Remove
the unnecessary Provider wrapper — use XDSSideNavCollapseContext
directly in SideNavItem popover and test helpers.

CollapseContext file stays as .ts (no JSX needed).

Co-authored-by: Navi <[email protected]>

* fix: move hooks before early return to prevent hooks violation

All useRef/useCallback hooks must run before the early return for
items without icons in collapsed mode. React requires the same
number of hooks every render.

Co-authored-by: Navi <[email protected]>

* fix: use --color-popover for collapsed subnav popover surface

Co-authored-by: Navi <[email protected]>

* refactor: extract collapsedItemStyles, move xdsClassName to item elements

- Extract shared collapsed item styles (navItemStyles.item + itemCollapsed +
  selected + disabled) into a single collapsedItemStyles variable
- Move xdsClassName('side-nav-item') from wrapper div to the actual item
  elements (button/link/trigger) where the styles are applied
- Wrapper divs now only get styles.root

Co-authored-by: Navi <[email protected]>

* fix: add xdsClassName to expanded items, 4px popover offset

- Move xdsClassName('side-nav-item') to expanded link/button elements
  (was only on wrapper div)
- Add marginInlineStart: spacing-1 (4px) to popover surface for gap
  between trigger and popover

Co-authored-by: Navi <[email protected]>

* fix: update --color-divider to --color-border after #698 merge

PR #698 renamed --color-divider to --color-border across the codebase.
Updated the popoverSurface borderColor to use the new token name.

Co-authored-by: Navi <[email protected]>

---------

Co-authored-by: Navi <[email protected]>
@cixzhang
cixzhang deleted the navi/feat/token-renames branch March 20, 2026 16:59
rubyycheung added a commit that referenced this pull request Mar 21, 2026
Tokens were renamed on main (PR #698). Updated all references:
- accent-deemphasized → accent-muted
- hover-overlay → overlay-hover, pressed-overlay → overlay-pressed
- focus-outline → ring-focus (and error/success/warning variants)
- deemphasized → muted
- text-on-media → text-on-dark-media, icon-on-media → icon-on-dark-media
- divider → border, divider-high-contrast → border-strong, divider-emphasized → border-emphasized
- positive → success, negative → error (and muted variants)
- educational → info (and muted variant)
- glimmer → skeleton, shadow-elevation → shadow

Removed tokens no longer in core:
- accent-text, text-placeholder, icon-tertiary, glimmer-high-contrast
rubyycheung added a commit that referenced this pull request Mar 22, 2026
Tokens were renamed on main (PR #698). Updated all references:
- accent-deemphasized → accent-muted
- hover-overlay → overlay-hover, pressed-overlay → overlay-pressed
- focus-outline → ring-focus (and error/success/warning variants)
- deemphasized → muted
- text-on-media → text-on-dark-media, icon-on-media → icon-on-dark-media
- divider → border, divider-high-contrast → border-strong, divider-emphasized → border-emphasized
- positive → success, negative → error (and muted variants)
- educational → info (and muted variant)
- glimmer → skeleton, shadow-elevation → shadow

Removed tokens no longer in core:
- accent-text, text-placeholder, icon-tertiary, glimmer-high-contrast
cixzhang added a commit that referenced this pull request Apr 26, 2026
* feat(SideNav): popover for collapsed items with children

When the SideNav is collapsed to icon-only mode, items with sub-items
now show a popover on click:

- Appears to the end (right in LTR) of the icon-only trigger
- Contains children rendered in expanded form (not collapsed) via
  XDSSideNavCollapseProvider wrapping with isCollapsed: false
- Closes on click outside, escape, or clicking a child item
- Shows the parent label as a header in the popover
- Uses XDS design tokens for surface, border, elevation, and radius

Items without children in collapsed mode render as icon-only
link/button with tooltip (existing behavior, cleaned up).

Changes:
- XDSSideNavCollapseContext.ts → .tsx with XDSSideNavCollapseProvider
- XDSSideNavItem: collapsed render path with useXDSPopover
- Removed dead isCollapsed references in expanded render path
- 8 new tests for collapsed mode behavior

Co-authored-by: Navi <[email protected]>

* feat: hover to open collapsed subnav popover

Popover now opens on hover (150ms delay) in addition to click,
matching TopNavMenu behavior. Hovering the popover content keeps
it open; leaving both trigger and panel closes after 200ms.

Co-authored-by: Navi <[email protected]>

* refactor: remove XDSSideNavCollapseProvider, use context directly

React 19 supports <Context value={...}> without .Provider. Remove
the unnecessary Provider wrapper — use XDSSideNavCollapseContext
directly in SideNavItem popover and test helpers.

CollapseContext file stays as .ts (no JSX needed).

Co-authored-by: Navi <[email protected]>

* fix: move hooks before early return to prevent hooks violation

All useRef/useCallback hooks must run before the early return for
items without icons in collapsed mode. React requires the same
number of hooks every render.

Co-authored-by: Navi <[email protected]>

* fix: use --color-popover for collapsed subnav popover surface

Co-authored-by: Navi <[email protected]>

* refactor: extract collapsedItemStyles, move xdsClassName to item elements

- Extract shared collapsed item styles (navItemStyles.item + itemCollapsed +
  selected + disabled) into a single collapsedItemStyles variable
- Move xdsClassName('side-nav-item') from wrapper div to the actual item
  elements (button/link/trigger) where the styles are applied
- Wrapper divs now only get styles.root

Co-authored-by: Navi <[email protected]>

* fix: add xdsClassName to expanded items, 4px popover offset

- Move xdsClassName('side-nav-item') to expanded link/button elements
  (was only on wrapper div)
- Add marginInlineStart: spacing-1 (4px) to popover surface for gap
  between trigger and popover

Co-authored-by: Navi <[email protected]>

* fix: update --color-divider to --color-border after #698 merge

PR #698 renamed --color-divider to --color-border across the codebase.
Updated the popoverSurface borderColor to use the new token name.

Co-authored-by: Navi <[email protected]>

---------

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
* feat(SideNav): popover for collapsed items with children

When the SideNav is collapsed to icon-only mode, items with sub-items
now show a popover on click:

- Appears to the end (right in LTR) of the icon-only trigger
- Contains children rendered in expanded form (not collapsed) via
  XDSSideNavCollapseProvider wrapping with isCollapsed: false
- Closes on click outside, escape, or clicking a child item
- Shows the parent label as a header in the popover
- Uses XDS design tokens for surface, border, elevation, and radius

Items without children in collapsed mode render as icon-only
link/button with tooltip (existing behavior, cleaned up).

Changes:
- XDSSideNavCollapseContext.ts → .tsx with XDSSideNavCollapseProvider
- XDSSideNavItem: collapsed render path with useXDSPopover
- Removed dead isCollapsed references in expanded render path
- 8 new tests for collapsed mode behavior

Co-authored-by: Navi <[email protected]>

* feat: hover to open collapsed subnav popover

Popover now opens on hover (150ms delay) in addition to click,
matching TopNavMenu behavior. Hovering the popover content keeps
it open; leaving both trigger and panel closes after 200ms.

Co-authored-by: Navi <[email protected]>

* refactor: remove XDSSideNavCollapseProvider, use context directly

React 19 supports <Context value={...}> without .Provider. Remove
the unnecessary Provider wrapper — use XDSSideNavCollapseContext
directly in SideNavItem popover and test helpers.

CollapseContext file stays as .ts (no JSX needed).

Co-authored-by: Navi <[email protected]>

* fix: move hooks before early return to prevent hooks violation

All useRef/useCallback hooks must run before the early return for
items without icons in collapsed mode. React requires the same
number of hooks every render.

Co-authored-by: Navi <[email protected]>

* fix: use --color-popover for collapsed subnav popover surface

Co-authored-by: Navi <[email protected]>

* refactor: extract collapsedItemStyles, move xdsClassName to item elements

- Extract shared collapsed item styles (navItemStyles.item + itemCollapsed +
  selected + disabled) into a single collapsedItemStyles variable
- Move xdsClassName('side-nav-item') from wrapper div to the actual item
  elements (button/link/trigger) where the styles are applied
- Wrapper divs now only get styles.root

Co-authored-by: Navi <[email protected]>

* fix: add xdsClassName to expanded items, 4px popover offset

- Move xdsClassName('side-nav-item') to expanded link/button elements
  (was only on wrapper div)
- Add marginInlineStart: spacing-1 (4px) to popover surface for gap
  between trigger and popover

Co-authored-by: Navi <[email protected]>

* fix: update --color-divider to --color-border after #698 merge

PR #698 renamed --color-divider to --color-border across the codebase.
Updated the popoverSurface borderColor to use the new token name.

Co-authored-by: Navi <[email protected]>

---------

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
* feat(SideNav): popover for collapsed items with children

When the SideNav is collapsed to icon-only mode, items with sub-items
now show a popover on click:

- Appears to the end (right in LTR) of the icon-only trigger
- Contains children rendered in expanded form (not collapsed) via
  XDSSideNavCollapseProvider wrapping with isCollapsed: false
- Closes on click outside, escape, or clicking a child item
- Shows the parent label as a header in the popover
- Uses XDS design tokens for surface, border, elevation, and radius

Items without children in collapsed mode render as icon-only
link/button with tooltip (existing behavior, cleaned up).

Changes:
- XDSSideNavCollapseContext.ts → .tsx with XDSSideNavCollapseProvider
- XDSSideNavItem: collapsed render path with useXDSPopover
- Removed dead isCollapsed references in expanded render path
- 8 new tests for collapsed mode behavior


* feat: hover to open collapsed subnav popover

Popover now opens on hover (150ms delay) in addition to click,
matching TopNavMenu behavior. Hovering the popover content keeps
it open; leaving both trigger and panel closes after 200ms.


* refactor: remove XDSSideNavCollapseProvider, use context directly

React 19 supports <Context value={...}> without .Provider. Remove
the unnecessary Provider wrapper — use XDSSideNavCollapseContext
directly in SideNavItem popover and test helpers.

CollapseContext file stays as .ts (no JSX needed).


* fix: move hooks before early return to prevent hooks violation

All useRef/useCallback hooks must run before the early return for
items without icons in collapsed mode. React requires the same
number of hooks every render.


* fix: use --color-popover for collapsed subnav popover surface


* refactor: extract collapsedItemStyles, move xdsClassName to item elements

- Extract shared collapsed item styles (navItemStyles.item + itemCollapsed +
  selected + disabled) into a single collapsedItemStyles variable
- Move xdsClassName('side-nav-item') from wrapper div to the actual item
  elements (button/link/trigger) where the styles are applied
- Wrapper divs now only get styles.root


* fix: add xdsClassName to expanded items, 4px popover offset

- Move xdsClassName('side-nav-item') to expanded link/button elements
  (was only on wrapper div)
- Add marginInlineStart: spacing-1 (4px) to popover surface for gap
  between trigger and popover


* fix: update --color-divider to --color-border after #698 merge

PR #698 renamed --color-divider to --color-border across the codebase.
Updated the popoverSurface borderColor to use the new token name.


---------
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants