Skip to content

feat(codemods): add heading rename codemods, fix SideNav doc - #530

Merged
cixzhang merged 1 commit into
mainfrom
navi/feat/heading-rename-codemods-and-docs
Mar 8, 2026
Merged

cixzhang merged 1 commit into
mainfrom
navi/feat/heading-rename-codemods-and-docs

Conversation

@cixzhang

@cixzhang cixzhang commented Mar 8, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds codemods for the heading rename from PR #527 and fixes an over-rename in the SideNav doc.

Codemods

rename-topnav-title-to-heading

  • Renames title prop to heading on <XDSTopNav>, <XDSTopNavTitle>, and <XDSTopNavHeading>
  • Renames <XDSTopNavTitle> to <XDSTopNavHeading> (JSX element name, opening + closing)
  • Renames XDSTopNavTitle → XDSTopNavHeading and XDSTopNavTitleProps → XDSTopNavHeadingProps in import specifiers

rename-sidenav-header-to-heading

  • Renames props: title → heading, titleHref → headingHref, supertitle → superheading, supertitleHref → superheadingHref, subtitle → subheading, subtitleHref → subheadingHref on <XDSSideNavHeader> and <XDSSideNavHeading>
  • Renames <XDSSideNavHeader> to <XDSSideNavHeading> (JSX element name)
  • Renames XDSSideNavHeader → XDSSideNavHeading and XDSSideNavHeaderProps → XDSSideNavHeadingProps in import specifiers

Both codemods:

  • Only target the specific components (no false positives on other components with same prop names)
  • Handle aliased imports (renames imported name, preserves local alias)
  • Return undefined when no changes needed
  • Are registered in the v0.0.2 transform manifest

Doc fix

Fixed SideNav.doc.mjs: XDSSideNavSection examples incorrectly used heading="..." prop instead of title="...". The XDSSideNavSection component's title prop was not part of the heading rename — it was over-renamed in PR #527.

Tests

26 tests across 2 test files covering:

  • Prop renames on each target component
  • Element name renames (opening + closing tags)
  • Import specifier renames (including Props types)
  • Aliased imports
  • Non-target components not affected
  • Returns undefined when no changes needed
  • Multiple renames in one file

Add codemods for the heading rename from PR #527:

1. rename-topnav-title-to-heading: Renames title → heading prop on
   XDSTopNav/XDSTopNavTitle/XDSTopNavHeading, renames XDSTopNavTitle
   component and imports to XDSTopNavHeading.

2. rename-sidenav-header-to-heading: Renames all props (title → heading,
   titleHref → headingHref, supertitle → superheading, etc.) on
   XDSSideNavHeader/XDSSideNavHeading, renames the component and imports.

Both codemods handle:
- Prop renames on target components only (no false positives)
- JSX element name renames (opening + closing tags)
- Import specifier renames (including Props types)
- Aliased imports (renames imported name, preserves alias)
- Returns undefined when no changes needed

Also fixes SideNav.doc.mjs: XDSSideNavSection examples incorrectly used
heading= prop instead of title= (over-renamed in PR #527).
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 8, 2026
@github-actions

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

Modified Components

SideNav · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 688B N/A
Lines of Code N/A 849 -
Complexity N/A Very High (70) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 9.1KB 14.7KB 2.3KB

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

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)

Component Previews

Includes interactive hover previews as animated GIFs.

XDSSideNav

Default

Screenshot:

Default

Interaction Preview: (view video)

Default interaction

View in Storybook · navigation-xdssidenav--default

Title Without Icon

Screenshot:

Title Without Icon

View in Storybook · navigation-xdssidenav--title-without-icon

Header with Menu

Screenshot:

Header with Menu

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

Suite with Independent Links

Screenshot:

Suite with Independent Links

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

Nested Items

Screenshot:

Nested Items

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

With Footer Icons

Screenshot:

With Footer Icons

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

Disabled Items

Screenshot:

Disabled Items

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

Hidden Section Header

Screenshot:

Hidden Section Header

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


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

@cixzhang
cixzhang merged commit 08c1028 into main Mar 8, 2026
14 checks passed
cixzhang pushed a commit that referenced this pull request Mar 8, 2026
BREAKING CHANGE: Remove deprecated exports that were replaced in prior PRs.

Removed:
- XDSTopNavTitle, XDSTopNavTitleProps (use XDSTopNavHeading, XDSTopNavHeadingProps)
- XDSSideNavHeader, XDSSideNavHeaderProps (use XDSSideNavHeading, XDSSideNavHeadingProps)
- useXDSIcon hook (use getIcon from globalIconRegistry)
- IconRegistryContext (use registerIcons + getIcon)
- IconRegistry.tsx (deleted — all functionality lives in globalIconRegistry.tsx)
- getGlobalRegistry internal helper (no longer needed)

Added:
- migrate-useXDSIcon-to-getIcon codemod with 11 tests
- Updates internal imports from IconRegistry to globalIconRegistry

Migration codemods exist for all removed APIs:
- rename-topnav-title-to-heading (PR #530)
- rename-sidenav-header-to-heading (PR #530)
- migrate-useXDSIcon-to-getIcon (this PR)

Refs: #527, #530, #531
cixzhang added a commit that referenced this pull request Mar 8, 2026
….2 (#533)

BREAKING CHANGE: Remove deprecated exports that were replaced in prior PRs.

Removed:
- XDSTopNavTitle, XDSTopNavTitleProps (use XDSTopNavHeading, XDSTopNavHeadingProps)
- XDSSideNavHeader, XDSSideNavHeaderProps (use XDSSideNavHeading, XDSSideNavHeadingProps)
- useXDSIcon hook (use getIcon from globalIconRegistry)
- IconRegistryContext (use registerIcons + getIcon)
- IconRegistry.tsx (deleted — all functionality lives in globalIconRegistry.tsx)
- getGlobalRegistry internal helper (no longer needed)

Added:
- migrate-useXDSIcon-to-getIcon codemod with 11 tests
- Updates internal imports from IconRegistry to globalIconRegistry

Migration codemods exist for all removed APIs:
- rename-topnav-title-to-heading (PR #530)
- rename-sidenav-header-to-heading (PR #530)
- migrate-useXDSIcon-to-getIcon (this PR)

Refs: #527, #530, #531

Co-authored-by: navi[bot] <[email protected]>
@cixzhang
cixzhang deleted the navi/feat/heading-rename-codemods-and-docs branch March 13, 2026 10:50
cixzhang added a commit that referenced this pull request Apr 26, 2026
….2 (#533)

BREAKING CHANGE: Remove deprecated exports that were replaced in prior PRs.

Removed:
- XDSTopNavTitle, XDSTopNavTitleProps (use XDSTopNavHeading, XDSTopNavHeadingProps)
- XDSSideNavHeader, XDSSideNavHeaderProps (use XDSSideNavHeading, XDSSideNavHeadingProps)
- useXDSIcon hook (use getIcon from globalIconRegistry)
- IconRegistryContext (use registerIcons + getIcon)
- IconRegistry.tsx (deleted — all functionality lives in globalIconRegistry.tsx)
- getGlobalRegistry internal helper (no longer needed)

Added:
- migrate-useXDSIcon-to-getIcon codemod with 11 tests
- Updates internal imports from IconRegistry to globalIconRegistry

Migration codemods exist for all removed APIs:
- rename-topnav-title-to-heading (PR #530)
- rename-sidenav-header-to-heading (PR #530)
- migrate-useXDSIcon-to-getIcon (this PR)

Refs: #527, #530, #531

Co-authored-by: navi[bot] <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
….2 (#533)

BREAKING CHANGE: Remove deprecated exports that were replaced in prior PRs.

Removed:
- XDSTopNavTitle, XDSTopNavTitleProps (use XDSTopNavHeading, XDSTopNavHeadingProps)
- XDSSideNavHeader, XDSSideNavHeaderProps (use XDSSideNavHeading, XDSSideNavHeadingProps)
- useXDSIcon hook (use getIcon from globalIconRegistry)
- IconRegistryContext (use registerIcons + getIcon)
- IconRegistry.tsx (deleted — all functionality lives in globalIconRegistry.tsx)
- getGlobalRegistry internal helper (no longer needed)

Added:
- migrate-useXDSIcon-to-getIcon codemod with 11 tests
- Updates internal imports from IconRegistry to globalIconRegistry

Migration codemods exist for all removed APIs:
- rename-topnav-title-to-heading (PR #530)
- rename-sidenav-header-to-heading (PR #530)
- migrate-useXDSIcon-to-getIcon (this PR)

Refs: #527, #530, #531

Co-authored-by: navi[bot] <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
….2 (#533)

BREAKING CHANGE: Remove deprecated exports that were replaced in prior PRs.

Removed:
- XDSTopNavTitle, XDSTopNavTitleProps (use XDSTopNavHeading, XDSTopNavHeadingProps)
- XDSSideNavHeader, XDSSideNavHeaderProps (use XDSSideNavHeading, XDSSideNavHeadingProps)
- useXDSIcon hook (use getIcon from globalIconRegistry)
- IconRegistryContext (use registerIcons + getIcon)
- IconRegistry.tsx (deleted — all functionality lives in globalIconRegistry.tsx)
- getGlobalRegistry internal helper (no longer needed)

Added:
- migrate-useXDSIcon-to-getIcon codemod with 11 tests
- Updates internal imports from IconRegistry to globalIconRegistry

Migration codemods exist for all removed APIs:
- rename-topnav-title-to-heading (PR #530)
- rename-sidenav-header-to-heading (PR #530)
- migrate-useXDSIcon-to-getIcon (this PR)

Refs: #527, #530, #531
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