SU-SWS/decanter

View on GitHub
core/src/scss/utilities/functions/modular-scale/_calculate-modular-spacing.scss

Summary

Maintainability
Test Coverage

///
/// Calculates the modular spacing value at a step(integer) on the scale at a certain breakpoint.
///
/// The modular spacing value is calculated by multiplying the modular spacing base value at the requested breakpoint and the multiplier at the requested step of the scale.
///
/// The default value for $step is 0, which returns a multiplier value of 1, i.e., calculate-modular-spacing(0, 'xs') = $su-modular-spacing-base at XS breakpoint
///
/// @name calculate-modular-spacing
///
/// @param {Integer} $step - Integers from -4 to 9 including 0
/// @param {Breakpoint} $breakpoint - One of `xs`, `sm`, `md`, `lg`, `xl`, `2xl`
///
/// @group mixin
@function calculate-modular-spacing($step: 0, $breakpoint: 'xl') {
  @if ($step >= -4 and $step <= 9) {
    @return round(get-modular-spacing-base($breakpoint) * get-modular-spacing-multiplier($step) * 100) / 100;
  }
  @else {
    @error '$step should be an integer between -4 and 9';
  }
}