Skip to content

feat(AppShell): add XDSAppShell component - #247

Merged
cixzhang merged 3 commits into
mainfrom
navi/feat/appshell
Feb 21, 2026
Merged

cixzhang merged 3 commits into
mainfrom
navi/feat/appshell

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Summary

Adds XDSAppShell — an application-level layout shell that provides the structural frame for an app: header, sidebar navigation, and main content area. Closes #185.

What's included

Component: XDSAppShell

A slot-based layout shell with the following API:

Prop Type Default Description
children ReactNode — Main content (rendered as <main>)
topNav ReactNode — Top navigation slot
pageNav ReactNode — Sidebar navigation slot
topBanner ReactNode — System-wide banner slot
height 'fill' | 'auto' 'fill' Height behavior
isSidebarCollapsed boolean — Controlled collapse
initialIsSidebarCollapsed boolean false Uncontrolled collapse
onSidebarCollapsedChange (boolean) => void — Collapse callback
sidebarBreakpoint 'sm' | 'md' | 'lg' | 'none' 'md' Auto-collapse breakpoint
sidebarWidth number 260 Sidebar width (px)
xstyle StyleXStyles — Style overrides

Features

  • Two height modes: fill (100dvh, independent scroll containers) and auto (page scroll, sticky navs)
  • Sidebar collapse: Controlled + uncontrolled patterns with ViewTransitions API
  • Responsive collapse: Auto-collapses below breakpoint, overlay sidebar on mobile with backdrop
  • Skip-to-content link: Visually hidden, shown on focus
  • Semantic HTML: <header>, <nav> (with aria-label), <main> (with role="main")
  • Escape to close: Mobile overlay closes on Escape key

Files

File Purpose
packages/core/src/AppShell/XDSAppShell.tsx Main component
packages/core/src/AppShell/XDSAppShell.test.tsx 23 unit tests
packages/core/src/AppShell/index.ts Exports
packages/core/src/AppShell/README.md Documentation
apps/storybook/stories/AppShell.stories.tsx 8 storybook stories
packages/core/src/index.ts Updated to export AppShell

Design decisions

  • Flat naming — no compound component pattern (XDSAppShell.Header)
  • No separation prop — slot components control their own visual treatment
  • Works without optional slots — no pageNav = no sidebar, no topNav = no header
  • ProseProvider/LayerProvider skipped — don't exist yet, easy to add later
  • ViewTransitions with fallback — checks for API availability, runs synchronously if unavailable

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

AppShell · View in Storybook
Metric Value
Bundle Size (ESM) 209B
Bundle Size (CJS) 317B
Lines of Code 244
Source Files 2
Complexity High (24)
Exports XDSAppShell
Props Count N/A
Has Tests Yes
Has Stories Yes

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 6.9KB 11.2KB 1.8KB

Accessibility Audit

Status: No accessibility violations detected.

Component Previews

Includes interactive hover previews as animated GIFs.

XDSAppShell

Default

Screenshot:

Default

Interaction Preview: (view video)

Default interaction

View in Storybook · core-xdsappshell--default

Header Only

Screenshot:

Header Only

View in Storybook · core-xdsappshell--header-only

With Banner

Screenshot:

With Banner

View in Storybook · core-xdsappshell--with-banner

Auto Height

Screenshot:

Auto Height

View in Storybook · core-xdsappshell--auto-height

Controlled Collapse

Screenshot:

Controlled Collapse

View in Storybook · core-xdsappshell--controlled-collapse

Initially Collapsed

Screenshot:

Initially Collapsed

View in Storybook · core-xdsappshell--initially-collapsed

Custom Side Nav Width

Screenshot:

Custom Side Nav Width

View in Storybook · core-xdsappshell--custom-side-nav-width

Content Only

Screenshot:

Content Only

View in Storybook · core-xdsappshell--content-only


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

export const Default: Story = {
render: () => (
<XDSAppShell
topNav={<MockTopNav title="My App" />}

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.

Use the actual XDSTopNav

topNav={<MockTopNav title="My App" />}
pageNav={<MockPageNav />}
topBanner={
<div {...stylex.props(styles.banner)}>

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.

Use the actual XDSBanner

),
};

export const ControlledCollapse: Story = {

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.

Hmm collapse controls need too much coordination between shell and nav

* Breakpoint below which sidebar auto-collapses.
* @default 'md'
*/
sidebarBreakpoint?: XDSAppShellBreakpoint;

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 have some inconsistent API language around sidebar vs page nav

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.

Maybe sideNav to reflect topNav below

/**
* Optional top banner slot for system-wide announcements.
*/
topBanner?: ReactNode;

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.

Could be just "banner"


const observer = new ResizeObserver(entries => {
for (const entry of entries) {
setHeaderHeight(entry.contentRect.height);

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 also need the banner height

// =========================================================================
const handleToggleCollapse = useCallback(() => {
const newValue = !isCollapsed;
withViewTransition(() => {

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.

Let's skip for now. We need React transition support and use ViewTransitions

cixzhang and others added 3 commits February 21, 2026 19:50
Application-level layout shell that provides the structural frame for an app:
header, sidebar navigation, and main content area.

Features:
- Slot-based API: topNav, pageNav, topBanner, children
- Two height modes: fill (100dvh, independent scroll) and auto (page scroll, sticky navs)
- Sidebar collapse: controlled + uncontrolled patterns
- Responsive sidebar collapse via sidebarBreakpoint prop
- Mobile overlay sidebar with backdrop
- Skip-to-content link (visually hidden, shown on focus)
- ViewTransitions API for sidebar animations (graceful fallback)
- Semantic HTML: header, nav, main with proper ARIA attributes
- Default sidebar width: 260px

Closes #185

Co-authored-by: Navi <[email protected]>
… sideNav, add real components to stories

- Rename sidebar→sideNav for consistent API language (pageNav→sideNav,
  isSidebarCollapsed→isSideNavCollapsed, sidebarBreakpoint→sideNavBreakpoint, etc.)
- Rename topBanner→banner
- Compose XDSLayout internally (XDSLayoutHeader, XDSLayoutPanel, XDSLayoutContent)
  instead of building custom grid/flex layout
- Replace MockTopNav with actual XDSTopNav in stories
- Add TODO for XDSBanner once component is available
- Remove CSS transitions — snap open/closed for now (ViewTransitions planned)
- Add comment explaining matchMedia is event-driven and does not over-trigger
- Remove unused header/banner height measurement (XDSLayout handles positioning)
- Add TODO for root providers (ThemeProvider, ProseProvider, LayerProvider)
- Simplify ControlledCollapse story with note about shell/nav coordination

Co-authored-by: Navi <[email protected]>
Replace the placeholder banner div in the WithBanner story with the
actual XDSBanner component (variant="section"), now that Banner has
been merged to main. Remove the unused banner style.

Co-authored-by: Navi <[email protected]>
@cixzhang
cixzhang merged commit b194179 into main Feb 21, 2026
9 checks passed
@cixzhang
cixzhang deleted the navi/feat/appshell branch February 21, 2026 20:22
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.

XDSAppShell

1 participant