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(Header): Convert Header to CSS modules behind team feature flag #5192

Merged
merged 11 commits into from
Oct 30, 2024

Conversation

hussam-i-am
Copy link
Collaborator

@hussam-i-am hussam-i-am commented Oct 29, 2024

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

Changelog

New

Changed

Convert Header to CSS modules behind team feature flag

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@hussam-i-am hussam-i-am self-assigned this Oct 29, 2024
@hussam-i-am hussam-i-am requested a review from a team as a code owner October 29, 2024 21:12
Copy link

changeset-bot bot commented Oct 29, 2024

🦋 Changeset detected

Latest commit: f2f1fcc

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

This PR includes changesets to release 1 package
Name Type
@primer/react 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

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Oct 29, 2024
@github-actions github-actions bot temporarily deployed to storybook-preview-5192 October 29, 2024 21:14 Inactive
Copy link
Contributor

github-actions bot commented Oct 29, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 97.5 KB (+0.11% 🔺)
packages/react/dist/browser.umd.js 97.83 KB (+0.07% 🔺)

@primer-integration
Copy link

primer-integration bot commented Oct 29, 2024

🟢 golden-jobs completed with status success.

@hussam-i-am
Copy link
Collaborator Author

Updated the unit and storybook tests to verify className, as well as added support for as prop for Header since it was failing in the integration build

@github-actions github-actions bot temporarily deployed to storybook-preview-5192 October 30, 2024 17:11 Inactive
Comment on lines 81 to 82
className={clsx(className, enabled && classes.HeaderItem, enabled && rest.full && classes.Full)}
{...rest}
Copy link
Contributor

Choose a reason for hiding this comment

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

For variant type props, we're using data-attributes for styling instead of classnames. You can read a little bit about that in the CSS authoring guide.

So for the full prop, instead of a classname it would look something like this:

Suggested change
className={clsx(className, enabled && classes.HeaderItem, enabled && rest.full && classes.Full)}
{...rest}
className={clsx(className, enabled && classes.HeaderItem}
data-full={full}
{...rest}

And then in CSS

&:where([data-full]) {
  ....
}

If you check out the ButtonBase component you can see this in action 😄 

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, makes a lot of sense, updated!

@primer-integration
Copy link

👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/349206

@hussam-i-am hussam-i-am added this pull request to the merge queue Oct 30, 2024
Merged via the queue into main with commit cbeed21 Oct 30, 2024
43 checks passed
@hussam-i-am hussam-i-am deleted the hussam-i-am/css_modules_header branch October 30, 2024 22:24
@primer primer bot mentioned this pull request Oct 30, 2024
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.

Sorry I was late on this! Just had a couple comments for this that I think would be good to cover

Comment on lines +96 to +103
const isReactRouter = typeof to === 'string'
if (isReactRouter) {
// according to their docs, NavLink supports aria-current:
// https://reacttraining.com/react-router/web/api/NavLink/aria-current-string
return {'aria-current': 'page'}
} else {
return {}
}
Copy link
Member

Choose a reason for hiding this comment

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

I think this logic will need to be ported over into the HeaderLink so that it works with the flag enabled/disabled. Right now, it will only be applied when the styled component is used if I understand right 👀

Comment on lines +82 to +83
data-full={rest.full}
{...rest}
Copy link
Member

Choose a reason for hiding this comment

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

I think a challenge with this is that full will be an attribute when the flag is enabled and will give us an unexpected attribute error, e.g.

image

I think we should either update the styled component to use the data attribute pattern or only pass along full when the flag is enabled, if that makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants