4.2 breaking change: custom $grid-breakpoints that are smaller than default ones give errors
See original GitHub issueI’m unable to compile sass with the new $grid-breakpoint changes. This worked just fine with 4.1. It now doesn’t seem possible with 4.2
In my custom variable file that’s included before everything BS4 I have the following:
$grid-breakpoints: (
xxs: 0,
xs: 480px,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px
);
As you can see, an additional custom breakpoint exists at 480px.
Previously 4.1 _variable.sass
contained:
$grid-breakpoints: (
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px
) !default;
@include _assert-ascending($grid-breakpoints, "$grid-breakpoints");
@include _assert-starts-at-zero($grid-breakpoints);
And my code overrode all the breakpoints and worked fine.
Now in 4.2 _variable.sass:
$grid-breakpoints: () !default;
// stylelint-disable-next-line scss/dollar-variable-default
$grid-breakpoints: map-merge(
(
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px
),
$grid-breakpoints
);
@include _assert-ascending($grid-breakpoints, "$grid-breakpoints");
@include _assert-starts-at-zero($grid-breakpoints);
And it gives the following errors:
WARNING: Invalid value for $grid-breakpoints: This map must be in ascending order, but key 'xxs' has value 0 which isn't greater than 1200px, the value of the previous key 'xl' !
WARNING: First breakpoint in `$grid-breakpoints` must start at 0, but starts at 480px.
WARNING: Invalid value for $container-max-widths: This map must be in ascending order, but key 'xs' has value 500px which isn't greater than 1140px, the value of the previous key 'xl' !
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Changing grid breakpoints doesnt work properly
Hello. I am trying to change grid breakpoints and container max width by means of creating my own custom.scss file that contain code...
Read more >Grid system - Bootstrap
Use our powerful mobile-first flexbox grid to build layouts of all shapes and sizes thanks to a twelve column system, five default responsive...
Read more >Customize Bootstrap 4's grid-system Breakpoints - css
I need to change that xl breakpoint globally for bootstrap. Do I have to recompile Bootstrap 4 from the source files? I tried...
Read more >4.2 Customizing ggplot2 Plots - GitHub Pages
This overview will provide a framework for describing how to customize ... One quick way to increase data density in ggplot2 is to...
Read more >4.2 Simple base R plots | An Introduction to R
To plot a scatterplot of one numeric variable against another numeric ... Let's set the font size to be 30% smaller than the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think we need to ditch these built-in
map-merge
s for regular Sass maps. It now feels over-engineered, and perhaps poorly documented for how folks can customize things.With the usage of
map-merge
everywhere, we have the ability to easily add key-value pairs, but not to remove them. There’s no option in Sass to do this, but you can replace a value or add new ones (withmap-merge
). This is an issue because if you want fewer key-value pairs in a Sass map, you’ll see errors like those of https://github.com/twbs/bootstrap/issues/27927#issuecomment-450060013.So, what if we remove all
map-merge
in our variables?Let’s consider an example where we look at our
$grid-breakpoints
.To replace all of the values, we redefine the keys’ values:
To replace individual key-value pairs, we use
map-merge
:To add additional values, we also use
map-merge
:To do a bit of everything, we can use replace the default values and use multiple
map-merge
s:You can see all of this in this Sassmeister gist.
It’s also possible to sort maps after merge, I tried with this gist and it worked without changing anything else : https://gist.github.com/Jakobud/a0ac11e80a1de453cd86f0d3fc0a1410#gistcomment-2327765