Skip to content

docs(ui)/feat(tooling): Typography + Button mapping guides and typography codemod (Wave 1) - #30721

Merged
chirag-madlani merged 2 commits into
mainfrom
antd-migration/wave1-typography-guide
Jul 31, 2026
Merged

docs(ui)/feat(tooling): Typography + Button mapping guides and typography codemod (Wave 1)#30721
chirag-madlani merged 2 commits into
mainfrom
antd-migration/wave1-typography-guide

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

First Wave 1 artifacts for the AntD → ui-core-components migration (#30565, epic #30570), landing now that Wave 0 (#30560) and the core prerequisites (#30664 forwardRef, #30665 Typography color prop — both in main) are merged.

Commit 1 — mapping guides (docs/antd-migration/typography.md, button.md): the review contracts for the first two sweeps, derived from a three-repo usage survey (~1,160 Typography tags, 1,370 Button instances). All previously-pending design decisions are baked in as approved (2026-07-30):

  • Typography Title level→size: 5→text-md, 4→text-lg, 3→text-xl, 2→display-xs, 1→display-sm
  • Button sizes: small→xs, middle→sm, large→md (dynamic expressions = hand-finish)
  • ghost/type="ghost"color="tertiary" per-site (no new core variant)
  • type="secondary" → core color="secondary" (prop landed in feat(ui-core): add semantic color prop to Typography #30665)
    Hand-finish punch lists (copyable/expandable/code/keyboard for Typography; Button.Group/ref/shape/border-overrides for Button) are enumerated with file:line.

Commit 2 — typography codemod (tooling/antd-codemods/transforms/antd-typography-to-core.js): converts Typography.Text/Title/Paragraph/Link (incl. destructured + aliased forms and mocks), maps type→color / strong→weight / underline→className, passes ellipsis through (shapes are identical), and does safe partial conversion — elements with unsupported props stay on antd (aliased CoreTypography for converted siblings) with warnings listing what needs hand-finishing. 27 inline tests; full codemod suite 37/37.

Verification

  • yarn test in tooling/antd-codemods: 2 suites, 37/37 green (10 existing + 27 new).
  • Prerequisites verified present in main before authoring (Typography color prop, Button forwardRef).

Fixes #30720

🤖 Generated with Claude Code

Greptile Summary

Adds Wave 1 Ant Design migration guidance and a Typography codemod.

  • Documents Typography and Button prop, size, styling, and manual-migration mappings.
  • Adds a jscodeshift transform for Typography subcomponents, destructured aliases, partial conversions, and import rewriting.
  • Adds inline coverage for supported mappings, skipped constructs, imports, and warning behavior.

Confidence Score: 4/5

The PR appears safe to merge, with one non-blocking codemod robustness issue around choosing a collision-free partial-conversion alias.

The documented mappings and covered transformations are coherent, but partial conversion can generate an invalid or incorrect binding when a target file already uses the hard-coded CoreTypography identifier.

Files Needing Attention: tooling/antd-codemods/transforms/antd-typography-to-core.js

Important Files Changed

Filename Overview
tooling/antd-codemods/transforms/antd-typography-to-core.js Implements the Typography transformation and partial-conversion import management; the fixed partial-conversion alias can collide with an existing local binding.
tooling/antd-codemods/tests/antd-typography-to-core.test.js Covers primary mappings, unsupported cases, import updates, destructuring, aliases, and warning output.
docs/antd-migration/typography.md Defines the approved Typography mapping and manual follow-up contract.
docs/antd-migration/button.md Defines Button mappings and enumerates cases requiring manual migration.
tooling/antd-codemods/README.md Documents invocation and the transform's partial-conversion behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Find antd Typography import] --> B[Classify member and destructured JSX]
  B --> C{Element mechanically supported?}
  C -->|Yes| D[Rewrite props and element to core Typography]
  C -->|No| E[Retain antd element and emit warning]
  D --> F{Any retained antd usage?}
  E --> F
  F -->|No| G[Replace or merge Typography import]
  F -->|Yes| H[Add aliased CoreTypography import]
Loading

Reviews (1): Last reviewed commit: "feat(tooling): add antd-typography-to-co..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

chirag-madlani and others added 2 commits July 30, 2026 21:48
Bakes in the approved Wave 1 decisions (LEVEL_SIZE_MAP, Button size scale,
ghost -> color="tertiary", Tooltip/Space/Tag related decisions) now that the
core Typography color prop and Button forwardRef have landed in main.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Drops the standalone codemod (developed ahead of the Wave 0 scaffold merge)
into tooling/antd-codemods/, with the LEVEL_SIZE_MAP convention marked
approved 2026-07-30. All 37 tests pass (10 move-named-imports + 27
typography).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 30, 2026 16:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Jul 30, 2026
Comment on lines +493 to +503
if (!hasAlias) {
if (coreImports.size()) {
coreImports.at(0).get().node.specifiers.push(
j.importSpecifier(j.identifier('Typography'), j.identifier(CORE_LOCAL_ALIAS))
);
} else {
const decl = j.importDeclaration(
[j.importSpecifier(j.identifier('Typography'), j.identifier(CORE_LOCAL_ALIAS))],
j.literal(CORE_MODULE)
);
j(typographyImportPath).insertAfter(decl);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Fixed alias can collide

Partial conversions always introduce the fixed CoreTypography local name, while this check only detects an existing core import with that alias. A file with another binding named CoreTypography will receive a duplicate binding or have converted elements resolve to the wrong identifier, so choose an unused local name before rewriting the elements and import.

Comment on lines +46 to +47
// `ellipsis={{ ... }}` keys with no core equivalent (show-more/less UX).
const ELLIPSIS_UNSUPPORTED_KEYS = ['expandable', 'symbol', 'onExpand'];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Edge Case: ellipsis object: only 3 keys blocked, others silently dropped

convertElement only skips ellipsis objects containing expandable/symbol/onExpand (ELLIPSIS_UNSUPPORTED_KEYS). antd's ellipsis object also supports keys core Typography ignores — e.g. suffix, onEllipsis. An element like ellipsis={{ rows: 2, suffix: '…', onEllipsis: fn }} is converted and the whole object is passed through, so suffix/onEllipsis behavior is silently lost with no warning. Additionally, a spread property inside the ellipsis object (ellipsis={{ ...opts }}) has prop.key undefined, so the hasBadKey check skips it and an object that actually contains expandable could be converted. Consider treating any ellipsis-object key outside {rows, tooltip} (and any spread) as a skip reason.

Was this helpful? React with 👍 / 👎

Comment on lines +330 to +344
root.find(j.JSXElement).forEach((elPath) => {
const classification = classifyElement(elPath.node);
if (!classification) {
return;
}
if (classification.matchType === 'bare') {
bareUsageFound = true;
return;
}
const result = convertElement(elPath.node, classification.kind);
if (result.skip) {
skips.push({ file: filePath, kind: classification.kind, reason: result.reason });
if (classification.matchType === 'destructured') {
recordDestructuredUsage(classification.localName, 'skipped');
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Edge Case: Destructured names used outside JSX may break on removal

The transform only scans JSXElements to decide whether a destructured sub-component name (e.g. const { Text } = Typography;) is still needed. If that local name is also referenced in a non-JSX position (e.g. const C = Text; or passed to a HOC), destructuredUsage records no usage, the property is removed from the pattern (usage undefined → filtered when converted siblings exist), and the remaining reference becomes an undefined identifier. This is an uncommon pattern but would produce broken output silently; consider bailing out (or keeping the binding) when the local name appears in any non-JSX identifier reference.

Was this helpful? React with 👍 / 👎

@gitar-bot

gitar-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 0 resolved / 2 findings

Adds typography and button migration guides along with a custom codemod for transitioning AntD typography components. Consider addressing the minor ellipsis object and destructured name limitations in the transform script.

💡 Edge Case: ellipsis object: only 3 keys blocked, others silently dropped

📄 tooling/antd-codemods/transforms/antd-typography-to-core.js:46-47 📄 tooling/antd-codemods/transforms/antd-typography-to-core.js:193-206

convertElement only skips ellipsis objects containing expandable/symbol/onExpand (ELLIPSIS_UNSUPPORTED_KEYS). antd's ellipsis object also supports keys core Typography ignores — e.g. suffix, onEllipsis. An element like ellipsis={{ rows: 2, suffix: '…', onEllipsis: fn }} is converted and the whole object is passed through, so suffix/onEllipsis behavior is silently lost with no warning. Additionally, a spread property inside the ellipsis object (ellipsis={{ ...opts }}) has prop.key undefined, so the hasBadKey check skips it and an object that actually contains expandable could be converted. Consider treating any ellipsis-object key outside {rows, tooltip} (and any spread) as a skip reason.

💡 Edge Case: Destructured names used outside JSX may break on removal

📄 tooling/antd-codemods/transforms/antd-typography-to-core.js:330-344 📄 tooling/antd-codemods/transforms/antd-typography-to-core.js:380-394

The transform only scans JSXElements to decide whether a destructured sub-component name (e.g. const { Text } = Typography;) is still needed. If that local name is also referenced in a non-JSX position (e.g. const C = Text; or passed to a HOC), destructuredUsage records no usage, the property is removed from the pattern (usage undefined → filtered when converted siblings exist), and the remaining reference becomes an undefined identifier. This is an uncommon pattern but would produce broken output silently; consider bailing out (or keeping the binding) when the local name appears in any non-JSX identifier reference.

🤖 Prompt for agents
Code Review: Adds typography and button migration guides along with a custom codemod for transitioning AntD typography components. Consider addressing the minor ellipsis object and destructured name limitations in the transform script.

1. 💡 Edge Case: ellipsis object: only 3 keys blocked, others silently dropped
   Files: tooling/antd-codemods/transforms/antd-typography-to-core.js:46-47, tooling/antd-codemods/transforms/antd-typography-to-core.js:193-206

   convertElement only skips ellipsis objects containing expandable/symbol/onExpand (ELLIPSIS_UNSUPPORTED_KEYS). antd's ellipsis object also supports keys core Typography ignores — e.g. suffix, onEllipsis. An element like `ellipsis={{ rows: 2, suffix: '…', onEllipsis: fn }}` is converted and the whole object is passed through, so suffix/onEllipsis behavior is silently lost with no warning. Additionally, a spread property inside the ellipsis object (`ellipsis={{ ...opts }}`) has `prop.key` undefined, so the `hasBadKey` check skips it and an object that actually contains expandable could be converted. Consider treating any ellipsis-object key outside {rows, tooltip} (and any spread) as a skip reason.

2. 💡 Edge Case: Destructured names used outside JSX may break on removal
   Files: tooling/antd-codemods/transforms/antd-typography-to-core.js:330-344, tooling/antd-codemods/transforms/antd-typography-to-core.js:380-394

   The transform only scans JSXElements to decide whether a destructured sub-component name (e.g. `const { Text } = Typography;`) is still needed. If that local name is also referenced in a non-JSX position (e.g. `const C = Text;` or passed to a HOC), destructuredUsage records no usage, the property is removed from the pattern (usage undefined → filtered when converted siblings exist), and the remaining reference becomes an undefined identifier. This is an uncommon pattern but would produce broken output silently; consider bailing out (or keeping the binding) when the local name appears in any non-JSX identifier reference.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar | Powered by Gitar — free for open source

@github-actions

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 4881920887140ebf520a0bafdb914df22b49b20b in Playwright run 30560957014, attempt 1.

✅ 537 passed · ❌ 0 failed · 🟡 2 flaky · ⏭️ 3 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 47m 54s

⏱️ Max setup 2m 52s · max shard execution 15m 48s · max shard-job elapsed before upload 19m 36s · reporting 5s

🌐 202.87 requests/attempt · 2.85 app boots/UI scenario · 15.19% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 15.19% (convergence target: at most 15%).
  • Browser traffic was 202.87 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.85 per UI scenario (1604 boots / 562 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 84 0 0 0 0 0
🟡 Shard chromium-02 100 0 1 0 0 0
🟡 Shard chromium-03 99 0 1 0 0 0
✅ Shard chromium-04 114 0 0 3 0 0
✅ Shard data-asset-rules-01 61 0 0 0 0 0
✅ Shard domain-isolation-01 14 0 0 0 0 0
✅ Shard global-state-01 23 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 10 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0
🟡 2 flaky test(s) (passed on retry)
  • Pages/Entity.spec.tsUser as Owner with unsorted list (shard chromium-02, 1 retry)
  • Pages/Entity.spec.tsDomain Propagation (shard chromium-03, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@chirag-madlani
chirag-madlani enabled auto-merge July 31, 2026 04:38
@chirag-madlani
chirag-madlani added this pull request to the merge queue Jul 31, 2026
Merged via the queue into main with commit 85191aa Jul 31, 2026
82 of 84 checks passed
@chirag-madlani
chirag-madlani deleted the antd-migration/wave1-typography-guide branch July 31, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wave 1: Typography + Button mapping guides and typography codemod

4 participants