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

Create codemod to migrate colors to css variables #363

Merged
merged 9 commits into from
Aug 29, 2023

Conversation

martimalek
Copy link
Contributor

@martimalek martimalek commented Aug 25, 2023

What:

Adds a codemod that migrates usages of the old Colors constant to CSS variables following our new colors structure


Why:

To ease the adoption of Wave 2.0 by automating the colors migration

How:

  • Add tests for both the existing codemod and the new one
    • In the testfixtures folders there are x.input.tsx with their respective x.output.tsx (the output file is what the input file should look like after running the codemod on it)
    • In the _tests I simply define the path and the config to run the codemods tests
  • Rename existing v2 codemod to more semantic block-to-width-100
  • Add new colors-to-css-vars codemod
  • Move /codemods folder to /src so it is included in the build

Checklist:

  • Update codemods docs
  • Move /codemods folder to /src to include it in the build
  • Ready to be merged

Closes #357

Copy link
Contributor

@nlopin nlopin left a comment

Choose a reason for hiding this comment

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

Do you think we can put a comment to the code recommending switching to semantic colours via getSemanticValue()?

@martimalek
Copy link
Contributor Author

martimalek commented Aug 29, 2023

Do you think we can put a comment to the code recommending switching to semantic colours via getSemanticValue()?

I think that can be tricky, when using the AST explorer it seems that comments don't always represent nodes in the AST, and when they do, they don't have a value 😕 (see attached). Looking at jscodeshifts API it seems that some nodes have a comments or leadingComment property, so I think it is possible to do, but if it's okay with you I'd prefer to have a comment in the migration guide with the recommendation for now and focus on other issues of the 2.0 milestone, in case we are ready for release and still have more time this can be a nice to have.
image

@martimalek martimalek merged commit 0c6c9ab into next Aug 29, 2023
8 of 10 checks passed
@martimalek martimalek deleted the colors-to-css-vars-codemod branch August 29, 2023 15:44
@github-actions
Copy link
Contributor

🎉 This PR is included in version 3.0.0-next.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants