-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
4.2 breaking change: custom $grid-breakpoints that are smaller than default ones give errors #27927
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
Comments
The def of map-merge() specifies that the order of /**
* Merges two maps together into a new map. Keys in `$map2` will take
* precedence over keys in `$map1`.
*
* This is the best way to add new values to a map.
*
* All keys in the returned map that also appear in `$map1` will have the
* same order as in `$map1`. New keys from `$map2` will be placed at the end
* of the map.
*
* Like all map functions, `map-merge()` returns a new map rather than
* modifying its arguments in place.
*
* @example
* map-merge(("foo": 1), ("bar": 2)) => ("foo": 1, "bar": 2)
* map-merge(("foo": 1, "bar": 2), ("bar": 3)) => ("foo": 1, "bar": 3)
* @overload map_merge($map1, $map2)
* @param $map1 [Sass::Script::Value::Map]
* @param $map2 [Sass::Script::Value::Map]
* @return [Sass::Script::Value::Map]
* @raise [ArgumentError] if either parameter is not a map
*/
@function map_merge($map1, $map2) { /* stub */ } Since, unlike the other maps that are merged, the order is important, To achieve this I think the double application of map-merge() should take care of it: $grid-breakpoints: () !default;
// stylelint-disable-next-line scss/dollar-variable-default
$grid-breakpoints-ordered: map-merge(
$grid-breakpoints,
(
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px
)
);
$grid-breakpoints: map-merge($grid-breakpoints-ordered, $grid-breakpoints) Unless there's some other sass function that could handle this, I'm not sure of any better way. |
Additionally the docs give a specific use example:
which is no longer true since by just defining fewer breakpoints, the default ones will be added back in on merge. |
I have the same problem, i'm trying to compile with https://github.com/leafo/scssphp |
Have you solved in this way for now? |
Sticking to Bootstrap 4.1 until the following issue is resolved: twbs/bootstrap#27927
Nah, I solved it by changing the dep from $container-max-widths: () !default;
// stylelint-disable-next-line scss/dollar-variable-default
$container-max-widths-order: map-merge(
$container-max-widths,
(
sm: 540px,
md: 720px,
lg: 960px,
xl: 1140px
)
);
$container-max-widths: map-merge($container-max-widths-order, $container-max-widths); |
/CC @MartijnCuppens |
I think we need to ditch these built-in With the usage of So, what if we remove all Let's consider an example where we look at our $grid-breakpoints: (
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px
) !default; To replace all of the values, we redefine the keys' values: $grid-breakpoints: (
xs: 0,
sm: 400px,
md: 800px,
lg: 1200px,
xl: 1600px
); To replace individual key-value pairs, we use $grid-breakpoints: (
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px
) !default;
$grid-breakpoints: map-merge($grid-breakpoints, (xl: 1600px)); To add additional values, we also use $grid-breakpoints: map-merge(
$grid-breakpoints,
(
xxl: 1600px,
xxxl: 1800px
)
); To do a bit of everything, we can use replace the default values and use multiple $grid-breakpoints: (
xs: 300px,
sm: 500px,
md: 800px,
lg: 1100px,
xl: 1400px
);
$grid-breakpoints: map-merge(
(
xxs: 0
),
$grid-breakpoints
);
$grid-breakpoints: map-merge(
$grid-breakpoints,
(
xxl: 1600px,
xxxl: 1800px
)
); |
Hi @mdo
but these are the results:
Can you help us, please? Thanks a lot. Benedetto |
@Bek81 There's also no use in using the merge-map in your own definitions of the variables. The last example @bdo gave would have to have the extra xxs and xxl variables in like $breakpoints-before / $breakpoints-after which is way overly complicated. The example I provided makes overriding the breakpoints nearly the same as 4.1, but still has the issue of not being able to remove breakpoints. Reverting to the way it was done in 4.1 without merge-map seems like it might be the best solution. The update provides no benefit other than being able to override a single break point or add one larger, most other cases you'd need to override each breakpoint manually anyway. |
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 |
This is preventing us from upgrading to 4.2 |
Hi there, I would suggest to just revert the new $grid-breakpoints declaration to what it was before, on the 4.1 version:
the new approach uses:
so when you try to update the variable using your custom.scss like this:
the _assert_ascending function will throw the following warning:
Adding @debug $key; @debug $num; you can easily see what's going on.
The ss value I've added in my custom.scss goes to end of the map so this function. Note that this is just a warning so the CSS gets compiled. If you really want to avoid this warning message you can (temporary and hacky fix) comment this line: |
Uh oh!
There was an error while loading. Please reload this page.
I'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:
As you can see, an additional custom breakpoint exists at 480px.
Previously 4.1
_variable.sass
contained:And my code overrode all the breakpoints and worked fine.
Now in 4.2 _variable.sass:
And it gives the following errors:
The text was updated successfully, but these errors were encountered: