1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-16 02:24:19 +02:00

Add add and subtract function

This commit is contained in:
ysds
2019-09-03 20:18:44 +03:00
committed by XhmikosR
parent c62efc3ef6
commit d6ebc60d3d
7 changed files with 106 additions and 30 deletions

View File

@@ -108,3 +108,40 @@
@function shade-color($color, $level) {
@return mix(black, $color, $level * $theme-color-interval);
}
// Return valid calc
@function add($value1, $value2, $return-calc: true) {
@if $value1 == null {
@return $value2;
}
@if $value2 == null {
@return $value1;
}
@if type-of($value1) == number and type-of($value2) == number and comparable($value1, $value2) {
@return $value1 + $value2;
}
@return if($return-calc == true, calc(#{$value1} + #{$value2}), #{$value1} + #{$value2});
}
@function subtract($value1, $value2, $return-calc: true) {
@if $value1 == null and $value2 == null {
@return null;
}
@if $value1 == null {
@return -$value2;
}
@if $value2 == null {
@return $value1;
}
@if type-of($value1) == number and type-of($value2) == number and comparable($value1, $value2) {
@return $value1 - $value2;
}
@return if($return-calc == true, calc(#{$value1} - #{$value2}), #{$value1} - #{$value2});
}