Skip to content

P4 (parts 1-3,5): dual-emit astryx-* CSS classes, data-attrs + sibling astryx.css - #2928

Merged
ejhammond merged 7 commits into
xds-unprefix-integrationfrom
navi/refactor/p4-source-rename
Jun 19, 2026
Merged

ejhammond merged 7 commits into
xds-unprefix-integrationfrom
navi/refactor/p4-source-rename

Conversation

@ejhammond

Copy link
Copy Markdown
Contributor

What

The non-rename portions of P4 — the dual-emit compat surfaces that let consumers adopt astryx-* while xds-* keeps working. The big source rename (part 4) is intentionally a separate follow-up PR.

(1) CSS class dual-emit

xdsThemeProps() now emits both base classes: astryx-button xds-button primary sm (via stableClassName + legacyStableClassName). Variant tokens unchanged.

(2) Population A theme data-attr dual-emit + @scope

Consumer-observable theme attributes dual-emit, and BOTH theme-CSS generators scope to either prefix:

  • XDSTheme.tsx: documentElement gets data-astryx-theme + data-xds-theme; injected <style> markers use naming helpers.
  • XDSMediaTheme.tsx: dual-emits data-astryx-media + data-xds-media.
  • reset.css: :where([data-astryx-media], [data-xds-media]).
  • generateThemeRules.ts (runtime) + build-theme.mjs (static) — new themeScopeStart/THEME_SCOPE_TO/mediaSelector/componentClassSelector helpers build dual-prefix @scope start/limit, on-media surfaces, and .astryx-/.xds- component overrides. Kept in SYNC.

(3) Population B internal data-attrs

Renamed in place to data-astryx-* (token/dictation/scrolling/trigger-anchor/highlight/edge-comp/toast-fallback) — internal plumbing, write+read co-located, no consumer contract.

(5) Sibling astryx.css

Build emits dist/astryx.css (md5-identical to xds.css) + ./astryx.css package export. Layer name stays @layer xds-base per P0 decision 4.

Not in this PR (P4 part 4)

The 320-file source rename (XDS*.tsx → bare canonical) + compat-generator inversion + 101 barrel regenerations. That's the largest, highest-risk change and gets its own staged, reviewed PR.

Validation

Full @xds/core vitest suite: 3152/3152 pass. Updated the ~11 exact-match class/scope assertions + 3 FormLayout snapshots to the dual form (all other toContain/toHaveClass assertions stayed green since xds-* is still present).

Package scope stays @xds/*; layer names unchanged. CI note: integration-branch PRs don't auto-run CI; validated locally. (A pre-existing DateRangePreset TS2308 from the integration base — fixed on main by #2925/#2926, awaiting sync — blocks the full tsc build but is unrelated to these changes; vitest validates independently.)

xdsThemeProps() now emits BOTH the new astryx-* and legacy xds-* base class
(e.g. 'astryx-button xds-button primary sm') so new consumer CSS can target
astryx-* while existing xds-* selectors keep matching through the compat
window. Variant tokens (primary, sm, level-1) are unchanged. Uses the
stableClassName/legacyStableClassName helpers from the naming module.

Updates xdsThemeProps.test.ts assertions to the dual-class form. Component
tests that use toContain/toHaveClass/querySelector on xds-* keep passing
(the xds-* class is still present); exact-match assertions (P6 scope) will be
swept separately.

Part of P4 (source-of-record renames); CSS dual-emit sub-part.
…pshots

- xdsThemeProps.test.ts combined assertion -> dual-class form
- regenerate 3 XDSFormLayout snapshots (astryx-form-layout prepended to
  xds-form-layout; otherwise byte-identical)

Full core suite: 3152/3152 pass with the class dual-emit.
Renames the self-contained internal data attributes in place (no dual-emit
per P0 decision 2 — these are not consumer-observable contracts):
data-xds-token{,-id,-value}, data-xds-dictation-interim, data-xds-scrolling,
data-xds-trigger-anchor, data-xds-highlight-{dynamic,styles}, data-xds-edge-comp,
data-xds-toast-fallback -> data-astryx-*.

Each attr's write (setAttribute/JSX) and read (querySelector/stylex :is()/:has())
sites are co-located within the same component module and moved together, so
there is no contract break. 14 source + test files; 150 tests across
Chat/CodeBlock/Layout/Toast pass.

Deliberately EXCLUDED (not in this unit):
- data-xds-theme / -theme-prose / -media / -id — Population A, dual-emit +
  @scope-coupled (theme CSS generation). Handled in the data-attr dual-emit unit.
- data-xds-syntax-theme — read by generated syntax CSS at runtime (coupled).
The CSS build now writes dist/astryx.css with byte-identical content to
dist/xds.css (verified: same md5), and package.json exports './astryx.css'.
Gives consumers a forward-named import path ('@xds/core/astryx.css') during
the compat window. Layer name stays @layer xds-base until final cutover (P10).

dist/ is gitignored (build artifact); committing the build script, the
astryx.css.d.ts type stub, and the package export only.
Population A (consumer-observable theme attributes) now dual-emit both the new
astryx-* and legacy xds-* forms, and the theme-CSS generators (both the runtime
generateThemeRules.ts and the static build-theme.mjs path) scope to either form.

Writers:
- XDSTheme.tsx: documentElement gets both data-astryx-theme + data-xds-theme;
  injected <style> markers use the naming helpers (cleanup query matches).
- XDSMediaTheme.tsx: dual-emits data-astryx-media + data-xds-media.
- reset.css: color-scheme rule matches :where([data-astryx-media], [data-xds-media]).

Generators (kept in SYNC):
- generateThemeRules.ts: new themeScopeStart()/THEME_SCOPE_TO/mediaSelector()/
  componentClassSelector() build dual-prefix selector-lists for @scope start,
  @scope limit, on-media surfaces, and .astryx-/.xds- component overrides.
- build-theme.mjs: mirrors the same dual-prefix helpers on the static path.

Layer names unchanged (xds-base/xds-theme) per P0 decision 4. Package scope
still @xds/*. Next: source rename + generator inversion (part 4).
generateThemeRules + onMediaTokens tests asserted the old single-prefix CSS
shape. Update to the dual form: @scope ([data-astryx-theme=x], [data-xds-theme=x])
to ([data-astryx-theme], [data-xds-theme]); on-media :is([data-*-media]) :is(.astryx-*, .xds-*);
reset.css :where([data-astryx-media], [data-xds-media]) regexes. All 232 theme
tests pass.
@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

@ejhammond must be a member of the Meta Open Source team on Vercel to deploy.
- Click here to add @ejhammond to the team.
- If you initiated this build, request access.

Learn more about collaboration on Vercel and other options here.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 18, 2026
apps/sandbox/.claude/CLAUDE.md is a build-regenerated agent-docs artifact that
got swept into the part-1 fixup commit. Restore to the integration baseline —
it's out of scope for the P4 dual-emit work.
@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
xds-sandbox Error Error Jun 19, 2026 12:19am

Request Review

@ejhammond
ejhammond merged commit 3eb6bf0 into xds-unprefix-integration Jun 19, 2026
2 of 3 checks passed
ejhammond added a commit that referenced this pull request Jun 19, 2026
…g astryx.css (#2928)

* P4 (part 1): dual-emit astryx-* + xds-* base classes in xdsThemeProps

xdsThemeProps() now emits BOTH the new astryx-* and legacy xds-* base class
(e.g. 'astryx-button xds-button primary sm') so new consumer CSS can target
astryx-* while existing xds-* selectors keep matching through the compat
window. Variant tokens (primary, sm, level-1) are unchanged. Uses the
stableClassName/legacyStableClassName helpers from the naming module.

Updates xdsThemeProps.test.ts assertions to the dual-class form. Component
tests that use toContain/toHaveClass/querySelector on xds-* keep passing
(the xds-* class is still present); exact-match assertions (P6 scope) will be
swept separately.

Part of P4 (source-of-record renames); CSS dual-emit sub-part.

* P4 (part 1 fixup): update remaining class assertions + FormLayout snapshots

- xdsThemeProps.test.ts combined assertion -> dual-class form
- regenerate 3 XDSFormLayout snapshots (astryx-form-layout prepended to
  xds-form-layout; otherwise byte-identical)

Full core suite: 3152/3152 pass with the class dual-emit.

* P4 (part 3): rename internal Population B data-attrs to data-astryx-*

Renames the self-contained internal data attributes in place (no dual-emit
per P0 decision 2 — these are not consumer-observable contracts):
data-xds-token{,-id,-value}, data-xds-dictation-interim, data-xds-scrolling,
data-xds-trigger-anchor, data-xds-highlight-{dynamic,styles}, data-xds-edge-comp,
data-xds-toast-fallback -> data-astryx-*.

Each attr's write (setAttribute/JSX) and read (querySelector/stylex :is()/:has())
sites are co-located within the same component module and moved together, so
there is no contract break. 14 source + test files; 150 tests across
Chat/CodeBlock/Layout/Toast pass.

Deliberately EXCLUDED (not in this unit):
- data-xds-theme / -theme-prose / -media / -id — Population A, dual-emit +
  @scope-coupled (theme CSS generation). Handled in the data-attr dual-emit unit.
- data-xds-syntax-theme — read by generated syntax CSS at runtime (coupled).

* P4 (part 5): emit sibling astryx.css alongside xds.css

The CSS build now writes dist/astryx.css with byte-identical content to
dist/xds.css (verified: same md5), and package.json exports './astryx.css'.
Gives consumers a forward-named import path ('@xds/core/astryx.css') during
the compat window. Layer name stays @layer xds-base until final cutover (P10).

dist/ is gitignored (build artifact); committing the build script, the
astryx.css.d.ts type stub, and the package export only.

* P4 (part 2): dual-emit Population A theme data-attrs + @scope selectors

Population A (consumer-observable theme attributes) now dual-emit both the new
astryx-* and legacy xds-* forms, and the theme-CSS generators (both the runtime
generateThemeRules.ts and the static build-theme.mjs path) scope to either form.

Writers:
- XDSTheme.tsx: documentElement gets both data-astryx-theme + data-xds-theme;
  injected <style> markers use the naming helpers (cleanup query matches).
- XDSMediaTheme.tsx: dual-emits data-astryx-media + data-xds-media.
- reset.css: color-scheme rule matches :where([data-astryx-media], [data-xds-media]).

Generators (kept in SYNC):
- generateThemeRules.ts: new themeScopeStart()/THEME_SCOPE_TO/mediaSelector()/
  componentClassSelector() build dual-prefix selector-lists for @scope start,
  @scope limit, on-media surfaces, and .astryx-/.xds- component overrides.
- build-theme.mjs: mirrors the same dual-prefix helpers on the static path.

Layer names unchanged (xds-base/xds-theme) per P0 decision 4. Package scope
still @xds/*. Next: source rename + generator inversion (part 4).

* P4 (part 2 fixup): update theme-CSS tests for dual-prefix @scope output

generateThemeRules + onMediaTokens tests asserted the old single-prefix CSS
shape. Update to the dual form: @scope ([data-astryx-theme=x], [data-xds-theme=x])
to ([data-astryx-theme], [data-xds-theme]); on-media :is([data-*-media]) :is(.astryx-*, .xds-*);
reset.css :where([data-astryx-media], [data-xds-media]) regexes. All 232 theme
tests pass.

* Drop accidentally-committed regenerated CLAUDE.md

apps/sandbox/.claude/CLAUDE.md is a build-regenerated agent-docs artifact that
got swept into the part-1 fixup commit. Restore to the integration baseline —
it's out of scope for the P4 dual-emit work.

(cherry picked from commit 3eb6bf0)
@cixzhang
cixzhang deleted the navi/refactor/p4-source-rename branch June 21, 2026 17:03

This branch had an error being deployed

1 failed deployment
Preview — 69766338 Deployed Jun 19, 2026 by vercel[bot]
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