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

Upgrade to v9 primitives #717

Merged
merged 18 commits into from
Aug 28, 2024
Merged

Upgrade to v9 primitives #717

merged 18 commits into from
Aug 28, 2024

Conversation

rezrah
Copy link
Collaborator

@rezrah rezrah commented Aug 27, 2024

Summary

Part of https://github.com/github/primer/issues/3176

Completes the upgrade to v9 primitives, keeping all previous build configuration in-tact.

Diff of changes can be seen in the bot comment here 👀

Screenshot 2024-08-28 at 13 03 06

Note

All changes in this PR are directly related to the upgrade only and focussed around end-user output.
Refactoring of implementation details is out-of-scope, and will be reviewed at a later date to keep this PR manageable.

List of notable changes:

  • completes upgrade to v9 primitives
  • fixed bug in CI diff, which wasn't emitting new tokens, only diffs to existing ones
  • updated eslint-plugin-primer-react dependency and subsequently impacted files

What should reviewers focus on?

Contributor checklist:

  • All new and existing CI checks pass
  • Tests prove that the feature works and covers both happy and unhappy paths
  • Any drop in coverage, breaking changes or regressions have been documented above
  • New visual snapshots have been generated / updated for any UI changes
  • All developer debugging and non-functional logging has been removed
  • Related issues have been referenced in the PR description

Reviewer checklist:

  • Check that pull request and proposed changes adhere to our contribution guidelines and code of conduct
  • Check that tests prove the feature works and covers both happy and unhappy paths
  • Check that there aren't other open Pull Requests for the same update/change

Copy link

changeset-bot bot commented Aug 27, 2024

🦋 Changeset detected

Latest commit: 0fc2075

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

This PR includes changesets to release 6 packages
Name Type
@primer/react-brand Minor
@primer/brand-primitives Minor
@primer/brand-e2e Minor
@primer/brand-fonts Minor
@primer/brand-config Minor
@primer/brand-storybook Minor

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

Copy link
Contributor

github-actions bot commented Aug 27, 2024

🟢 No visual differences found

Our visual comparison tests did not find any differences in the UI.

@primer primer deleted a comment from github-actions bot Aug 27, 2024
Copy link
Contributor

github-actions bot commented Aug 27, 2024

🔍 Design token changes found

View CSS variable changes
+ --base-size-6: 0.375rem;
+ --base-size-2: 0.125rem;
- --brand-breakpoint-xxlarge: 90rem;
+ --brand-breakpoint-xxlarge: 87.5rem;
- @custom-media --brand-viewportRange-wide-viewport (min-width: 90rem);
+ @custom-media --brand-viewportRange-wide-viewport (min-width: 87.5rem);

@rezrah rezrah marked this pull request as ready for review August 28, 2024 12:08
* transform: scss variable names
* example: `$namespace-item-variant-property-modifier`
*/
StyleDictionary.registerTransform({
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🙌 nice..

added as a follow up PR item

* transform: css variable names
* example: `--namespace-item-variant-property-modifier`
*/
StyleDictionary.registerTransform({
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be removed, both scss and css are pathToKebabCase, the prefix is added later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks, added as a follow up PR item

* example: `namespace.item.variant.property.modifier`
*/
StyleDictionary.registerTransform({
name: 'name/js',
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks, added as a follow up PR item. Will need the JS equivalent of that function to ship first.

* example: `NamespaceItemVariantPropertyModifier`
*/
StyleDictionary.registerTransform({
name: 'name/js/es6',
Copy link
Contributor

Choose a reason for hiding this comment

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

We can upstream this if you want.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes please 🙏

Copy link
Contributor

Choose a reason for hiding this comment

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


// transform: px to rem
StyleDictionary.registerTransform({
name: 'pxToRem',
Copy link
Contributor

Choose a reason for hiding this comment

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

If you have token: "dimension" on all your size tokens you could use: https://github.com/primer/primitives/blob/main/src/transformers/dimensionToRem.ts

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Needs a bit more investigation...

...added as a follow up PR item.


// ts output
StyleDictionary.registerTransform({
name: 'attribute/typescript',
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this work? Interesting. Can you explain it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll get back to you on that... 😅

...added as a follow up PR item.


// css output
StyleDictionary.registerTransform({
name: 'attribute/css',
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need this?


// transform: composite typography to shorthands
StyleDictionary.registerTransform({
name: 'typography/shorthand',
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be able to use this: https://github.com/primer/primitives/blob/main/src/transformers/typographyToCss.ts

If not, this should be our goal to make it use this upstream transformer.

// REGISTER THE CUSTOM TRANFORM GROUPS

StyleDictionary.registerTransformGroup({
name: 'css',
Copy link
Contributor

Choose a reason for hiding this comment

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

Just FYI, you don't need to use TransformGroups, you can just add the transforms to the platform directly.

Copy link
Contributor

@lukasoppermann lukasoppermann Aug 28, 2024

Choose a reason for hiding this comment

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

I meant to add this to scss, Although since scss and css are the same transforms, you could just use css for all.

})

StyleDictionary.registerFormat({
name: 'custom/format/custom-media',
Copy link
Contributor

Choose a reason for hiding this comment

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

},
scss: {
buildPath: `${outputPath}/scss/`,
transformGroup: 'scss',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
transformGroup: 'scss',
transformGroup: 'css',

They are the same.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't have CI diffing against the scss folder, so can't verify any regressions easily. Is this something you're super confident about @lukasoppermann, if so I can do it now. Alternatively, can do this one in a follow up PR.

Comment on lines 491 to 494
pathToKebabCase,
pathToDotNotation,
capitalize,
pathToPascalCase,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to export them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably not, let me remove these now 👍 thanks

Copy link
Contributor

@lukasoppermann lukasoppermann left a comment

Choose a reason for hiding this comment

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

Comments can be addressed in a separate PR.

@@ -0,0 +1,495 @@
/**
* Ported from primer/primitives, as it was removed in v8 release and we still need it
Copy link
Collaborator Author

@rezrah rezrah Aug 28, 2024

Choose a reason for hiding this comment

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

For posterity, this PR isn't where we'll refactor this file. That will happen in subsequent PRs. Tasklist added here.

Copy link
Contributor

@danielguillan danielguillan left a comment

Choose a reason for hiding this comment

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

Looking great! This is a really exciting update! 🚀

@rezrah rezrah merged commit 24fc6d0 into main Aug 28, 2024
17 of 18 checks passed
@rezrah rezrah deleted the rezrah/v9-primitives-upgrade branch August 28, 2024 15:40
@primer-css primer-css mentioned this pull request Aug 28, 2024
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