Skip to content

feat(cli): add rebrand-xds-css-namespace codemod (P2) - #2883

Merged
ejhammond merged 1 commit into
navi/feat/p2-codemodsfrom
navi/feat/p2-css-codemod
Jun 17, 2026
Merged

ejhammond merged 1 commit into
navi/feat/p2-codemodsfrom
navi/feat/p2-css-codemod

Conversation

@ejhammond

Copy link
Copy Markdown
Contributor

Summary

Second P2 (codemods) transform for the XDS → Astryx prefix migration (paste P2380608025). Rebrands consumer override CSS and markup from the legacy xds DOM namespace to astryx:

.xds-button           ->  .astryx-button
[data-xds-theme=...]  ->  [data-astryx-theme=...]
data-xds-media="dark"  ->  data-astryx-media="dark"   (JSX/markup)
className="xds-card"   ->  className="astryx-card"

Pairs with the JS-identifier codemod (#2879) — together they cover the consumer-side rewrites P9 runs per app.

Stacked on #2879 (navi/feat/p2-codemods) — this PR targets that branch so the diff shows only the CSS codemod. Both share the v0.0.15 manifest. Merge #2879 first (or retarget this to integration once #2879 lands).

Safety boundaries (per P0)

During compat the library dual-emits both class names and the theme/media data attributes, so flipping selectors to astryx is always safe. The codemod deliberately leaves untouched:

  • @layer xds-base / @layer xds-theme — a CSS layer can't be aliased or dual-emitted, so layer names stay xds-* through the whole compat window and only rebrand at final cutover. Rewriting them would desync the consumer from the library's emitted layer (the split-brain hazard).
  • --xds-* custom properties — these use the inverted read fallback (feat(core): rebrand component padding vars with inverted-fallback compat (P3c, part 4 — final) #2882) and need per-case human review (stale vs intentional override), handled separately in P9.

Implementation

String-based transform (CSS isn't JS-parseable), mirroring the existing migrate-theme-selectors-to-data-attrs codemod. Three patterns: data-xds-* attributes, .xds-* class selectors, and bare xds-* class tokens in className strings (with a LAYER_NAMES guard preserving xds-base/xds-theme).

Registered in v0.0.15 as optional; run via:

xds upgrade --codemod rebrand-xds-css-namespace --codemod-only --apply

Test plan

  • 10 tests: class selectors, data-attr selectors, JSX attrs, getAttribute string args, className tokens, a realistic override block, and the safety cases (layer names + --xds-* vars preserved).
  • 26 tests pass across both P2 codemods + the upgrade suite; manifest loads and both codemods are discoverable.

Second XDS-prefix migration codemod (P2380608025). Rebrands consumer
override CSS and markup from the legacy `xds` DOM namespace to `astryx`:

  .xds-button           -> .astryx-button
  [data-xds-theme=...]  -> [data-astryx-theme=...]
  data-xds-media="dark"  -> data-astryx-media="dark"   (JSX/markup)
  className="xds-card"   -> className="astryx-card"

During compat the library dual-emits both class names and the theme/media
data attributes, so a consumer can flip selectors to the astryx form at any
time and they keep matching.

Deliberately leaves untouched (per P0):
- @layer xds-base / xds-theme — a CSS layer cannot be aliased/dual-emitted,
  so layer names stay xds-* through the whole compat window and only rebrand
  at final cutover; rewriting them would desync the consumer from the
  librarys emitted layer.
- --xds-* custom properties — they use the inverted read fallback and need
  per-case human review (stale vs intentional), handled separately.

String-based transform (CSS is not JS-parseable), mirroring the existing
migrate-theme-selectors-to-data-attrs codemod. Registered in v0.0.15 as
optional; run via:
  xds upgrade --codemod rebrand-xds-css-namespace --codemod-only --apply

Test plan: 10 tests — class selectors, data-attr selectors, JSX attrs,
getAttribute string args, className tokens, a realistic override block, and
the safety cases (layer names + --xds-* vars preserved). 26 tests pass
across both P2 codemods + the upgrade suite.

Stacked on #2879 (drop-xds-prefix-imports) — shares the v0.0.15 manifest.
@vercel

vercel Bot commented Jun 17, 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 17, 2026
@ejhammond
ejhammond merged commit 1994265 into navi/feat/p2-codemods Jun 17, 2026
2 of 3 checks passed
@cixzhang
cixzhang deleted the navi/feat/p2-css-codemod branch June 21, 2026 16:58

This branch had an error being deployed

1 failed deployment
Preview — f18d2596 Deployed Jun 17, 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