aboutsummaryrefslogtreecommitdiff
path: root/scss/_functions.scss
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2021-07-29 09:14:40 +0300
committerGitHub <[email protected]>2021-07-29 09:14:40 +0300
commitef5336373fc2431b3d1d37cde85cd262210a1dc6 (patch)
treee325fb4c5532b464d05780c731d0f118f2a88d7f /scss/_functions.scss
parent62edf07d7491684fe67a9c1e9439ed2bd10ca741 (diff)
parentc6c0bbb0b67fe89b55740a63fd10d4ad79044970 (diff)
downloadbootstrap-main-fod-simpler-table-structure.tar.xz
bootstrap-main-fod-simpler-table-structure.zip
Merge branch 'main' into main-fod-simpler-table-structuremain-fod-simpler-table-structure
Diffstat (limited to 'scss/_functions.scss')
-rw-r--r--scss/_functions.scss63
1 files changed, 39 insertions, 24 deletions
diff --git a/scss/_functions.scss b/scss/_functions.scss
index 2d3478bfa..1f3263175 100644
--- a/scss/_functions.scss
+++ b/scss/_functions.scss
@@ -55,6 +55,16 @@
@return $result;
}
+// Merge multiple maps
+@function map-merge-multiple($maps...) {
+ $merged-maps: ();
+
+ @each $map in $maps {
+ $merged-maps: map-merge($merged-maps, $map);
+ }
+ @return $merged-maps;
+}
+
// Replace `$search` with `$replace` in `$string`
// Used on our SVG icon backgrounds for custom forms.
//
@@ -181,14 +191,6 @@ $_luminance-list: .0008 .001 .0011 .0013 .0015 .0017 .002 .0022 .0025 .0027 .003
@return $value1 + $value2;
}
- @if type-of($value1) != number {
- $value1: unquote("(") + $value1 + unquote(")");
- }
-
- @if type-of($value2) != number {
- $value2: unquote("(") + $value2 + unquote(")");
- }
-
@return if($return-calc == true, calc(#{$value1} + #{$value2}), $value1 + unquote(" + ") + $value2);
}
@@ -209,10 +211,6 @@ $_luminance-list: .0008 .001 .0011 .0013 .0015 .0017 .002 .0022 .0025 .0027 .003
@return $value1 - $value2;
}
- @if type-of($value1) != number {
- $value1: unquote("(") + $value1 + unquote(")");
- }
-
@if type-of($value2) != number {
$value2: unquote("(") + $value2 + unquote(")");
}
@@ -221,26 +219,43 @@ $_luminance-list: .0008 .001 .0011 .0013 .0015 .0017 .002 .0022 .0025 .0027 .003
}
@function divide($dividend, $divisor, $precision: 10) {
- $sign: if($dividend > 0 and $divisor > 0, 1, -1);
+ $sign: if($dividend > 0 and $divisor > 0 or $dividend < 0 and $divisor < 0, 1, -1);
$dividend: abs($dividend);
$divisor: abs($divisor);
- $quotient: 0;
- $remainder: $dividend;
@if $dividend == 0 {
@return 0;
}
@if $divisor == 0 {
@error "Cannot divide by 0";
}
- @if $divisor == 1 {
- @return $dividend;
- }
- @while $remainder >= $divisor {
- $quotient: $quotient + 1;
- $remainder: $remainder - $divisor;
+ $remainder: $dividend;
+ $result: 0;
+ $factor: 10;
+ @while ($remainder > 0 and $precision >= 0) {
+ $quotient: 0;
+ @while ($remainder >= $divisor) {
+ $remainder: $remainder - $divisor;
+ $quotient: $quotient + 1;
+ }
+ $result: $result * 10 + $quotient;
+ $factor: $factor * .1;
+ $remainder: $remainder * 10;
+ $precision: $precision - 1;
+ @if ($precision < 0 and $remainder >= $divisor * 5) {
+ $result: $result + 1;
+ }
}
- @if $remainder > 0 and $precision > 0 {
- $remainder: divide($remainder * 10, $divisor, $precision - 1) * .1;
+ $result: $result * $factor * $sign;
+ $dividend-unit: unit($dividend);
+ $divisor-unit: unit($divisor);
+ $unit-map: (
+ "px": 1px,
+ "rem": 1rem,
+ "em": 1em,
+ "%": 1%
+ );
+ @if ($dividend-unit != $divisor-unit and map-has-key($unit-map, $dividend-unit)) {
+ $result: $result * map-get($unit-map, $dividend-unit);
}
- @return ($quotient + $remainder) * $sign;
+ @return $result;
}