Skip to content

feat(PageNav): add XDSPageNav component with header, items, and sections - #251

Merged
cixzhang merged 7 commits into
mainfrom
navi/feat/pagenav
Feb 22, 2026
Merged

cixzhang merged 7 commits into
mainfrom
navi/feat/pagenav

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Summary

Implements XDSPageNav v1 sidebar navigation component per #84.

Components

XDSPageNav

Container with five zones stacked vertically:

  • header (sticky) — typically XDSPageNavHeader
  • stickyContent (sticky) — buttons, pinned items
  • children (scrollable) — nav sections and items
  • footer — promo cards, etc.
  • footerIcons — icon buttons at bottom

XDSPageNavHeader

Product/suite/account header with smart interaction boundary logic:

  • No hrefs + menu → whole header is the popover trigger
  • titleHref only, no menu → whole header is one link
  • titleHref + supertitleHref, no menu → each is an independent link
  • menu + hrefs → links are independent <a>, chevron is the trigger

Composes useXDSPopover internally when menu is provided.

XDSPageNavItem

Navigation item with:

  • icon / selectedIcon (XDSIconType)
  • isSelected → accent background pill + aria-current="page"
  • isDisabled, href, onClick, endContent
  • Nesting via children + collapsible prop

XDSPageNavSection

Section grouping with:

  • title, subtitle, endContent
  • collapsible prop for expand/collapse
  • isHeaderHidden for visually hidden but accessible headers
  • role="group" with aria-labelledby

Also includes

Accessibility

  • <nav aria-label="Page navigation">
  • aria-current="page" on selected items
  • role="group" with aria-labelledby on sections
  • aria-expanded on collapsible triggers
  • Keyboard navigation support

Dependencies


Crafted with care by Navi

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

github-actions Bot commented Feb 21, 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.

New Components

PageNav · View in Storybook
Metric Value
Bundle Size (ESM) 613B
Bundle Size (CJS) 802B
Lines of Code 805
Source Files 5
Complexity Very High (73)
Exports XDSPageNav, XDSPageNavHeader, XDSPageNavItem, XDSPageNavSection
Props Count N/A
Has Tests Yes
Has Stories Yes

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 7.1KB 11.6KB 1.8KB

Accessibility Audit

Status: 1 accessibility violation(s) found.

XDSPageNav - 1 issue(s)
  • serious: Links must have discernible text
    • Rule: link-name

Component Previews

Includes interactive hover previews as animated GIFs.

XDSPageNav

Default

Screenshot:

Default

Interaction Preview: (view video)

Default interaction

View in Storybook · navigation-xdspagenav--default

Header with Menu

Screenshot:

Header with Menu

View in Storybook · navigation-xdspagenav--with-header-menu

Suite with Independent Links

Screenshot:

Suite with Independent Links

View in Storybook · navigation-xdspagenav--suite-header

Nested Items

Screenshot:

Nested Items

View in Storybook · navigation-xdspagenav--nested-items

With Footer Icons

Screenshot:

With Footer Icons

View in Storybook · navigation-xdspagenav--with-footer

Disabled Items

Screenshot:

Disabled Items

View in Storybook · navigation-xdspagenav--disabled-item

Hidden Section Header

Screenshot:

Hidden Section Header

View in Storybook · navigation-xdspagenav--hidden-section-header


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

cixzhang and others added 2 commits February 21, 2026 20:21
Implements XDSPageNav v1 sidebar navigation component per issue #84.

Components:
- XDSPageNav: Container with five zones (header, stickyContent, scrollable children, footer, footerIcons)
- XDSPageNavHeader: Product/suite/account header with smart interaction boundary logic and popover menu support
- XDSPageNavItem: Nav item with icon, selected state (aria-current=page), nesting, collapsible, endContent
- XDSPageNavSection: Section grouping with role=group, aria-labelledby, collapsible support

Also includes:
- useXDSCollapsible placeholder hook (until #187 lands)
- 49 unit tests covering all components and interactions
- Storybook stories with multiple variants
- README documentation

Co-authored-by: Navi <[email protected]>
zIndex: 1,
backgroundColor: colorVars['--color-surface'],
},
topContent: {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Does this need scroll margin to clear the header? Maybe they should be sticky together?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They already stick together — both header and topContent are inside the same stickyTop div, so they scroll as one unit. The scrollable area (flex: 1; overflowY: auto) starts below that sticky block, so no scroll-margin is needed.

lineHeightVars,
radiusVars,
} from '../theme/tokens.stylex';
import {useXDSPopover} from '../Layer/useXDSPopover';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can create a new issue for this but ideally we should avoid fetching layer resources unless we're sure to render them. Might need XDSPopover to accomplish this with React.lazy though. See XDSText for an example of this optimization.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tracked in #264. The tricky part is that useXDSPopover is a hook (not a component), so we can't React.lazy it directly. The approach would be to extract the menu-dependent rendering into a separate PageNavHeaderWithMenu component that can be lazy-loaded. Keeping it as a follow-up to avoid bloating this PR.

@cixzhang

Copy link
Copy Markdown
Contributor Author

Looking pretty good. Demonstrate selected icons using their filled variant if possible.

…ter, remove hasChevron

- Replace raw <button> elements with XDSButton (ghost variant) in stories
- Replace hardcoded icon sizes with XDSIcon component in stories
- Wrap header + topContent in a single sticky container so they stick together
- Make footer + footerIcons sticky to bottom with margin-top: auto
- Replace custom <a> link styles with XDSLink in header
- Remove hasChevron prop — chevron now auto-shown only when menu is provided
- Add TODO(#264) for lazy-loading popover resources

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

Copy link
Copy Markdown
Contributor Author

In the "Suite with Independent Links" example, the popover should still appear in the same position as when there are no links, so it should be aligned relative to the full page nav header. We may need to provide separate contextRef and triggerRefs to the popover API.

@cixzhang

Copy link
Copy Markdown
Contributor Author

The clickable/hover visual for the header is too flush with the nav container. It needs to be visually at least 4px spaced from the edges.

@cixzhang

Copy link
Copy Markdown
Contributor Author

Following the design mocks in #84, the section headings should use smaller text and not be in all caps.

- Section headings: remove uppercase/letter-spacing, use smaller text per design mocks (#84)
- Header hover: add 4px inset margin so interactive area isn't flush with container edges
- Suite header popover: anchor to full header div (not chevron) so popover position
  is consistent regardless of independent links
- Stories: add selectedIcon (filled variant) to all selected items
- Lazy-load popover deferred to #264 (requires component extraction, not just React.lazy)

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed all feedback — pushed 884e282.

Summary of changes:

  1. ✅ Selected icons — all stories now pass selectedIcon (filled variant) for selected items
  2. ✅ Suite header popover alignment — popover now anchors to the full header div via setRef/triggerRef, not the chevron button. Position is consistent regardless of independent links.
  3. ✅ Header hover inset — added interactiveInset style with marginInline/marginBlock of --spacing-1 (4px) so the hover/click visual is inset from container edges
  4. ✅ Section headings — removed textTransform: uppercase and letterSpacing, now uses smaller text per #84 design mocks
  5. ✅ Scroll margin / sticky — already addressed: header + topContent are wrapped in the same stickyTop div, so they stick together. No scroll-margin needed since the scrollable area starts below.
  6. ✅ Lazy-load popover — tracked in #264. Requires extracting the popover-dependent rendering into a lazy-loadable component (can't React.lazy a hook directly). Deferred to keep this PR focused.

@cixzhang

Copy link
Copy Markdown
Contributor Author

Replied to all inline threads and addressed the general comments:

  • Filled icon variants: All stories now use selectedIcon={HomeIconSolid} for selected items ✅
  • Suite popover alignment: Popover anchors to the full header div now, not the chevron. The setRef callback sets popover.triggerRef on the outer div whenever menu is provided, so the popover position is identical whether links are present or not. ✅
  • Header hover inset: Added interactiveInset style (marginInline/marginBlock: --spacing-1 = 4px). Applied to both the link and button variants of the interactive header. ✅
  • Section headings: Removed textTransform: uppercase and letterSpacing: 0.05em. Now matches XDSPageNav (sidebar navigation) #84 design mocks. ✅

The interactiveInset margins on the header <a> were overflowing the
block-level stickyTop container. Adding display:flex + flexDirection:column
properly contains the margins.
With stickyTop now using display:flex, the explicit width caused the
header to overflow past its inset margins. Flex children fill naturally.
Match DropdownMenu/Selector patterns:
- boxShadow with --color-shadow-elevation for card elevation
- borderRadius and backgroundColor on popover content
- minWidth: anchor-size(width) so popover is at least as wide as header
- marginBlockStart gap between trigger and popover
@cixzhang
cixzhang merged commit afb0f94 into main Feb 22, 2026
9 checks passed
@cixzhang
cixzhang deleted the navi/feat/pagenav branch February 25, 2026 15:29
cixzhang added a commit that referenced this pull request Apr 26, 2026
…ons (#251)

* feat(PageNav): add XDSPageNav component with header, items, and sections

Implements XDSPageNav v1 sidebar navigation component per issue #84.

Components:
- XDSPageNav: Container with five zones (header, stickyContent, scrollable children, footer, footerIcons)
- XDSPageNavHeader: Product/suite/account header with smart interaction boundary logic and popover menu support
- XDSPageNavItem: Nav item with icon, selected state (aria-current=page), nesting, collapsible, endContent
- XDSPageNavSection: Section grouping with role=group, aria-labelledby, collapsible support

Also includes:
- useXDSCollapsible placeholder hook (until #187 lands)
- 49 unit tests covering all components and interactions
- Storybook stories with multiple variants
- README documentation

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

* refactor(PageNav): rename stickyContent to topContent and remove collapsible (deferred to #187)

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

* refactor(PageNav): address review — use XDSButton/XDSLink, sticky footer, remove hasChevron

- Replace raw <button> elements with XDSButton (ghost variant) in stories
- Replace hardcoded icon sizes with XDSIcon component in stories
- Wrap header + topContent in a single sticky container so they stick together
- Make footer + footerIcons sticky to bottom with margin-top: auto
- Replace custom <a> link styles with XDSLink in header
- Remove hasChevron prop — chevron now auto-shown only when menu is provided
- Add TODO(#264) for lazy-loading popover resources

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

* fix(PageNav): address review feedback

- Section headings: remove uppercase/letter-spacing, use smaller text per design mocks (#84)
- Header hover: add 4px inset margin so interactive area isn't flush with container edges
- Suite header popover: anchor to full header div (not chevron) so popover position
  is consistent regardless of independent links
- Stories: add selectedIcon (filled variant) to all selected items
- Lazy-load popover deferred to #264 (requires component extraction, not just React.lazy)

* fix(PageNav): add flex to stickyTop to contain header inset margins

The interactiveInset margins on the header <a> were overflowing the
block-level stickyTop container. Adding display:flex + flexDirection:column
properly contains the margins.

* fix(PageNav): remove width:100% from header root

With stickyTop now using display:flex, the explicit width caused the
header to overflow past its inset margins. Flex children fill naturally.

* fix(PageNav): add elevation shadow and min-width to header popover

Match DropdownMenu/Selector patterns:
- boxShadow with --color-shadow-elevation for card elevation
- borderRadius and backgroundColor on popover content
- minWidth: anchor-size(width) so popover is at least as wide as header
- marginBlockStart gap between trigger and popover

---------

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
…ons (#251)

* feat(PageNav): add XDSPageNav component with header, items, and sections

Implements XDSPageNav v1 sidebar navigation component per issue #84.

Components:
- XDSPageNav: Container with five zones (header, stickyContent, scrollable children, footer, footerIcons)
- XDSPageNavHeader: Product/suite/account header with smart interaction boundary logic and popover menu support
- XDSPageNavItem: Nav item with icon, selected state (aria-current=page), nesting, collapsible, endContent
- XDSPageNavSection: Section grouping with role=group, aria-labelledby, collapsible support

Also includes:
- useXDSCollapsible placeholder hook (until #187 lands)
- 49 unit tests covering all components and interactions
- Storybook stories with multiple variants
- README documentation


* refactor(PageNav): rename stickyContent to topContent and remove collapsible (deferred to #187)


* refactor(PageNav): address review — use XDSButton/XDSLink, sticky footer, remove hasChevron

- Replace raw <button> elements with XDSButton (ghost variant) in stories
- Replace hardcoded icon sizes with XDSIcon component in stories
- Wrap header + topContent in a single sticky container so they stick together
- Make footer + footerIcons sticky to bottom with margin-top: auto
- Replace custom <a> link styles with XDSLink in header
- Remove hasChevron prop — chevron now auto-shown only when menu is provided
- Add TODO(#264) for lazy-loading popover resources


* fix(PageNav): address review feedback

- Section headings: remove uppercase/letter-spacing, use smaller text per design mocks (#84)
- Header hover: add 4px inset margin so interactive area isn't flush with container edges
- Suite header popover: anchor to full header div (not chevron) so popover position
  is consistent regardless of independent links
- Stories: add selectedIcon (filled variant) to all selected items
- Lazy-load popover deferred to #264 (requires component extraction, not just React.lazy)

* fix(PageNav): add flex to stickyTop to contain header inset margins

The interactiveInset margins on the header <a> were overflowing the
block-level stickyTop container. Adding display:flex + flexDirection:column
properly contains the margins.

* fix(PageNav): remove width:100% from header root

With stickyTop now using display:flex, the explicit width caused the
header to overflow past its inset margins. Flex children fill naturally.

* fix(PageNav): add elevation shadow and min-width to header popover

Match DropdownMenu/Selector patterns:
- boxShadow with --color-shadow-elevation for card elevation
- borderRadius and backgroundColor on popover content
- minWidth: anchor-size(width) so popover is at least as wide as header
- marginBlockStart gap between trigger and popover

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