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

Support full media queries in theme.breakpoints in @theme-ui/match-media hooks #2199

Merged
merged 8 commits into from
Apr 21, 2022

Conversation

hasparus
Copy link
Member

@hasparus hasparus commented Apr 8, 2022

Closes #2197.

So, turns out @theme-ui/match-media isn't too popular and we just didn't remember about it when we added full media query support to responsive values in sx prop.

📦 Published PR as canary version: 0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0

✨ Test out this PR locally via:

npm install @theme-ui/color-modes@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/color@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/components@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/core@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/css@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/custom-properties@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/editor@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install gatsby-plugin-theme-ui@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install gatsby-theme-style-guide@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install gatsby-theme-ui-layout@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/match-media@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/mdx@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/parse-props@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/preset-base@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/preset-bootstrap@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/preset-bulma@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/preset-dark@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/preset-deep@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/preset-funk@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/preset-future@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/preset-polaris@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/preset-roboto@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/preset-sketchy@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/preset-swiss@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/preset-system@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/preset-tailwind@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/preset-tosh@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/presets@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/prism@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/sidenav@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/style-guide@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/tailwind@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/theme-provider@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install theme-ui@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
npm install @theme-ui/typography@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
# or 
yarn add @theme-ui/color-modes@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/color@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/components@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/core@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/css@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/custom-properties@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/editor@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add gatsby-plugin-theme-ui@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add gatsby-theme-style-guide@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add gatsby-theme-ui-layout@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/match-media@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/mdx@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/parse-props@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/preset-base@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/preset-bootstrap@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/preset-bulma@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/preset-dark@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/preset-deep@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/preset-funk@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/preset-future@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/preset-polaris@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/preset-roboto@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/preset-sketchy@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/preset-swiss@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/preset-system@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/preset-tailwind@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/preset-tosh@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/presets@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/prism@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/sidenav@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/style-guide@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/tailwind@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/theme-provider@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add theme-ui@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0
yarn add @theme-ui/typography@0.14.3--canary.2199.c124ac7c4eaa771a50ae43f2dd1bc0aa7ca2bdab.0

@vercel
Copy link

vercel bot commented Apr 8, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/systemui/theme-ui/C3vDibCQeZpcqzJDpN3CgbANk5jL
✅ Preview: https://theme-ui-git-match-media-breakpoints-systemui.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 8, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit de50e7d:

Sandbox Source
next-theme-ui-example Configuration
gatsby-plugin-theme-ui-example Configuration

Copy link
Member

@lachlanjc lachlanjc left a comment

Choose a reason for hiding this comment

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

Source looks good to me!

).length
breakpoints.filter((bp) => {
const query = bp.includes('@media')
? bp.slice(7) // remove '@media '
Copy link
Member

Choose a reason for hiding this comment

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

bp.replace('@media ', '') might be more readable, I don't feel strongly though

Copy link
Member Author

@hasparus hasparus Apr 20, 2022

Choose a reason for hiding this comment

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

Fair point 🙏 My code is actually buggy. If you have a leading space (like @media), my version wouldn't work, and yours is more permissive. Applying your suggestion!

@vercel
Copy link

vercel bot commented Apr 20, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
theme-ui ✅ Ready (Inspect) Visit Preview Apr 20, 2022 at 2:55PM (UTC)

@hasparus hasparus merged commit d2946ef into develop Apr 21, 2022
@hasparus hasparus deleted the match-media-breakpoints branch April 21, 2022 13:19
@hasparus
Copy link
Member Author

🚀 PR was released in v0.14.3 🚀

@hasparus hasparus added the released This issue/pull request has been released. label Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useBreakpointIndex and useResponsiveValue don't handle full @media queries in theme.breakpoints
2 participants