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.

Responsive font size with breakpoints aliases generates media queries in incorrect order

See original GitHub issue

Bug report

Describe the bug

If I use: <Heading fontSize={["30px", "45px", "60px", "90px", "180px"]}> The css generated is in the correct order:

@media screen and (min-width: 80em)
<style>
.css-1yf13mp {
    font-size: 180px;
}
@media screen and (min-width: 62em)
<style>
.css-1yf13mp {
    font-size: 90px;
}
@media screen and (min-width: 620px)
<style>
.css-1yf13mp {
    font-size: 60px;
}
@media screen and (min-width: 400px)
<style>
.css-1yf13mp {
    font-size: 45px;
}

If I use: <Heading fontSize={{ base: "30px", sm: "45px", md: "60px", lg: "90px", xl: "180px" }}> The css generated is in the wrong order thus the font size applied is not the right one.

@media screen and (min-width: 620px)
<style>
.css-yxyd02 {
    font-size: 60px;
}
@media screen and (min-width: 400px)
<style>
.css-yxyd02 {
    font-size: 45px;
}
@media screen and (min-width: 80em)
<style>
.css-yxyd02 {
    font-size: 180px;
}
@media screen and (min-width: 62em)
<style>
.css-yxyd02 {
    font-size: 90px;
}

In that case for instance on a desktop (1920px), it’s the 620px breakpoint size which is applied.

Expected behavior

I’d expect the generated media queries to be in the right order.

System information

  • OS: Linux
  • Browser (if applies): Chrome (but not tested on other browsers)
  • Version of @chakra-ui/core: 1.0.0-rc.3
  • Version of Node.js: 12.15.0

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
trompxcommented, Sep 29, 2020

My bad I did a simple yarn add @chakra-ui/theme-tools. All is working perfectly now, thanks! There is just a small typo in the docs: import { createBreakpoints } from "chakra-ui/theme-tools" is missing the @ in front of chakra-ui.

0reactions
ljosberinncommented, Sep 29, 2020

Neat, glad its resolved 😃 Regarding the typo, thanks, yes, we have a PR for that which I should merge anyways.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Responsive Typography With Sass Maps - Smashing Magazine
Let's start by creating a Sass map with key-value pairs — breakpoints as keys and font sizes as corresponding values. ... With mobile-first...
Read more >
Responsive typography with chained media queries - Bugsnag
Chaining complex media queries​​ If your project includes Breakpoint, the responsive mixin calls it to generate each of the chained media queries ......
Read more >
Responsive Layouts, Fewer Media Queries | CSS-Tricks
Since we are changing the number of items per rows between three values, we need two “breakpoints” (from N to M , and...
Read more >
CSS: max-width for @media query not working - Stack Overflow
Have you tried adding the viewport in? <meta name="viewport" content="width=device-width, initial-scale=1">. Working JSFiddle.
Read more >
Responsive web design basics
To insert a breakpoint at 600px , create two media queries at the end of your CSS for the component, one to use...
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