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

PageHeader: Handle responsive CSS properties with breakpoints #2662

Merged
merged 12 commits into from
Dec 28, 2022

Conversation

broccolinisoup
Copy link
Member

@broccolinisoup broccolinisoup commented Dec 7, 2022

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

Following up a #2265 (comment) for shifting the responsiveness logic from JS to CSS via using media queries to make the component more SSR friendly.

Context:

Currently PageHeader uses useResponsiveHook to manage components' visibility via hidden prop. It works fine however, this causes a layout shift in SSR. To avoid that, this PR adds a utility function called CSSManagedResponsiveValue and it manages the responsive visibility with CSS breakpoints and still keeps the same API

hidden={{narrow: true, regular: false, wide:false}}

or

hidden={false}

Screenshots

No visual changes

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@broccolinisoup broccolinisoup self-assigned this Dec 7, 2022
@changeset-bot
Copy link

changeset-bot bot commented Dec 7, 2022

🦋 Changeset detected

Latest commit: 0927bd1

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

@broccolinisoup broccolinisoup added the skip changeset This change does not need a changelog label Dec 7, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 84.94 KB (0%)
dist/browser.umd.js 85.55 KB (0%)

@broccolinisoup broccolinisoup temporarily deployed to github-pages December 7, 2022 09:07 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2662 December 7, 2022 09:08 Inactive
@broccolinisoup broccolinisoup temporarily deployed to github-pages December 9, 2022 03:37 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2662 December 9, 2022 03:37 Inactive
@broccolinisoup broccolinisoup temporarily deployed to github-pages December 9, 2022 09:03 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2662 December 9, 2022 09:04 Inactive
Base automatically changed from pk/page-header to main December 9, 2022 21:09
@broccolinisoup broccolinisoup temporarily deployed to github-pages December 12, 2022 01:14 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2662 December 12, 2022 01:14 Inactive
@broccolinisoup broccolinisoup temporarily deployed to github-pages December 12, 2022 01:50 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2662 December 12, 2022 01:50 Inactive
@broccolinisoup broccolinisoup removed the skip changeset This change does not need a changelog label Dec 12, 2022
@broccolinisoup broccolinisoup marked this pull request as ready for review December 12, 2022 04:54
@broccolinisoup broccolinisoup changed the title PageHeader: CSS media queries for responsive sub component visibility PageHeader: CSS media queries for responsive visibility with hidden prop Dec 12, 2022
@github-actions github-actions bot temporarily deployed to storybook-preview-2662 December 12, 2022 04:58 Inactive
@broccolinisoup broccolinisoup temporarily deployed to github-pages December 12, 2022 05:02 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2662 December 12, 2022 05:02 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2662 December 15, 2022 04:19 Inactive
@broccolinisoup broccolinisoup temporarily deployed to github-pages December 15, 2022 05:04 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2662 December 15, 2022 05:04 Inactive
@broccolinisoup broccolinisoup temporarily deployed to github-pages December 15, 2022 05:14 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2662 December 15, 2022 05:14 Inactive
@broccolinisoup broccolinisoup temporarily deployed to github-pages December 15, 2022 10:50 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2662 December 15, 2022 10:50 Inactive
Copy link
Contributor

@colebemis colebemis left a comment

Choose a reason for hiding this comment

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

Looks good to go after you make the function name change 👍 Nice work on this @broccolinisoup 🎉

@broccolinisoup broccolinisoup temporarily deployed to github-pages December 28, 2022 02:21 — with GitHub Actions Inactive
@broccolinisoup broccolinisoup changed the title PageHeader: CSS media queries for responsive visibility with hidden prop PageHeader: Handle responsive CSS properties with breakpoints Dec 28, 2022
@broccolinisoup broccolinisoup merged commit 1266b10 into main Dec 28, 2022
@broccolinisoup broccolinisoup deleted the css-breakpoints-page-header branch December 28, 2022 03:01
@primer-css primer-css mentioned this pull request Dec 28, 2022
colebemis pushed a commit that referenced this pull request Jan 21, 2023
* try using media query instead of hook

* Update to use css media queries and make the func more generic

* add comments and rename the function

* update unit tests

* add changeset

* remove unused imports

* address code review feedback

* type fixes & small adj & add fallback CSS declaration

* type fix and add comment

* update tests

* update changeset description

* rename the function and move it into utils/
colebemis pushed a commit that referenced this pull request Jan 21, 2023
* try using media query instead of hook

* Update to use css media queries and make the func more generic

* add comments and rename the function

* update unit tests

* add changeset

* remove unused imports

* address code review feedback

* type fixes & small adj & add fallback CSS declaration

* type fix and add comment

* update tests

* update changeset description

* rename the function and move it into utils/
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