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

docs(tokens) Updates migration instructions. #4239

Merged
merged 4 commits into from
Oct 9, 2024

Conversation

edonehoo
Copy link
Collaborator

@edonehoo edonehoo commented Sep 5, 2024

Closes #4218, adds to existing tokens docs

@patternfly-build
Copy link
Contributor

patternfly-build commented Sep 5, 2024

@edonehoo
Copy link
Collaborator Author

edonehoo commented Sep 5, 2024

@srambach RE #4218, were you thinking of a different direction than this pr goes? Much of the info from the linked doc in the issue was already on the site, but do you think it would make more sense in a different page or with more detail? Added some more details and specifics, though!

I saw the codemods notes in the original doc, but they seemed like observations more than things we want to communicate on org

@edonehoo edonehoo linked an issue Sep 6, 2024 that may be closed by this pull request
@srambach
Copy link
Member

I think this came out of a recent conversation specifically about React tokens (which are the React version of our CSS variables). This includes more than just token variables. This is great info, and I like the improvements you've made to the "develop with tokens" page. But I think this was intended to add some information to the upgrade guide about finding and fixing React tokens specifically. @nicolethoen @wise-king-sullyman maybe you two have more specific information?

@adamviktora
Copy link

Following on what Sarah has written about React tokens - we just discussed that on a working session, and it would be great to add some notes like this:

  • React token names are based on the CSS variable names, but instead of -- symbol, _ is used plus the starting --pf- is removed. So for example --pf-t--global--spacer--sm becomes a t_global_spacer_sm react token.
  • React token can be imported from its file directly: import t_global_spacer_sm from '@patternfly/react-tokens/dist/esm/t_global_spacer_sm' or from the whole package: import { t_global_spacer_sm } from '@patternfly/react-tokens'
  • React token is an object having name, value and var properties:
const t_global_spacer_sm = {
  "name": "--pf-t--global--spacer--sm",
  "value": "0.5rem",
  "var": "var(--pf-t--global--spacer--sm)"
}

@kmcfaul
Copy link
Contributor

kmcfaul commented Sep 24, 2024

@adamviktora Is this a blocker or could it be done in a follow up?

@adamviktora
Copy link

@kmcfaul It can be a follow up for sure

@srambach
Copy link
Member

@kmcfaul I think @adamviktora 's suggestions are the core of this issue so I think it's worth doing before merging this rather than making another issue.

@edonehoo
Copy link
Collaborator Author

@adamviktora ty for this context!
@srambach I integrated Adam's comment, but I can't tell if it's enough extra context on its own to help guide people that will actually use this info. WDYT?

If we do want to go further in these docs, or if I'm misunderstanding any of these details, it would probably be good to arrange time for a call to help me understand this more deeply (also cc @nicolethoen) !

Copy link

@adamviktora adamviktora left a comment

Choose a reason for hiding this comment

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

I really like the updates, I think it explains React tokens pretty well. Two comments bellow:

@@ -61,7 +61,7 @@ PatternFly 6 supports our new design token system, which changes variable names

Wherever you have any custom CSS overrides that reference PatternFly class names or CSS variables, you should carefully review them and make updates to ensure that they align with our token variables, which are outlined in our [tokens documentation](/tokens/all-patternfly-tokens). As much as possible, we recommend removing your CSS overrides so that your product upgrade experience will be smoother for future releases.

If your product uses a custom solution to replicate PatternFly styling (without using PatternFly components), then it will need to be reskinned. We recognize that this may be a large undertaking, so we encourage you to reach out to the PatternFly team so that we support this work.
If your product uses a custom solution to replicate PatternFly styling (without using PatternFly components), then it will need to be re-skinned. We recognize that this may be a large undertaking, so we encourage you to reach out to the PatternFly team so that we can help support this work.

Choose a reason for hiding this comment

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

I'd mention also (probably in this block) that we have a codemod for updating global CSS variables, which are part of their React code (it will not fix .css files, but only javascript or typescript ones).

This codemod updates global color variables to a temporary hot pink color: --pf-t--temp--dev--tbd (or t_temp_dev_tbd when using React tokens), so consumers can build their code and visually see on the website, at which places they will have to manually replace this token with a new one.

For other global variables (spacers, font size, box shadow), it will try to provide an autofix to match the same value (or the closest one).

This codemod works both for CSS variables and React tokens.
e.g. a CSS variable: --pf-v5-global--FontSize--lg becomes --pf-t--global--font--size--lg
and a react token: global_FontSize_lg becomes t_global_font_size_lg

Copy link
Collaborator Author

@edonehoo edonehoo Oct 2, 2024

Choose a reason for hiding this comment

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

thanks for all of this info!! Is that this codemod? https://github.com/patternfly/pf-codemods?tab=readme-ov-file#tokens-update. I linked to that one in my last commit, but can adjust if needed. Is https://github.com/patternfly/pf-codemods/tree/main/packages/class-name-updater limited to css?

Choose a reason for hiding this comment

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

Yes, that's the codemod. The class-name-updater is not limited to just css. Thanks for doing all the updates!

Copy link

@adamviktora adamviktora left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

Copy link
Contributor

@kmcfaul kmcfaul left a comment

Choose a reason for hiding this comment

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

🎉

Copy link
Member

@srambach srambach left a comment

Choose a reason for hiding this comment

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

I think this looks good, thank you! 🩷

@kmcfaul kmcfaul merged commit 51f5a8a into patternfly:main Oct 9, 2024
4 checks passed
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.

Document how to upgrade React tokens
6 participants