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 for process for refactoring a Primer React Component to CSS modules #5135

Merged
merged 16 commits into from
Oct 17, 2024

Conversation

jonrohan
Copy link
Member

Closes https://github.com/github/primer/issues/3657

This PR documents how to migrate a styled component into a CSS module in primer react.

@jonrohan jonrohan added the skip changeset This change does not need a changelog label Oct 16, 2024
@jonrohan jonrohan requested a review from a team as a code owner October 16, 2024 17:54
@jonrohan jonrohan requested a review from TylerJDev October 16, 2024 17:54
Copy link

changeset-bot bot commented Oct 16, 2024

⚠️ No Changeset found

Latest commit: f21ccdc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@github-actions github-actions bot added the staff Author is a staff member label Oct 16, 2024
@jonrohan jonrohan requested review from keithamus, joshblack and langermank and removed request for TylerJDev October 16, 2024 17:55
@github-actions github-actions bot temporarily deployed to storybook-preview-5135 October 16, 2024 17:57 Inactive
Copy link
Contributor

github-actions bot commented Oct 16, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 97.01 KB (0%)
packages/react/dist/browser.umd.js 97.4 KB (0%)

@github-actions github-actions bot temporarily deployed to storybook-preview-5135 October 16, 2024 18:16 Inactive
Copy link
Member

@joshblack joshblack 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! Left a couple of comments 👀

2. **Feature Flagging:**
- Add a feature flag to toggle the `sx` prop for controlled rollout (staff shipping).
3. **Create CSS Module:**
- Add a corresponding `{Component}.module.css` file.
Copy link
Member

Choose a reason for hiding this comment

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

Would this be a good place to talk about how we use :where() for managing specificity or would this be a different doc?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could just link to the doc I'm writing here when its done

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that would fall into the css authoring doc https://github.com/primer/react/pull/5037/files

Copy link
Contributor

@langermank langermank left a comment

Choose a reason for hiding this comment

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

Great start! Just left some ideas


1. **Check for `className` and `style` Prop:**
- Ensure the component accepts a `className` for styling from outside of primer/react.
- Ensure the component accepts a `style` prop for more dynamic styling like positioning.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have to explicitly set this as a prop, or does it just come for free? CC @joshblack

Copy link
Member

Choose a reason for hiding this comment

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

@langermank it will come for free with {...props} most of the time but it may be good for us to make both explicit to avoid issues like:

<MyComponent
  className="hi"
  styles={{ /* ... */ }}
  {...props}
/>

Where either could be overridden instead of merged like we would want

2. **Feature Flagging:**
- Add a feature flag to toggle the `sx` prop for controlled rollout (staff shipping).
3. **Create CSS Module:**
- Add a corresponding `{Component}.module.css` file.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could just link to the doc I'm writing here when its done

@github-actions github-actions bot temporarily deployed to storybook-preview-5135 October 16, 2024 19:12 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-5135 October 16, 2024 19:31 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-5135 October 16, 2024 19:36 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-5135 October 16, 2024 21:31 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-5135 October 16, 2024 22:43 Inactive
@jonrohan jonrohan requested a review from joshblack October 17, 2024 19:41
@github-actions github-actions bot temporarily deployed to storybook-preview-5135 October 17, 2024 19:43 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-5135 October 17, 2024 19:53 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-5135 October 17, 2024 19:57 Inactive
Copy link
Contributor

@langermank langermank left a comment

Choose a reason for hiding this comment

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

Fantastic!

@jonrohan jonrohan added this pull request to the merge queue Oct 17, 2024
Merged via the queue into main with commit 1f53e40 Oct 17, 2024
43 checks passed
@jonrohan jonrohan deleted the migrating_to_css_modules_doc branch October 17, 2024 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changeset This change does not need a changelog staff Author is a staff member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants