math.calculate()
// Sass.
@use 'sass:list';
@use 'sass:meta';
// The `math.calculate()` function.
@function calculate($operations...) {
@each $value, $operator,
$operand in if(list.length($operations) == 3, ($operations), $operations)
{
@if $value and $operand {
@if $operator == '+' {
@return calc($value + $operand);
} @else if $operator == '-' {
@return calc($value - $operand);
} @else if $operator == '*' {
@return calc($value * $operand);
} @else if $operator == '/' {
@return calc($value / $operand);
}
}
}
@return null;
}https://github.com/angular-package/sass/blob/main/math/_math.calculate.function.scss
Parameters
$operations...
$operations...Return
Examples
Last updated