Skip to content

feat: CSS layer ordering for dist path theming - #806

Merged
cixzhang merged 18 commits into
mainfrom
navi/feat/css-layer-ordering
Mar 22, 2026
Merged

cixzhang merged 18 commits into
mainfrom
navi/feat/css-layer-ordering

Conversation

@cixzhang

@cixzhang cixzhang commented Mar 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Establishes CSS layer ordering for the dist path so theme overrides win over component styles by cascade, not specificity. Also migrates the sandbox app to use the dist path with a full Theme Editor page.

CSS Layer Model

@layer xds.reset, xds.core.base, xds.theme;
  1. xds.reset — reset styles (lowest priority)
  2. xds.core.base — component styles from StyleX
  3. xds.theme — theme token + component overrides (wins over base)

Product/consumer styles sit unlayered and naturally win over all XDS layers — no !important needed.

Sandbox: Dist Path + Theme Editor

Migrates the sandbox from importing source to importing from the dist path (@xds/core/Button, etc.). Adds a Theme Editor page with:

  • Live token editing (colors, spacing, radius, typography)
  • Type scale preview with configurable base + ratio
  • Component gallery (buttons, badges, banners, inputs, dialogs, tables, etc.)
  • Theme export as defineTheme code
  • Theme switching (default, neutral, brutalist)

Changes

Core infrastructure:

  • reset.css: @layer reset → @layer xds.reset
  • storybook/main.ts: layer declaration updated
  • Verified: build-css.mjs uses @layer xds.core.base, build-theme.mjs uses @layer xds.theme, XDSTheme.tsx runtime uses @layer xds.theme — all correct, no changes needed

Sandbox:

  • layout.tsx: uses XDSAppShell from dist with layer imports
  • shell-lab/page.tsx: shell configuration playground
  • theme-editor/page.tsx: full theme editor with live preview
  • All component usages updated to current API (Banner container, numeric SpacingStep, onOpenChange, typography.scale, etc.)

@cixzhang
cixzhang requested a review from josephfarina as a code owner March 21, 2026 21:50
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 21, 2026
@github-actions

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

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 602.3KB 635.5KB 117.6KB

Accessibility Audit

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

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)
XDSCodeBlock - 2 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 8/13 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
  • 🟠 serious: Ensure elements that have scrollable content are accessible by keyboard
    • Rule: scrollable-region-focusable · Affects 1/13 stories · Learn more
    • WCAG: 2.1.1, 2.1.3 (Level A)
XDSCodeEditor - 3 issue(s)
  • 🟠 serious: Ensure every ARIA input field has an accessible name
    • Rule: aria-input-field-name · Affects 7/7 stories · Learn more
    • WCAG: 4.1.2 (Level A)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 3/7 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
  • 🟠 serious: Ensure elements that have scrollable content are accessible by keyboard
    • Rule: scrollable-region-focusable · Affects 1/7 stories · Learn more
    • WCAG: 2.1.1, 2.1.3 (Level A)
XDSHeading - 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)
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

@cixzhang
cixzhang marked this pull request as draft March 21, 2026 22:37
@cixzhang
cixzhang force-pushed the navi/feat/css-layer-ordering branch from aa64cb4 to ea0cb44 Compare March 21, 2026 23:25
@cixzhang cixzhang changed the title feat: unified CSS layer ordering (xds.reset, xds.core.base, xds.theme) feat: CSS layer ordering for dist path theming Mar 21, 2026
@cixzhang
cixzhang force-pushed the navi/feat/css-layer-ordering branch 2 times, most recently from e940fc0 to 6919354 Compare March 22, 2026 00:34
@cixzhang
cixzhang marked this pull request as ready for review March 22, 2026 03:05
@cixzhang
cixzhang marked this pull request as draft March 22, 2026 03:09
@cixzhang
cixzhang force-pushed the navi/feat/css-layer-ordering branch from 8233214 to f941f9b Compare March 22, 2026 04:16
@cixzhang
cixzhang force-pushed the navi/feat/css-layer-ordering branch from f941f9b to 2942729 Compare March 22, 2026 07:10
cixzhang pushed a commit that referenced this pull request Mar 22, 2026
With splitting: false, tsup inlines all code into each entry point.
Two fixes needed:

1. Barrel index.ts files need 'use client' since they're the entry points
2. Post-build script (fix-use-client-dist.mjs) moves the directive to
   line 1 in dist files — tsup/babel may insert helpers before it

Fixes sandbox build failure in #806.
cixzhang added a commit that referenced this pull request Mar 22, 2026
With splitting: false, tsup inlines all code into each entry point.
Two fixes needed:

1. Barrel index.ts files need 'use client' since they're the entry points
2. Post-build script (fix-use-client-dist.mjs) moves the directive to
   line 1 in dist files — tsup/babel may insert helpers before it

Fixes sandbox build failure in #806.

Co-authored-by: Navi <[email protected]>
@cixzhang
cixzhang force-pushed the navi/feat/css-layer-ordering branch from 2942729 to 91e6751 Compare March 22, 2026 08:36
Navi added 11 commits March 22, 2026 16:05
Establishes a 3-layer CSS model so theme overrides win over base
component styles without !important:

1. xds-reset — reset styles (lowest priority)
2. xds-base — component styles from StyleX build
3. xds-theme — theme token + component overrides

Uses hyphenated names (xds-base, not xds.base) to avoid CSS sub-layer
nesting — @layer xds.theme would be a sub-layer of @layer xds, which
has lower priority than its parent. Flat layers with declaration order
give us the right cascade.

Storybook switches to dist path (requires yarn build first) so the
layer model is exercised. Brutalist theme adds a borderRadius override
on button (9999px pill) for visual verification — if layers work,
brutalist buttons are pill-shaped; if broken, they stay sharp.

Changes:
- reset.css: @layer reset → @layer xds-reset
- build-css.mjs: @layer xds → @layer xds-base
- build-theme.mjs: @layer xds.theme → @layer xds-theme
- XDSTheme.tsx: runtime injection uses @layer xds-theme
- Storybook: dist path + layer order declaration
- Brutalist: pill button override for visual verification
- Sandbox: layer model documentation
Establishes a 3-layer CSS model so theme overrides win over base
component styles without !important:

1. xds-reset — reset styles (lowest priority)
2. xds-base — component styles from StyleX build
3. xds-theme — theme token + component overrides

Uses hyphenated names (xds-base, not xds.base) because CSS
@layer xds.theme would be a sub-layer of @layer xds — sub-layers
have lower priority than their parent's direct rules.

Changes:
- reset.css: @layer reset → @layer xds-reset
- build-css.mjs: @layer xds → @layer xds-base
- build-theme.mjs: @layer xds.theme → @layer xds-theme
- XDSTheme.tsx: runtime injection uses @layer xds-theme
- Brutalist: pill button override for visual verification
- Sandbox: layer model documentation

Storybook stays on source path (preserves autodocs).
Verified via local yarn build + storybook with dist — pill buttons
confirm theme layer wins over base.
Replace hand-rolled sidebar with XDSAppShell + XDSSideNav.
Add theme selector (default/neutral/brutalist) and dark mode toggle
to the sidebar, making the sandbox a proper verification environment
for the CSS layer model.

- Providers: theme context with selection + mode state
- SandboxNav: XDSSideNav with page links + theme/mode controls
- SandboxTopNav: XDSTopNav header
- Layout: XDSAppShell wrapping sandbox pages
- Import all three theme CSS files (scoped via @scope, only active applies)
- Remove hand-rolled Sidebar.tsx
Sandbox now uses pre-built dist CSS for @xds/core and themes:
- PostCSS only compiles sandbox page files (not core/theme source)
- useCSSLayers: false for page styles (unlayered = consumer behavior)
- next.config: stop transpiling @xds/core (uses dist)

Move ThemeEditor from Storybook to sandbox:
- New page at /pages/theme-editor/
- Storybook is now component docs only
- Sandbox is for theme experimentation + layer verification

Add Theme Editor to sandbox nav.
…tInput value

Batch fix for stale API usages in theme-editor sandbox page:
- Slider: minValue/maxValue → min/max
- Dialog: onClose → onOpenChange, remove title prop
- Stack: gap='md' → gap={3} (SpacingStep is numeric)
- TextInput in dialog: add required value prop
Navi added 7 commits March 22, 2026 16:05
Built core + themes locally with split DTS, ran tsc on sandbox — found
and fixed the last type error (TypographyCategoryValue cast).

All previous fixes from CI iterations are included in the rebase:
- padding='lg' → padding={4}
- getRowKey removed
- Badge variant/sentiment → valid variants
- TextInput/Switch/Checkbox value props
- Slider min/max, Dialog onOpenChange
- Stack direction, Avatar sizes
- typeScale → typography.scale
- Typed callback params
- Banner variant=educational → status=info

tsc --noEmit passes clean.
@cixzhang
cixzhang force-pushed the navi/feat/css-layer-ordering branch from 8da161b to c507ff9 Compare March 22, 2026 16:07
@cixzhang
cixzhang marked this pull request as ready for review March 22, 2026 17:20
@cixzhang
cixzhang merged commit a553b97 into main Mar 22, 2026
13 checks passed
josephfarina added a commit that referenced this pull request Mar 23, 2026
reset.css was renamed from @layer reset to @layer xds-reset in #806,
but the Storybook layer order declaration still referenced the old name.
Since xds-reset wasn't in the declaration, CSS treated it as undeclared
and gave it highest priority, causing the reset's border-width: 0 to
stomp component borders (TextInput, Selector, etc.).

Also adds xds-theme to the layer order so runtime theme injection
slots into the right position.
@cixzhang
cixzhang deleted the navi/feat/css-layer-ordering branch April 9, 2026 14:31
cixzhang added a commit that referenced this pull request Apr 26, 2026
With splitting: false, tsup inlines all code into each entry point.
Two fixes needed:

1. Barrel index.ts files need 'use client' since they're the entry points
2. Post-build script (fix-use-client-dist.mjs) moves the directive to
   line 1 in dist files — tsup/babel may insert helpers before it

Fixes sandbox build failure in #806.

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Apr 26, 2026
* feat: CSS layer ordering for dist path theming

Establishes a 3-layer CSS model so theme overrides win over base
component styles without !important:

1. xds-reset — reset styles (lowest priority)
2. xds-base — component styles from StyleX build
3. xds-theme — theme token + component overrides

Uses hyphenated names (xds-base, not xds.base) to avoid CSS sub-layer
nesting — @layer xds.theme would be a sub-layer of @layer xds, which
has lower priority than its parent. Flat layers with declaration order
give us the right cascade.

Storybook switches to dist path (requires yarn build first) so the
layer model is exercised. Brutalist theme adds a borderRadius override
on button (9999px pill) for visual verification — if layers work,
brutalist buttons are pill-shaped; if broken, they stay sharp.

Changes:
- reset.css: @layer reset → @layer xds-reset
- build-css.mjs: @layer xds → @layer xds-base
- build-theme.mjs: @layer xds.theme → @layer xds-theme
- XDSTheme.tsx: runtime injection uses @layer xds-theme
- Storybook: dist path + layer order declaration
- Brutalist: pill button override for visual verification
- Sandbox: layer model documentation

* feat: CSS layer ordering for dist path theming

Establishes a 3-layer CSS model so theme overrides win over base
component styles without !important:

1. xds-reset — reset styles (lowest priority)
2. xds-base — component styles from StyleX build
3. xds-theme — theme token + component overrides

Uses hyphenated names (xds-base, not xds.base) because CSS
@layer xds.theme would be a sub-layer of @layer xds — sub-layers
have lower priority than their parent's direct rules.

Changes:
- reset.css: @layer reset → @layer xds-reset
- build-css.mjs: @layer xds → @layer xds-base
- build-theme.mjs: @layer xds.theme → @layer xds-theme
- XDSTheme.tsx: runtime injection uses @layer xds-theme
- Brutalist: pill button override for visual verification
- Sandbox: layer model documentation

Storybook stays on source path (preserves autodocs).
Verified via local yarn build + storybook with dist — pill buttons
confirm theme layer wins over base.

* feat(sandbox): AppShell + theme switching for dist path verification

Replace hand-rolled sidebar with XDSAppShell + XDSSideNav.
Add theme selector (default/neutral/brutalist) and dark mode toggle
to the sidebar, making the sandbox a proper verification environment
for the CSS layer model.

- Providers: theme context with selection + mode state
- SandboxNav: XDSSideNav with page links + theme/mode controls
- SandboxTopNav: XDSTopNav header
- Layout: XDSAppShell wrapping sandbox pages
- Import all three theme CSS files (scoped via @scope, only active applies)
- Remove hand-rolled Sidebar.tsx

* feat(sandbox): switch to dist path + move ThemeEditor from Storybook

Sandbox now uses pre-built dist CSS for @xds/core and themes:
- PostCSS only compiles sandbox page files (not core/theme source)
- useCSSLayers: false for page styles (unlayered = consumer behavior)
- next.config: stop transpiling @xds/core (uses dist)

Move ThemeEditor from Storybook to sandbox:
- New page at /pages/theme-editor/
- Storybook is now component docs only
- Sandbox is for theme experimentation + layer verification

Add Theme Editor to sandbox nav.

* fix(sandbox): use numeric SpacingStep for Card padding

* fix(sandbox): remove getRowKey (not in XDSTable API)

* fix(sandbox): fix Badge variant/sentiment props to match current API

* fix(sandbox): fix TextInput value, Switch/Checkbox isSelected→value

* fix(sandbox): fix Slider min/max, Dialog onOpenChange, Stack gap, TextInput value

Batch fix for stale API usages in theme-editor sandbox page:
- Slider: minValue/maxValue → min/max
- Dialog: onClose → onOpenChange, remove title prop
- Stack: gap='md' → gap={3} (SpacingStep is numeric)
- TextInput in dialog: add required value prop

* fix(sandbox): close XDSDialog JSX tag

* fix(sandbox): Avatar size sm/md/lg → small/medium/large, remove Table size

* fix(sandbox): add direction to XDSStack

* fix(sandbox): Banner variant=educational → status=info, action → endContent, Badge accent → info

* fix(sandbox): add required label to ProgressBar

* fix(sandbox): type allDefaults as Record<string, string>

* fix(sandbox): typeScale → typography.scale in defineTheme call

* fix(sandbox): type all callback params, fix typeScale → typography.scale

* fix(sandbox): fix all type errors in theme-editor

Built core + themes locally with split DTS, ran tsc on sandbox — found
and fixed the last type error (TypographyCategoryValue cast).

All previous fixes from CI iterations are included in the rebase:
- padding='lg' → padding={4}
- getRowKey removed
- Badge variant/sentiment → valid variants
- TextInput/Switch/Checkbox value props
- Slider min/max, Dialog onOpenChange
- Stack direction, Avatar sizes
- typeScale → typography.scale
- Typed callback params
- Banner variant=educational → status=info

tsc --noEmit passes clean.

---------

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
With splitting: false, tsup inlines all code into each entry point.
Two fixes needed:

1. Barrel index.ts files need 'use client' since they're the entry points
2. Post-build script (fix-use-client-dist.mjs) moves the directive to
   line 1 in dist files — tsup/babel may insert helpers before it

Fixes sandbox build failure in #806.

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
* feat: CSS layer ordering for dist path theming

Establishes a 3-layer CSS model so theme overrides win over base
component styles without !important:

1. xds-reset — reset styles (lowest priority)
2. xds-base — component styles from StyleX build
3. xds-theme — theme token + component overrides

Uses hyphenated names (xds-base, not xds.base) to avoid CSS sub-layer
nesting — @layer xds.theme would be a sub-layer of @layer xds, which
has lower priority than its parent. Flat layers with declaration order
give us the right cascade.

Storybook switches to dist path (requires yarn build first) so the
layer model is exercised. Brutalist theme adds a borderRadius override
on button (9999px pill) for visual verification — if layers work,
brutalist buttons are pill-shaped; if broken, they stay sharp.

Changes:
- reset.css: @layer reset → @layer xds-reset
- build-css.mjs: @layer xds → @layer xds-base
- build-theme.mjs: @layer xds.theme → @layer xds-theme
- XDSTheme.tsx: runtime injection uses @layer xds-theme
- Storybook: dist path + layer order declaration
- Brutalist: pill button override for visual verification
- Sandbox: layer model documentation

* feat: CSS layer ordering for dist path theming

Establishes a 3-layer CSS model so theme overrides win over base
component styles without !important:

1. xds-reset — reset styles (lowest priority)
2. xds-base — component styles from StyleX build
3. xds-theme — theme token + component overrides

Uses hyphenated names (xds-base, not xds.base) because CSS
@layer xds.theme would be a sub-layer of @layer xds — sub-layers
have lower priority than their parent's direct rules.

Changes:
- reset.css: @layer reset → @layer xds-reset
- build-css.mjs: @layer xds → @layer xds-base
- build-theme.mjs: @layer xds.theme → @layer xds-theme
- XDSTheme.tsx: runtime injection uses @layer xds-theme
- Brutalist: pill button override for visual verification
- Sandbox: layer model documentation

Storybook stays on source path (preserves autodocs).
Verified via local yarn build + storybook with dist — pill buttons
confirm theme layer wins over base.

* feat(sandbox): AppShell + theme switching for dist path verification

Replace hand-rolled sidebar with XDSAppShell + XDSSideNav.
Add theme selector (default/neutral/brutalist) and dark mode toggle
to the sidebar, making the sandbox a proper verification environment
for the CSS layer model.

- Providers: theme context with selection + mode state
- SandboxNav: XDSSideNav with page links + theme/mode controls
- SandboxTopNav: XDSTopNav header
- Layout: XDSAppShell wrapping sandbox pages
- Import all three theme CSS files (scoped via @scope, only active applies)
- Remove hand-rolled Sidebar.tsx

* feat(sandbox): switch to dist path + move ThemeEditor from Storybook

Sandbox now uses pre-built dist CSS for @xds/core and themes:
- PostCSS only compiles sandbox page files (not core/theme source)
- useCSSLayers: false for page styles (unlayered = consumer behavior)
- next.config: stop transpiling @xds/core (uses dist)

Move ThemeEditor from Storybook to sandbox:
- New page at /pages/theme-editor/
- Storybook is now component docs only
- Sandbox is for theme experimentation + layer verification

Add Theme Editor to sandbox nav.

* fix(sandbox): use numeric SpacingStep for Card padding

* fix(sandbox): remove getRowKey (not in XDSTable API)

* fix(sandbox): fix Badge variant/sentiment props to match current API

* fix(sandbox): fix TextInput value, Switch/Checkbox isSelected→value

* fix(sandbox): fix Slider min/max, Dialog onOpenChange, Stack gap, TextInput value

Batch fix for stale API usages in theme-editor sandbox page:
- Slider: minValue/maxValue → min/max
- Dialog: onClose → onOpenChange, remove title prop
- Stack: gap='md' → gap={3} (SpacingStep is numeric)
- TextInput in dialog: add required value prop

* fix(sandbox): close XDSDialog JSX tag

* fix(sandbox): Avatar size sm/md/lg → small/medium/large, remove Table size

* fix(sandbox): add direction to XDSStack

* fix(sandbox): Banner variant=educational → status=info, action → endContent, Badge accent → info

* fix(sandbox): add required label to ProgressBar

* fix(sandbox): type allDefaults as Record<string, string>

* fix(sandbox): typeScale → typography.scale in defineTheme call

* fix(sandbox): type all callback params, fix typeScale → typography.scale

* fix(sandbox): fix all type errors in theme-editor

Built core + themes locally with split DTS, ran tsc on sandbox — found
and fixed the last type error (TypographyCategoryValue cast).

All previous fixes from CI iterations are included in the rebase:
- padding='lg' → padding={4}
- getRowKey removed
- Badge variant/sentiment → valid variants
- TextInput/Switch/Checkbox value props
- Slider min/max, Dialog onOpenChange
- Stack direction, Avatar sizes
- typeScale → typography.scale
- Typed callback params
- Banner variant=educational → status=info

tsc --noEmit passes clean.

---------

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
With splitting: false, tsup inlines all code into each entry point.
Two fixes needed:

1. Barrel index.ts files need 'use client' since they're the entry points
2. Post-build script (fix-use-client-dist.mjs) moves the directive to
   line 1 in dist files — tsup/babel may insert helpers before it

Fixes sandbox build failure in #806.
cixzhang added a commit that referenced this pull request Jun 21, 2026
* feat: CSS layer ordering for dist path theming

Establishes a 3-layer CSS model so theme overrides win over base
component styles without !important:

1. xds-reset — reset styles (lowest priority)
2. xds-base — component styles from StyleX build
3. xds-theme — theme token + component overrides

Uses hyphenated names (xds-base, not xds.base) to avoid CSS sub-layer
nesting — @layer xds.theme would be a sub-layer of @layer xds, which
has lower priority than its parent. Flat layers with declaration order
give us the right cascade.

Storybook switches to dist path (requires yarn build first) so the
layer model is exercised. Brutalist theme adds a borderRadius override
on button (9999px pill) for visual verification — if layers work,
brutalist buttons are pill-shaped; if broken, they stay sharp.

Changes:
- reset.css: @layer reset → @layer xds-reset
- build-css.mjs: @layer xds → @layer xds-base
- build-theme.mjs: @layer xds.theme → @layer xds-theme
- XDSTheme.tsx: runtime injection uses @layer xds-theme
- Storybook: dist path + layer order declaration
- Brutalist: pill button override for visual verification
- Sandbox: layer model documentation

* feat: CSS layer ordering for dist path theming

Establishes a 3-layer CSS model so theme overrides win over base
component styles without !important:

1. xds-reset — reset styles (lowest priority)
2. xds-base — component styles from StyleX build
3. xds-theme — theme token + component overrides

Uses hyphenated names (xds-base, not xds.base) because CSS
@layer xds.theme would be a sub-layer of @layer xds — sub-layers
have lower priority than their parent's direct rules.

Changes:
- reset.css: @layer reset → @layer xds-reset
- build-css.mjs: @layer xds → @layer xds-base
- build-theme.mjs: @layer xds.theme → @layer xds-theme
- XDSTheme.tsx: runtime injection uses @layer xds-theme
- Brutalist: pill button override for visual verification
- Sandbox: layer model documentation

Storybook stays on source path (preserves autodocs).
Verified via local yarn build + storybook with dist — pill buttons
confirm theme layer wins over base.

* feat(sandbox): AppShell + theme switching for dist path verification

Replace hand-rolled sidebar with XDSAppShell + XDSSideNav.
Add theme selector (default/neutral/brutalist) and dark mode toggle
to the sidebar, making the sandbox a proper verification environment
for the CSS layer model.

- Providers: theme context with selection + mode state
- SandboxNav: XDSSideNav with page links + theme/mode controls
- SandboxTopNav: XDSTopNav header
- Layout: XDSAppShell wrapping sandbox pages
- Import all three theme CSS files (scoped via @scope, only active applies)
- Remove hand-rolled Sidebar.tsx

* feat(sandbox): switch to dist path + move ThemeEditor from Storybook

Sandbox now uses pre-built dist CSS for @xds/core and themes:
- PostCSS only compiles sandbox page files (not core/theme source)
- useCSSLayers: false for page styles (unlayered = consumer behavior)
- next.config: stop transpiling @xds/core (uses dist)

Move ThemeEditor from Storybook to sandbox:
- New page at /pages/theme-editor/
- Storybook is now component docs only
- Sandbox is for theme experimentation + layer verification

Add Theme Editor to sandbox nav.

* fix(sandbox): use numeric SpacingStep for Card padding

* fix(sandbox): remove getRowKey (not in XDSTable API)

* fix(sandbox): fix Badge variant/sentiment props to match current API

* fix(sandbox): fix TextInput value, Switch/Checkbox isSelected→value

* fix(sandbox): fix Slider min/max, Dialog onOpenChange, Stack gap, TextInput value

Batch fix for stale API usages in theme-editor sandbox page:
- Slider: minValue/maxValue → min/max
- Dialog: onClose → onOpenChange, remove title prop
- Stack: gap='md' → gap={3} (SpacingStep is numeric)
- TextInput in dialog: add required value prop

* fix(sandbox): close XDSDialog JSX tag

* fix(sandbox): Avatar size sm/md/lg → small/medium/large, remove Table size

* fix(sandbox): add direction to XDSStack

* fix(sandbox): Banner variant=educational → status=info, action → endContent, Badge accent → info

* fix(sandbox): add required label to ProgressBar

* fix(sandbox): type allDefaults as Record<string, string>

* fix(sandbox): typeScale → typography.scale in defineTheme call

* fix(sandbox): type all callback params, fix typeScale → typography.scale

* fix(sandbox): fix all type errors in theme-editor

Built core + themes locally with split DTS, ran tsc on sandbox — found
and fixed the last type error (TypographyCategoryValue cast).

All previous fixes from CI iterations are included in the rebase:
- padding='lg' → padding={4}
- getRowKey removed
- Badge variant/sentiment → valid variants
- TextInput/Switch/Checkbox value props
- Slider min/max, Dialog onOpenChange
- Stack direction, Avatar sizes
- typeScale → typography.scale
- Typed callback params
- Banner variant=educational → status=info

tsc --noEmit passes clean.

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