question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does not accept custom breakpoints as ems

See original GitHub issue

We all now, that relay just on pixels is not enough, so I tried to have breakpoints based on em values, but some how converts these em values to new ems:

I am using: “next”: “^8.0.0”, “react”: “^16.8.1”, “react-dom”: “^16.8.1”, “styled-breakpoints”: “^6.6.2”, “styled-components”: “^4.1.3”, “styled-normalize”: “^8.0.6”, “styled-theme”: “^0.3.3”

const theme = {
  breakpoints:{
      xs: '30em',
      sm: '50em',
      md: '60em',
      lg: '80em',
      xl: '120em',
  }
}
const Container = styled.div`
  ${down('md')} {
    color: rebeccapurple;
  }
`

This is what I got SSR rendered:

/* sc-component-id: PageTitle__Container-c1sqxi-0 */
 @media (min-width:48em) and (max-width:61.99875em){
   .bsEiBw{color:rebeccapurple;}
 }
 @media (min-width:1.875em) and (max-width:3.12375em){
   .jQjQlc{color:rebeccapurple;}
 }
 @media (min-width:3.125em) and (max-width:3.74875em){
   .bBciUM{color:rebeccapurple;}
 }
 @media (max-width:2.62375em){
   .haykbX{color:rebeccapurple;}
 }
 @media (max-width:47.99875em){
   .imXVfl{color:rebeccapurple;}
 }
 @media (max-width:4.99875em){
   .bANXey{color:rebeccapurple;}
 }
 @media (max-width:4.99875em){
   .gZDZUq{color:rebeccapurple;}
 }
 @media (max-width:4.99875em){
   .pTrKY{color:rebeccapurple;}
 }

If I use px as breakpoint values, then all is working as expected.

Current element has class gZDZUq

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
DanWebbcommented, May 18, 2019

@mg901 Could the lib just not be concerned about the units of measurement being used by removing the unit conversion like: https://github.com/DanWebb/styled-breakpoints/commit/2cc404ae01ce0060ac0e5d36266905439c0073a2 this will be needed because once you add px someone will come along asking for rem then pt

Is the reason you currently need the conversion due to how getting the next breakpoint value works?

1reaction
mg901commented, Apr 3, 2019

@lauriskuznecovs, first of all, I want to thank you for using styled-breakpoints. I will fix this problem within 24 hours. If you can fix this faster, send me a PR decision.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Use CSS Breakpoints For Responsive Design
CSS media query breakpoints can be selected based on the device on which the website is being rendered. However, this is not a...
Read more >
Issue with min and max media queries due to using ems?
I've built a few sites with both min and max width media queries, and for me they've been painfully difficult to maintain and...
Read more >
Approaches to Media Queries in Sass - CSS-Tricks
If an operator is found, it is extracted and any matching breakpoint will be returned, or else we assume it's a custom value...
Read more >
Switching between breakpoints causes useBreakpoint to ...
log I have been using inside the use-breakpoint snippet above doesn't seem to log the md breakpoint when using createBreakpoints (and ems not...
Read more >
Additional Custom Breakpoints - Technical Details and Gotchas
There you go, the Additional Custom Breakpoints experiment should now be ... Elementor is no longer going to support accessing responsive ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found