Skip to content

feat(SideNav): collapsible sidebar with isCollapsible prop - #641

Merged
cixzhang merged 11 commits into
mainfrom
navi/feat/sidenav-collapse
Mar 17, 2026
Merged

cixzhang merged 11 commits into
mainfrom
navi/feat/sidenav-collapse

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Summary

Adds collapsible sidebar support to XDSSideNav. Collapse is owned entirely by the SideNav — not the AppShell.

API

// Basic — just one prop, collapse button auto-rendered
<XDSSideNav isCollapsible>
  <XDSSideNavSection title="Main">
    <XDSSideNavItem label="Dashboard" icon={DashboardIcon} />
  </XDSSideNavSection>
</XDSSideNav>

// Controlled
<XDSSideNav isCollapsible isCollapsed={collapsed} onCollapsedChange={setCollapsed}>
  ...
</XDSSideNav>

// Start collapsed
<XDSSideNav isCollapsible defaultIsCollapsed>
  ...
</XDSSideNav>

Architecture

  • Collapse state lives on XDSSideNav — not AppShell. Each sidenav manages its own collapse independently (supports multiple sidenavs on a page).
  • SideNavCollapseContext provides { isCollapsed, toggle, isCollapsible } to all descendants.
  • Each child component decides its own collapsed behavior:
    • XDSSideNavItem: icon-only when collapsed (hides label, endContent, children). Hidden when no icon. Tooltip with label on hover (sibling mode via anchorRef).
    • XDSSideNavSection: hides section headers when collapsed.
    • XDSSideNavHeading: shows icon-only when collapsed. Hidden if no icon.
    • XDSSideNavCollapseButton: uses XDSButton variant=ghost. Auto-rendered in footer when isCollapsible.

Breaking Changes

Removed non-functional AppShell collapse props:

  • isSideNavCollapsed
  • onSideNavCollapsedChange
  • defaultIsSideNavCollapsed

These never worked properly. Collapse is now isCollapsible on XDSSideNav.

Visual Treatment

  • Expanded: 260px width, full nav items with labels
  • Collapsed: 52px width, icon-only items, centered heading icon, vertical footer icons, collapse button at bottom-left
  • Footer uses column-reverse when collapsed so collapse button stays at bottom

Vibe Test

Compared 4 approaches across 7 prompts. Approach D (hybrid: isCollapsible + composable XDSSideNavCollapseButton) won with 98% avg confidence and 0 workarounds. See #565 comment for full results.

Shell Lab

  • Config panel reorganized into AppShell / SideNav / TopNav / Mobile Nav sections
  • Collapsible toggle in SideNav section
  • Nav items with icons (Dashboard, Messages, Settings, Projects, Documentation)
  • Items without icons (API Reference, Support) hide when collapsed

Test plan

  • All tests passing
  • Tested in Shell Lab across all variants and height modes

Part of #565

Implement Approach D (hybrid) from the sidenav collapse vibe test:

- Add isCollapsible prop to XDSSideNav — enables collapse behavior
  and provides SideNavCollapseContext to descendants
- Add XDSSideNavCollapseButton — composable toggle button that
  reads collapse state from context (inside sidenav) or via ref
  (outside sidenav, TODO)
- Supports controlled (isCollapsed + onCollapsedChange) and
  uncontrolled (defaultIsCollapsed) modes on XDSSideNav
- Button accepts label/children for customization
- Uses getIcon('chevronLeft') from icon registry
- xdsClassName('side-nav-collapse-button') for theming

Vibe test results (7 prompts):
- D scored 98% avg confidence, 0 workarounds on 6/7 prompts
- Beats C (isCollapsible only) on external toggle placement
  (no state management needed — use sideNavRef)
- Beats A (explicit wiring) on simple cases (one prop vs useState + 3 props)

Part of #565
Remove broken collapse props from AppShell:
- isSideNavCollapsed
- onSideNavCollapsedChange
- defaultIsSideNavCollapsed
- handleToggleCollapse

Collapse is now entirely a SideNav concern:
- SideNav provides SideNavCollapseContext when isCollapsible is true
- XDSSideNavItem reads context: hides items without icons when collapsed,
  shows icon-only for items with icons (hides label, endContent, children)
- XDSSideNavSection hides section headers when collapsed

AppShell changes:
- showSideNavInline no longer checks isCollapsed (sidenav always inline
  above breakpoint, handles its own collapsed visual)
- Default mobile nav uses its own open/close state instead of collapse state
- Responsive breakpoint tracking simplified (just tracks isBelowBreakpoint)

Tests updated to remove collapse prop references.

Part of #565
…er icons

SideNav collapsed visual treatment:
- Root narrows to 52px when collapsed
- SideNavHeading: shows icon-only when collapsed, hides if no icon
- Footer icons stack vertically when collapsed, border removed
- Header area stays visible (heading handles its own collapsed visual)
- topContent and footer content hide when collapsed
- Footer always renders when collapsible (collapse button stays visible)

Part of #565
- SideNav auto-renders XDSSideNavCollapseButton in footer when isCollapsible
- Collapse button stays bottom-left: separate footerRow with justify-between
- Collapsed heading: reduced padding (2px), centered icon
- SideNav owns its own width (260px expanded, 52px collapsed)
- AppShell no longer sets panel width — SideNav controls it
- Shell lab: isCollapsible toggle, auto-placed collapse button

Part of #565
…lapse props

Config panel now organized into clear sections:
- AppShell (variant, height, banner)
- SideNav (show, heading, super/subheading, content, footer, collapsible, breakpoint)
- TopNav (show, heading, alignment, style)
- Mobile Nav (mode, side)

Sections separated by XDSDivider for visual clarity.

Removed old AppShell collapse props from config:
- defaultCollapsed, controlledCollapse, isCollapsed
- collapseProps wiring
Collapse is now entirely controlled by isCollapsible on XDSSideNav.
Collapsed state visual treatment:
- SideNavItem: icon-only when collapsed (hides label, endContent, children)
- SideNavItem: centered icon with reduced padding in collapsed mode
- SideNavItem: hidden (display:none) when no icon in collapsed mode
- SideNavItem: tooltip with label on hover when collapsed (sibling mode via anchorRef)
- SideNavSection: hides section headers when collapsed
- SideNavHeading: shows icon-only when collapsed, hidden if no icon
- SideNavCollapseButton: uses XDSButton variant=ghost (not raw button)
- Footer: column-reverse when collapsed, collapse button at bottom

Structural approach:
- SideNav does NOT hide its layout zones (stickyTop, scrollable, stickyBottom)
- Each child component reads collapse context and decides its own behavior
- No hooks violations — all hooks called before early returns

Shell lab:
- Added icons to Dashboard, Messages, Settings, Projects, Documentation
- API Reference and Support have no icons (hide when collapsed)
- Config panel reorganized: AppShell, SideNav, TopNav, Mobile Nav sections
- Removed old AppShell collapse props (defaultCollapsed, controlledCollapse, isCollapsed)

Part of #565
@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

AppShell · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 625B N/A
Lines of Code N/A 370 -
Complexity N/A Very High (44) -
SideNav · View in Storybook · 🆕 XDSSideNavCollapseButton
Metric Before After Delta
Bundle Size (ESM) N/A 913B N/A
Lines of Code N/A 1031 -
Complexity N/A Very High (104) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 9.5KB 15.3KB 2.4KB

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

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)

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

- SideNavCollapseContext → XDSSideNavCollapseContext
- useSideNavCollapse → useXDSSideNavCollapse
- Renamed file SideNavCollapseContext.ts → XDSSideNavCollapseContext.ts

Per API-Conventions wiki: public hooks use useXDS prefix.
…bject}

Replace 5 separate collapse props with a single `collapsible` prop:

Before (5 props):
  <XDSSideNav isCollapsible isCollapsed={v} onCollapsedChange={set}
    defaultIsCollapsed hasCollapseButton={false}>

After (1 prop):
  <XDSSideNav collapsible>
  <XDSSideNav collapsible={{ defaultIsCollapsed: true }}>
  <XDSSideNav collapsible={{ isCollapsed: v, onCollapsedChange: set }}>
  <XDSSideNav collapsible={{ hasButton: false, isCollapsed: v, onCollapsedChange: set }}>

Validated via vibe test (5 prompts × 4 API shapes):
- `collapsible={bool|obj}` won on simple case (reads like English)
- No naming stutter (vs isCollapsible={{ isCollapsed }})
- Co-located config (vs 5 scattered flat props)

Also adds v0.0.5 codemod:
- Migrates isCollapsible + related props → collapsible
- Removes deprecated AppShell props (isSideNavCollapsed, etc.)
- 7 tests covering all transform cases

Shell lab updated with external toggle demo (TopNav location).

Part of #565
@cixzhang
cixzhang merged commit b4bf46f into main Mar 17, 2026
11 checks passed
@cixzhang cixzhang mentioned this pull request Mar 17, 2026
52 of 55 tasks
@cixzhang
cixzhang deleted the navi/feat/sidenav-collapse branch March 17, 2026 03:54
josephfarina added a commit that referenced this pull request Mar 17, 2026
SideNav: Add collapsible prop, XDSSideNavCollapseButton component,
and collapse-related features/notes to all three translations
(docs, docsZh, docsDense). These were added in #641 without doc updates.

AppShell: Add missing contentPadding to docsDense propDescriptions.
Button: Add missing isDisabled to docsDense propDescriptions.

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Apr 26, 2026
* feat(SideNav): add isCollapsible prop and XDSSideNavCollapseButton

Implement Approach D (hybrid) from the sidenav collapse vibe test:

- Add isCollapsible prop to XDSSideNav — enables collapse behavior
  and provides SideNavCollapseContext to descendants
- Add XDSSideNavCollapseButton — composable toggle button that
  reads collapse state from context (inside sidenav) or via ref
  (outside sidenav, TODO)
- Supports controlled (isCollapsed + onCollapsedChange) and
  uncontrolled (defaultIsCollapsed) modes on XDSSideNav
- Button accepts label/children for customization
- Uses getIcon('chevronLeft') from icon registry
- xdsClassName('side-nav-collapse-button') for theming

Vibe test results (7 prompts):
- D scored 98% avg confidence, 0 workarounds on 6/7 prompts
- Beats C (isCollapsible only) on external toggle placement
  (no state management needed — use sideNavRef)
- Beats A (explicit wiring) on simple cases (one prop vs useState + 3 props)

Part of #565

* refactor: move collapse from AppShell to SideNav, add collapsed visuals

Remove broken collapse props from AppShell:
- isSideNavCollapsed
- onSideNavCollapsedChange
- defaultIsSideNavCollapsed
- handleToggleCollapse

Collapse is now entirely a SideNav concern:
- SideNav provides SideNavCollapseContext when isCollapsible is true
- XDSSideNavItem reads context: hides items without icons when collapsed,
  shows icon-only for items with icons (hides label, endContent, children)
- XDSSideNavSection hides section headers when collapsed

AppShell changes:
- showSideNavInline no longer checks isCollapsed (sidenav always inline
  above breakpoint, handles its own collapsed visual)
- Default mobile nav uses its own open/close state instead of collapse state
- Responsive breakpoint tracking simplified (just tracks isBelowBreakpoint)

Tests updated to remove collapse prop references.

Part of #565

* feat: collapsed visual — 52px width, icon-only heading, vertical footer icons

SideNav collapsed visual treatment:
- Root narrows to 52px when collapsed
- SideNavHeading: shows icon-only when collapsed, hides if no icon
- Footer icons stack vertically when collapsed, border removed
- Header area stays visible (heading handles its own collapsed visual)
- topContent and footer content hide when collapsed
- Footer always renders when collapsible (collapse button stays visible)

Part of #565

* fix: auto-place collapse button, centered heading, SideNav owns width

- SideNav auto-renders XDSSideNavCollapseButton in footer when isCollapsible
- Collapse button stays bottom-left: separate footerRow with justify-between
- Collapsed heading: reduced padding (2px), centered icon
- SideNav owns its own width (260px expanded, 52px collapsed)
- AppShell no longer sets panel width — SideNav controls it
- Shell lab: isCollapsible toggle, auto-placed collapse button

Part of #565

* fix: remove extra quote in shell lab

* fix: actually render the collapse button in SideNav footer

* fix: footer layout — column-reverse for collapsed, simpler footerIcons rendering

* refactor(shell-lab): reorganize config panel, remove old AppShell collapse props

Config panel now organized into clear sections:
- AppShell (variant, height, banner)
- SideNav (show, heading, super/subheading, content, footer, collapsible, breakpoint)
- TopNav (show, heading, alignment, style)
- Mobile Nav (mode, side)

Sections separated by XDSDivider for visual clarity.

Removed old AppShell collapse props from config:
- defaultCollapsed, controlledCollapse, isCollapsed
- collapseProps wiring
Collapse is now entirely controlled by isCollapsible on XDSSideNav.

* feat(SideNav): collapsed visuals, tooltips, icons, config panel cleanup

Collapsed state visual treatment:
- SideNavItem: icon-only when collapsed (hides label, endContent, children)
- SideNavItem: centered icon with reduced padding in collapsed mode
- SideNavItem: hidden (display:none) when no icon in collapsed mode
- SideNavItem: tooltip with label on hover when collapsed (sibling mode via anchorRef)
- SideNavSection: hides section headers when collapsed
- SideNavHeading: shows icon-only when collapsed, hidden if no icon
- SideNavCollapseButton: uses XDSButton variant=ghost (not raw button)
- Footer: column-reverse when collapsed, collapse button at bottom

Structural approach:
- SideNav does NOT hide its layout zones (stickyTop, scrollable, stickyBottom)
- Each child component reads collapse context and decides its own behavior
- No hooks violations — all hooks called before early returns

Shell lab:
- Added icons to Dashboard, Messages, Settings, Projects, Documentation
- API Reference and Support have no icons (hide when collapsed)
- Config panel reorganized: AppShell, SideNav, TopNav, Mobile Nav sections
- Removed old AppShell collapse props (defaultCollapsed, controlledCollapse, isCollapsed)

Part of #565

* refactor: prefix context and hook with XDS per API conventions

- SideNavCollapseContext → XDSSideNavCollapseContext
- useSideNavCollapse → useXDSSideNavCollapse
- Renamed file SideNavCollapseContext.ts → XDSSideNavCollapseContext.ts

Per API-Conventions wiki: public hooks use useXDS prefix.

* refactor(SideNav): unify collapse props into collapsible={boolean | object}

Replace 5 separate collapse props with a single `collapsible` prop:

Before (5 props):
  <XDSSideNav isCollapsible isCollapsed={v} onCollapsedChange={set}
    defaultIsCollapsed hasCollapseButton={false}>

After (1 prop):
  <XDSSideNav collapsible>
  <XDSSideNav collapsible={{ defaultIsCollapsed: true }}>
  <XDSSideNav collapsible={{ isCollapsed: v, onCollapsedChange: set }}>
  <XDSSideNav collapsible={{ hasButton: false, isCollapsed: v, onCollapsedChange: set }}>

Validated via vibe test (5 prompts × 4 API shapes):
- `collapsible={bool|obj}` won on simple case (reads like English)
- No naming stutter (vs isCollapsible={{ isCollapsed }})
- Co-located config (vs 5 scattered flat props)

Also adds v0.0.5 codemod:
- Migrates isCollapsible + related props → collapsible
- Removes deprecated AppShell props (isSideNavCollapsed, etc.)
- 7 tests covering all transform cases

Shell lab updated with external toggle demo (TopNav location).

Part of #565
cixzhang added a commit that referenced this pull request Jun 21, 2026
* feat(SideNav): add isCollapsible prop and XDSSideNavCollapseButton

Implement Approach D (hybrid) from the sidenav collapse vibe test:

- Add isCollapsible prop to XDSSideNav — enables collapse behavior
  and provides SideNavCollapseContext to descendants
- Add XDSSideNavCollapseButton — composable toggle button that
  reads collapse state from context (inside sidenav) or via ref
  (outside sidenav, TODO)
- Supports controlled (isCollapsed + onCollapsedChange) and
  uncontrolled (defaultIsCollapsed) modes on XDSSideNav
- Button accepts label/children for customization
- Uses getIcon('chevronLeft') from icon registry
- xdsClassName('side-nav-collapse-button') for theming

Vibe test results (7 prompts):
- D scored 98% avg confidence, 0 workarounds on 6/7 prompts
- Beats C (isCollapsible only) on external toggle placement
  (no state management needed — use sideNavRef)
- Beats A (explicit wiring) on simple cases (one prop vs useState + 3 props)

Part of #565

* refactor: move collapse from AppShell to SideNav, add collapsed visuals

Remove broken collapse props from AppShell:
- isSideNavCollapsed
- onSideNavCollapsedChange
- defaultIsSideNavCollapsed
- handleToggleCollapse

Collapse is now entirely a SideNav concern:
- SideNav provides SideNavCollapseContext when isCollapsible is true
- XDSSideNavItem reads context: hides items without icons when collapsed,
  shows icon-only for items with icons (hides label, endContent, children)
- XDSSideNavSection hides section headers when collapsed

AppShell changes:
- showSideNavInline no longer checks isCollapsed (sidenav always inline
  above breakpoint, handles its own collapsed visual)
- Default mobile nav uses its own open/close state instead of collapse state
- Responsive breakpoint tracking simplified (just tracks isBelowBreakpoint)

Tests updated to remove collapse prop references.

Part of #565

* feat: collapsed visual — 52px width, icon-only heading, vertical footer icons

SideNav collapsed visual treatment:
- Root narrows to 52px when collapsed
- SideNavHeading: shows icon-only when collapsed, hides if no icon
- Footer icons stack vertically when collapsed, border removed
- Header area stays visible (heading handles its own collapsed visual)
- topContent and footer content hide when collapsed
- Footer always renders when collapsible (collapse button stays visible)

Part of #565

* fix: auto-place collapse button, centered heading, SideNav owns width

- SideNav auto-renders XDSSideNavCollapseButton in footer when isCollapsible
- Collapse button stays bottom-left: separate footerRow with justify-between
- Collapsed heading: reduced padding (2px), centered icon
- SideNav owns its own width (260px expanded, 52px collapsed)
- AppShell no longer sets panel width — SideNav controls it
- Shell lab: isCollapsible toggle, auto-placed collapse button

Part of #565

* fix: remove extra quote in shell lab

* fix: actually render the collapse button in SideNav footer

* fix: footer layout — column-reverse for collapsed, simpler footerIcons rendering

* refactor(shell-lab): reorganize config panel, remove old AppShell collapse props

Config panel now organized into clear sections:
- AppShell (variant, height, banner)
- SideNav (show, heading, super/subheading, content, footer, collapsible, breakpoint)
- TopNav (show, heading, alignment, style)
- Mobile Nav (mode, side)

Sections separated by XDSDivider for visual clarity.

Removed old AppShell collapse props from config:
- defaultCollapsed, controlledCollapse, isCollapsed
- collapseProps wiring
Collapse is now entirely controlled by isCollapsible on XDSSideNav.

* feat(SideNav): collapsed visuals, tooltips, icons, config panel cleanup

Collapsed state visual treatment:
- SideNavItem: icon-only when collapsed (hides label, endContent, children)
- SideNavItem: centered icon with reduced padding in collapsed mode
- SideNavItem: hidden (display:none) when no icon in collapsed mode
- SideNavItem: tooltip with label on hover when collapsed (sibling mode via anchorRef)
- SideNavSection: hides section headers when collapsed
- SideNavHeading: shows icon-only when collapsed, hidden if no icon
- SideNavCollapseButton: uses XDSButton variant=ghost (not raw button)
- Footer: column-reverse when collapsed, collapse button at bottom

Structural approach:
- SideNav does NOT hide its layout zones (stickyTop, scrollable, stickyBottom)
- Each child component reads collapse context and decides its own behavior
- No hooks violations — all hooks called before early returns

Shell lab:
- Added icons to Dashboard, Messages, Settings, Projects, Documentation
- API Reference and Support have no icons (hide when collapsed)
- Config panel reorganized: AppShell, SideNav, TopNav, Mobile Nav sections
- Removed old AppShell collapse props (defaultCollapsed, controlledCollapse, isCollapsed)

Part of #565

* refactor: prefix context and hook with XDS per API conventions

- SideNavCollapseContext → XDSSideNavCollapseContext
- useSideNavCollapse → useXDSSideNavCollapse
- Renamed file SideNavCollapseContext.ts → XDSSideNavCollapseContext.ts

Per API-Conventions wiki: public hooks use useXDS prefix.

* refactor(SideNav): unify collapse props into collapsible={boolean | object}

Replace 5 separate collapse props with a single `collapsible` prop:

Before (5 props):
  <XDSSideNav isCollapsible isCollapsed={v} onCollapsedChange={set}
    defaultIsCollapsed hasCollapseButton={false}>

After (1 prop):
  <XDSSideNav collapsible>
  <XDSSideNav collapsible={{ defaultIsCollapsed: true }}>
  <XDSSideNav collapsible={{ isCollapsed: v, onCollapsedChange: set }}>
  <XDSSideNav collapsible={{ hasButton: false, isCollapsed: v, onCollapsedChange: set }}>

Validated via vibe test (5 prompts × 4 API shapes):
- `collapsible={bool|obj}` won on simple case (reads like English)
- No naming stutter (vs isCollapsible={{ isCollapsed }})
- Co-located config (vs 5 scattered flat props)

Also adds v0.0.5 codemod:
- Migrates isCollapsible + related props → collapsible
- Removes deprecated AppShell props (isSideNavCollapsed, etc.)
- 7 tests covering all transform cases

Shell lab updated with external toggle demo (TopNav location).

Part of #565
cixzhang added a commit that referenced this pull request Jun 21, 2026
* feat(SideNav): add isCollapsible prop and XDSSideNavCollapseButton

Implement Approach D (hybrid) from the sidenav collapse vibe test:

- Add isCollapsible prop to XDSSideNav — enables collapse behavior
  and provides SideNavCollapseContext to descendants
- Add XDSSideNavCollapseButton — composable toggle button that
  reads collapse state from context (inside sidenav) or via ref
  (outside sidenav, TODO)
- Supports controlled (isCollapsed + onCollapsedChange) and
  uncontrolled (defaultIsCollapsed) modes on XDSSideNav
- Button accepts label/children for customization
- Uses getIcon('chevronLeft') from icon registry
- xdsClassName('side-nav-collapse-button') for theming

Vibe test results (7 prompts):
- D scored 98% avg confidence, 0 workarounds on 6/7 prompts
- Beats C (isCollapsible only) on external toggle placement
  (no state management needed — use sideNavRef)
- Beats A (explicit wiring) on simple cases (one prop vs useState + 3 props)

Part of #565

* refactor: move collapse from AppShell to SideNav, add collapsed visuals

Remove broken collapse props from AppShell:
- isSideNavCollapsed
- onSideNavCollapsedChange
- defaultIsSideNavCollapsed
- handleToggleCollapse

Collapse is now entirely a SideNav concern:
- SideNav provides SideNavCollapseContext when isCollapsible is true
- XDSSideNavItem reads context: hides items without icons when collapsed,
  shows icon-only for items with icons (hides label, endContent, children)
- XDSSideNavSection hides section headers when collapsed

AppShell changes:
- showSideNavInline no longer checks isCollapsed (sidenav always inline
  above breakpoint, handles its own collapsed visual)
- Default mobile nav uses its own open/close state instead of collapse state
- Responsive breakpoint tracking simplified (just tracks isBelowBreakpoint)

Tests updated to remove collapse prop references.

Part of #565

* feat: collapsed visual — 52px width, icon-only heading, vertical footer icons

SideNav collapsed visual treatment:
- Root narrows to 52px when collapsed
- SideNavHeading: shows icon-only when collapsed, hides if no icon
- Footer icons stack vertically when collapsed, border removed
- Header area stays visible (heading handles its own collapsed visual)
- topContent and footer content hide when collapsed
- Footer always renders when collapsible (collapse button stays visible)

Part of #565

* fix: auto-place collapse button, centered heading, SideNav owns width

- SideNav auto-renders XDSSideNavCollapseButton in footer when isCollapsible
- Collapse button stays bottom-left: separate footerRow with justify-between
- Collapsed heading: reduced padding (2px), centered icon
- SideNav owns its own width (260px expanded, 52px collapsed)
- AppShell no longer sets panel width — SideNav controls it
- Shell lab: isCollapsible toggle, auto-placed collapse button

Part of #565

* fix: remove extra quote in shell lab

* fix: actually render the collapse button in SideNav footer

* fix: footer layout — column-reverse for collapsed, simpler footerIcons rendering

* refactor(shell-lab): reorganize config panel, remove old AppShell collapse props

Config panel now organized into clear sections:
- AppShell (variant, height, banner)
- SideNav (show, heading, super/subheading, content, footer, collapsible, breakpoint)
- TopNav (show, heading, alignment, style)
- Mobile Nav (mode, side)

Sections separated by XDSDivider for visual clarity.

Removed old AppShell collapse props from config:
- defaultCollapsed, controlledCollapse, isCollapsed
- collapseProps wiring
Collapse is now entirely controlled by isCollapsible on XDSSideNav.

* feat(SideNav): collapsed visuals, tooltips, icons, config panel cleanup

Collapsed state visual treatment:
- SideNavItem: icon-only when collapsed (hides label, endContent, children)
- SideNavItem: centered icon with reduced padding in collapsed mode
- SideNavItem: hidden (display:none) when no icon in collapsed mode
- SideNavItem: tooltip with label on hover when collapsed (sibling mode via anchorRef)
- SideNavSection: hides section headers when collapsed
- SideNavHeading: shows icon-only when collapsed, hidden if no icon
- SideNavCollapseButton: uses XDSButton variant=ghost (not raw button)
- Footer: column-reverse when collapsed, collapse button at bottom

Structural approach:
- SideNav does NOT hide its layout zones (stickyTop, scrollable, stickyBottom)
- Each child component reads collapse context and decides its own behavior
- No hooks violations — all hooks called before early returns

Shell lab:
- Added icons to Dashboard, Messages, Settings, Projects, Documentation
- API Reference and Support have no icons (hide when collapsed)
- Config panel reorganized: AppShell, SideNav, TopNav, Mobile Nav sections
- Removed old AppShell collapse props (defaultCollapsed, controlledCollapse, isCollapsed)

Part of #565

* refactor: prefix context and hook with XDS per API conventions

- SideNavCollapseContext → XDSSideNavCollapseContext
- useSideNavCollapse → useXDSSideNavCollapse
- Renamed file SideNavCollapseContext.ts → XDSSideNavCollapseContext.ts

Per API-Conventions wiki: public hooks use useXDS prefix.

* refactor(SideNav): unify collapse props into collapsible={boolean | object}

Replace 5 separate collapse props with a single `collapsible` prop:

Before (5 props):
  <XDSSideNav isCollapsible isCollapsed={v} onCollapsedChange={set}
    defaultIsCollapsed hasCollapseButton={false}>

After (1 prop):
  <XDSSideNav collapsible>
  <XDSSideNav collapsible={{ defaultIsCollapsed: true }}>
  <XDSSideNav collapsible={{ isCollapsed: v, onCollapsedChange: set }}>
  <XDSSideNav collapsible={{ hasButton: false, isCollapsed: v, onCollapsedChange: set }}>

Validated via vibe test (5 prompts × 4 API shapes):
- `collapsible={bool|obj}` won on simple case (reads like English)
- No naming stutter (vs isCollapsible={{ isCollapsed }})
- Co-located config (vs 5 scattered flat props)

Also adds v0.0.5 codemod:
- Migrates isCollapsible + related props → collapsible
- Removes deprecated AppShell props (isSideNavCollapsed, etc.)
- 7 tests covering all transform cases

Shell lab updated with external toggle demo (TopNav location).

Part of #565
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.

1 participant