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(codemod): add codemod to upgrade Icon to Future Icon #5080

Conversation

HeartSquared
Copy link
Contributor

@HeartSquared HeartSquared commented Sep 25, 2024

Why

KZN-2677

What

README:

  • Add new codemod to list
  • Set up notes

CaMonogramIcon:

  • Update import to Brand
  • Update tag name to Brand
  • Add variant enso
  • If inheritSize - remove prop
  • If not inheritSize - add style to set size to 20px
  • All other props as is

SpinnerIcon:

  • Update import to LoadingSpinner
  • Update tag name to LoadingSpinner
  • Replace aria-label with accessibilityLabel or fallback of "Loading"
  • Remove role
  • Remove viewBox
  • All other props as is

LiveIcon:

  • Update to sensors
    • TBC with Jess whether we want to add to the default set
  • Animated: OOS; keep it using legacy for now (but to later move to be a subcomponent of Tag)

Icon:

  • Update imports
  • Add name based on previous component name
  • Add isFilled if required based on previous component name
  • role="presentation" becomes isPresentational
  • role="img" to be removed (should have an aria-label)
  • aria-label becomes alt
  • classNameOverride becomes className
  • Leave inheritSize as is (expecting a TS error) and leave a comment above it
  • Changearia-hidden to isPresentational
  • Change color - inline style
  • Keep data-testid as is
  • Remove fontSize - doesn't do anything
  • Change height + width - convert to inline style
  • Keep id as is
  • Keep onClick as is
  • Remove viewBox

@HeartSquared HeartSquared marked this pull request as ready for review October 9, 2024 04:12
@HeartSquared HeartSquared requested a review from a team as a code owner October 9, 2024 04:12
Copy link
Contributor

github-actions bot commented Oct 9, 2024

✨ Here is your branch preview! ✨

Last updated for commit 2a69d7c: Merge branch 'KZN-2759/release--icon-material-symbols' into KZN-2677/icon-material-symbols--codemod

Copy link
Contributor

@dougmacknz dougmacknz left a comment

Choose a reason for hiding this comment

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

Awesome work

export const TestComponent = () => (
<>
<Brand variant="enso" style={{ width: "20px" }} role="presentation" />
<Brand variant="enso" style={{ width: "20px" }} role="img" aria-label="Add something" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this remove role="img" and change aria-label to alt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops! Yep you're right 😬 Will update 🙏🏻

["VisibleIcon", { name: "visibility" }],
["WritingIcon", undefined],
["ZoomInIcon", { name: "zoom_in" }],
["ZoomOutIcon", { name: "zoom_out" }],
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow this is a bonkers long list, kudos on getting the map 👏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy/paste is our best friend <3

value: string
): ts.JsxAttribute => createProp(name, ts.factory.createStringLiteral(value))

export const createStyleProp = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Seem potentially handy for the future. Could we add a util description here just to tether it back to its main purpose? I'm thinkin' something like 'A util that creates a style prop with the given attributes to be consumed in a transformer, ie: adding style={{width: "500px"}}".

*/
export const getKaioTagNamesByRegex = (
node: ts.Node,
importSpecifierTarget: string
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we mentioned regex in this arg? I know we call out that this performs on regex in the code comments but took me a second to realised this would also accept regex

Comment on lines 207 to 208
/* Consumer helpers */
export const setImportToRemove = (
Copy link
Contributor

Choose a reason for hiding this comment

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

I kind of understand these in the abstract by looking at how they're used in the upgradeIconV1 but can we add a little more context in the code comments, potentially with an example?

Base automatically changed from KZN-2653/icon--material-symbols to KZN-2759/release--icon-material-symbols October 11, 2024 05:05
@HeartSquared HeartSquared merged commit 2c7b013 into KZN-2759/release--icon-material-symbols Oct 13, 2024
19 checks passed
@HeartSquared HeartSquared deleted the KZN-2677/icon-material-symbols--codemod branch October 13, 2024 23:24
HeartSquared added a commit that referenced this pull request Oct 16, 2024
* feat(Icon): add future Icon (#4973)

* feat: add illustrations entrypoint

* chore(storybook): link to Material Symbols CDN

* feat(future/Icon): add prop to mirror in RTL

* docs(future/Icon): add api specification

* docs(future/Icon): update usage guidelines

* feat(future/Icon): add props for accessibility

* feat(future/Icon): add string suggestions for name

* feat(future/Icon): handle RTL icons that are not a direct mirror

* docs(future/Icon): add list of default icon set

* docs(DosAndDonts): update styles so items are the same height

* chore: update root test command to not watch

* docs(DosAndDonts): update styles for single col to span full width

* feat(Notification): update icons to use future Icon

* chore(tsconfig): resolve json in storybook

* chore(DosAndDonts): update to use new icon

* chore(ResourceLinks): update to use new icon

* fix(future/Tag): fix cautionary icon colour

* refactor: update Icon usage in some components

* chore: fix lint:fix script

* fix(Popover): fix icon color

* feat(codemod): add codemod to upgrade Icon to Future Icon (#5080)

* refactor: rename getTagName to getKaioTagName and abstract traversing

* feat(codemod): add util getKaioTagNamesByRegex

* refactor(transformSource): make tag name generic

* feat(updateJsxElementWithNewProps): add arg to update tag name

* feat(codemod): add codemod for upgrading icons

* feat(upgradeIconV1): transform CaMonogramIcon to Brand

* feat(updateKaioImport): add util to update imports

* feat(upgradeIconV1): transform SpinnerIcon to LoadingSpinner
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.

3 participants