aboutsummaryrefslogtreecommitdiff
path: root/scss/_functions.scss
diff options
context:
space:
mode:
Diffstat (limited to 'scss/_functions.scss')
-rw-r--r--scss/_functions.scss37
1 files changed, 37 insertions, 0 deletions
diff --git a/scss/_functions.scss b/scss/_functions.scss
index 79f988feb..930232950 100644
--- a/scss/_functions.scss
+++ b/scss/_functions.scss
@@ -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});
+}