Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(codemods): upgrade to Button v3 #5360

Closed
wants to merge 33 commits into from

Conversation

HeartSquared
Copy link
Contributor

@HeartSquared HeartSquared commented Dec 6, 2024

Why

Make adoption easier.

What

Codemod to upgrade Button v1/v2 and IconButton v1/v2 to Button v3 or LinkButton v3

Assumptions:

  • label should always exist, and become children
  • children should not already exist (always a self-closing element)

Props:

  • onClickonPress
  • labelchildren (self-closing → open/close element)
    • Examples of different types of label usage:
      • "Actions"
      • {"Actions for section" // TODO: i18n}
      • {"Back to Main Menu"}
      • {`Further options for ${track.name}`}
      • { showEmojiPicker ? formatMessage({ id: "liteRTE.emojiPickerLabel.close", defaultMessage: "Close emoji picker", description: "Label for the button that closes the emoji picker", }) : formatMessage({ id: "liteRTE.emojiPickerLabel.open", defaultMessage: "Open emoji picker", description: "Label for the button that opens the emoji picker", }) }
      • {label}
  • Update variants (TBC)
    • Default (undefined) → ?
    • primary → ?
    • secondary → ?
    • destructive → ?
    • secondary + destructive → ?
  • Update size (TBC)
    • regular → ?
    • small → ?
    • There is a usage of size={size} which would likely have a TS error - leave as is
  • reversedisReversed
  • classNameOverrideclassName
  • data-automation-iddata-testid
  • disabledisDisabled
  • Only when href exists:
    • newTabAndIUnderstandTheAccessibilityImplicationstarget="_blank"
      • Also add rel="noopener noreferrer"
  • IconButton only:
    • Add hasHiddenLabel

Component name:

  • IconButton (v1/v2) without href or componentButton (v3)
  • IconButton (v1/v2) with hrefLinkButton
  • IconButton (v1/v2) with componentLinkButton
    • Leave component prop but add a @todo to review
  • Button (v1/v2) without href or componentButton (v3)
  • Button (v1/v2) with hrefLinkButton
  • Button (v1/v2) with componentLinkButton

Imports:

  • From:
    • @kaizen/components
    • @kaizen/components/v1/actions
    • @kaizen/components/v2/actions
  • To:
    • @kaizen/components/v3/actions
  • IconButton may be aliased - use alias
  • Button may be aliased - use alias
  • Button (v3) not imported - add import
  • Button (v3) may already be used
    • Do not add an additional import
    • Button may be aliased - use alias

Copy link

changeset-bot bot commented Dec 6, 2024

⚠️ No Changeset found

Latest commit: 7148b2b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@HeartSquared HeartSquared changed the title refactor(codemods): move empty check to updateKaioImports refactor(codemods): upgrade to Button v3 Dec 6, 2024
@HeartSquared
Copy link
Contributor Author

Split into #5407 and #5408

@HeartSquared HeartSquared deleted the KZN-2846/codemod--icon-button branch December 19, 2024 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant