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
[breakpoints] Fix down function, eliminate overlap #6504
Conversation
- Should be consistent with the only function and set a max-width of 1 pixel less than the size of the specified breakpoint so that there isn't an overlap of 1 pixel.
- use step instead of 1px
- Removing a pixel is too much. In Chrome and Edge inspectors, a viewport of 599 is actually 599.2. We only need to ensure that it is less than 600. - Subtract 1 percent of our step in Down and Between.
Test case for the docs site (stylesheet from /src/components/AppContent.js):
Removing one pixel (as defined in the step variable) is too much because some viewports render with a fraction of a pixel. For example, Chrome and Edge inspectors render a 599px viewport as 599.2, which is greater than the max-width we're defining. We only need to be less than the size defined for the specified breakpoint. With the example above, setting a viewport to 1279px in Chrome's inspector should apply the between sm and md rules, but they are not getting applied because the actual width is greater: 1279.2px. To fix this, I've subtracted 1% of our step. This would set the max-width to 1279.99 for the between sm, md rules and 599.99 for the down sm rules, ensuring that edge case viewports are properly styled. |
- update test to check for new max widths - max-width will be 0.01 pixel less than the next breakpoint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for giving a shot at this issue. The overall logic looks good to me. I have been looking at what bootstrap is doing for some context: https://github.com/twbs/bootstrap/blob/v4-dev/scss/mixins/_breakpoints.scss#L38.
Thanks. |
Consider the following:
There is a 1px overlap because down sets a max-width equal to the size defined for the specified breakpoint. This is inconsistent with only which defines a max-width which is 1px less than the size defined for the next breakpoint.
This has been submitted as issue #6503.
This PR fixes the down function so that the max-width is set to 1px less than the size defined for the specified breakpoint and updates the test in the spec so that this change is accounted for.