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

useBreakpointIndex and useResponsiveValue don't handle full @media queries in theme.breakpoints #2197

Closed
hasparus opened this issue Apr 7, 2022 Discussed in #2195 · 4 comments · Fixed by #2199
Closed
Assignees
Labels
bug Something isn't working released This issue/pull request has been released.

Comments

@hasparus
Copy link
Member

hasparus commented Apr 7, 2022

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

Thanks for finding this @danimadmolil 🙏.

Discussed in #2195

Originally posted by danimadmolil April 7, 2022
Hellow, i'm new to theme-ui. my project is simple react-app.on index.js i create a theme and use it with ThemeProvider like this:

index.js

const theme = {
 breakpoints: [
    "@media screen and (min-width:300px) and (max-width:499px)",
    "@media screen and (min-width: 500px) and (max-width:899px)",
    "@media screen and (min-width: 900px)",
  ],
} 
<ThemeProvider theme={theme}>
   <App/>
</ThemeProvider>

App.js

import { useResponsiveValue, useBreakpointIndex } from "@theme-ui/match-media";
function App(){
  const color = useResponsiveValue((theme) => ["red", "blue", "orange"]);
  return <div className="app" style={{backgroundColor:color}}></div>
} 

the result color is always red. i'm not whay it's like that. can any one help me please?
note:if i use breakpoint:['40em','50em','60em'] it work fine but i like to use media queries with condition like (min-width) and (max-width).

@hasparus hasparus added the bug Something isn't working label Apr 7, 2022
@hasparus hasparus self-assigned this Apr 7, 2022
hasparus added a commit that referenced this issue Apr 8, 2022
hasparus added a commit that referenced this issue Apr 8, 2022
@hasparus
Copy link
Member Author

🚀 Issue was released in v0.14.3 🚀

@hasparus hasparus added the released This issue/pull request has been released. label Apr 21, 2022
@manwaring
Copy link

Not sure if a regression or I'm just misconfiguring but the same issue originally reported is happening for me in v0.16.1

@sbeben
Copy link

sbeben commented Oct 7, 2024

none of the versions works for me

@hasparus
Copy link
Member Author

@sbeben what's your setup? Framework, package manager version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants