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

feat(codemods): add codemod to upgrade V1 Buttons #5408

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

HeartSquared
Copy link
Contributor

@HeartSquared HeartSquared commented Dec 19, 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
    • Default (undefined):
      • Button -> variant secondary
      • IconButton -> variant tertiary
    • primary → variant primary
    • secondary → variant tertiary
    • destructive → delete
  • Update size
    • regularlarge
    • smallmedium
    • There is a usage of size={size} which would likely have a TS error - leave as is
  • reversedisReversed
  • onMouseDownonPressStart
  • fullWidthisFullWidth
  • classNameOverrideclassName
  • data-automation-iddata-testid
  • disabledisDisabled
  • newTabAndIUnderstandTheAccessibilityImplicationstarget="_blank"
    • Also add rel="noopener noreferrer"
  • IconButton only:
    • Add hasHiddenLabel
  • disableTabFocusAndIUnderstandTheAccessibilityImplicationsexcludeFromTabOrder
  • newTabAndIUnderstandTheAccessibilityImplications → removed
    • this is all handled through target blank and isn't needed

Component name:

  • IconButton (v1/v2) without href or componentButton (v3)
  • IconButton (v1/v2) with hrefLinkButton
  • IconButton (v1/v2) with componentLinkButton
  • 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 19, 2024

🦋 Changeset detected

Latest commit: b00705b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@kaizen/components Patch

Not sure what this means? Click here to learn what changesets are.

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

Base automatically changed from heartsquared/codemod-fix--upgradeIconV1 to main December 19, 2024 05:08
@HeartSquared HeartSquared force-pushed the KZN-2846/codemod--upgrade-button branch from 75ed8ab to 1cd8163 Compare December 19, 2024 05:43
@mcwinter07 mcwinter07 force-pushed the KZN-2846/codemod--upgrade-button branch from deb46b1 to e6c40a2 Compare February 11, 2025 02:44
@mcwinter07 mcwinter07 self-assigned this Feb 14, 2025
@mcwinter07 mcwinter07 marked this pull request as ready for review February 14, 2025 04:12
@mcwinter07 mcwinter07 requested a review from a team as a code owner February 14, 2025 04:12
Copy link
Contributor

github-actions bot commented Feb 14, 2025

✨ Here is your branch preview! ✨

Last updated for commit b00705b: Merge branch 'main' into KZN-2846/codemod--upgrade-button

@mcwinter07 mcwinter07 force-pushed the KZN-2846/codemod--upgrade-button branch from b3680c4 to b00705b Compare February 14, 2025 04:17
@mcwinter07
Copy link
Contributor

Question is, with this codemod, do we want to update to the versioned entires for button? or the next entry point outline in the tech vision 🤔 @dougmacknz

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.

2 participants