Skip to content
Snippets Groups Projects
Commit 182d1b6b authored by Ivica Puljic's avatar Ivica Puljic
Browse files

Issue #3414072 by pivica: SASS map variables override flexibility

parent 6bac3237
No related branches found
No related tags found
No related merge requests found
...@@ -86,7 +86,7 @@ $base-fonts: () !default; ...@@ -86,7 +86,7 @@ $base-fonts: () !default;
// Additional fonts that can be defined in child theme. // Additional fonts that can be defined in child theme.
$additional-fonts: () !default; $additional-fonts: () !default;
// Final theme fonts definition that will be used for font family generation. // Final theme fonts definition that will be used for font family generation.
$theme-fonts: map-merge($base-fonts, $additional-fonts) !default; $theme-fonts: bs-map-merge($base-fonts, $additional-fonts) !default;
// Base font size used for HTML tag. Everything else should use rem units. // Base font size used for HTML tag. Everything else should use rem units.
// http://bootstrap-documentation/docs/4.0/content/reboot/#page-defaults state // http://bootstrap-documentation/docs/4.0/content/reboot/#page-defaults state
...@@ -267,7 +267,7 @@ $navbar-brand-max-width: 75% !default; ...@@ -267,7 +267,7 @@ $navbar-brand-max-width: 75% !default;
// Navbar brand responsive widths. // Navbar brand responsive widths.
$navbar-brand-responsive-widths: () !default; $navbar-brand-responsive-widths: () !default;
@if ($navbar-brand-responsive-widths) { @if ($navbar-brand-responsive-widths) {
$navbar-brand-responsive-widths: map-merge(( $navbar-brand-responsive-widths: bs-map-merge((
xs: $navbar-brand-max-width, xs: $navbar-brand-max-width,
$responsive-break: $brand-logo-max-width, $responsive-break: $brand-logo-max-width,
), $navbar-brand-responsive-widths); ), $navbar-brand-responsive-widths);
...@@ -276,7 +276,7 @@ $navbar-brand-responsive-widths: () !default; ...@@ -276,7 +276,7 @@ $navbar-brand-responsive-widths: () !default;
$navbar-brand-vertical-margins: () !default; $navbar-brand-vertical-margins: () !default;
@if ($navbar-brand-vertical-margins) { @if ($navbar-brand-vertical-margins) {
$navbar-brand-vertical-margins: map-merge( $navbar-brand-vertical-margins: bs-map-merge(
( (
xs: ( xs: (
'top': $spacer, 'top': $spacer,
......
...@@ -9,3 +9,69 @@ ...@@ -9,3 +9,69 @@
@function bs-icon-content($icon-name) { @function bs-icon-content($icon-name) {
@return bs-content(map-get($bs-icon-map, $icon-name)); @return bs-content(map-get($bs-icon-map, $icon-name));
} }
// If key exists in map it returns the key value, if not returns default value.
@function bs-map-get-default($map, $key, $default) {
@return if(map-has-key($map, $key), map-get($map, $key), $default);
}
// Map deep get.
// See https://css-tricks.com/snippets/sass/deep-getset-maps/
@function bs-map-deep-get($map, $keys...) {
@each $key in $keys {
$map: map-get($map, $key);
}
@return $map;
}
// Merge two maps. Similar to the map-merge built into SCSS, but has added
// functionality to remove any key/value pair from the resulting map where the
// value is null.
@function bs-map-merge($map1, $map2) {
$result: map-merge($map1, $map2);
// Remove any null from a map. This allows child themes to
// remove values they not want by setting them to null.
@each $key, $value in $result {
@if ($value == null) {
$result: map-remove($result, $key);
}
}
@return $result;
}
// Merges two multidimensional maps recursively.
// It will remove any key/value pair from the resulting map where the value is
// null.
// @see https://github.com/pentzzsolt/sass-recursive-map-merge
@function bs-map-recursive-merge($map1, $map2, $config:() ) {
@if (type-of($map1) == map or (type-of($map1) == list and length($map1) == 0)) and (type-of($map2) == map or (type-of($map2) == list and length($map2) == 0)) {
$result: $map1;
@each $key, $value in $map2 {
@if (type-of(map-get($result, $key)) == map and type-of($value) == map) {
$result: map-merge($result, ($key: bs-map-recursive-merge(map-get($result, $key), $value)));
}
@else if (map-get($config, "merge-lists") and type-of(map-get($result, $key)) == list and type-of($value) == list) {
$result: map-merge($result, ($key: join(map-get($result, $key), $value)));
}
@else {
$result: map-merge($result, ($key: $value));
}
}
// Remove any null from a map. This allows child themes to
// remove values they not want by setting them to null.
@each $key, $value in $result {
@if ($value == null) {
$result: map-remove($result, $key);
}
}
@return $result;
}
@else {
@warn "bs-map-recursive-merge() expects it\'s parameters to be map types!";
@return null;
}
}
...@@ -94,6 +94,6 @@ $bs-icon-font-family: 'BS Icons' !default; ...@@ -94,6 +94,6 @@ $bs-icon-font-family: 'BS Icons' !default;
$bs-icon-class: 'fa' !default; $bs-icon-class: 'fa' !default;
// Additional icon shims. // Additional icon shims.
$bs-icon-shims: () !default; $bs-icon-shims: () !default;
$bs-icon-shims: map-merge(( $bs-icon-shims: bs-map-merge((
fa-close: fa-xmark, fa-close: fa-xmark,
), $bs-icon-shims); ), $bs-icon-shims);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment