Sha256: aa29d922791618b9da43c2aba9bd27cf6aa47b0fb54b5cc4b701b714cba66822

Contents?: true

Size: 913 Bytes

Versions: 2

Compression:

Stored size: 913 Bytes

Contents

// --------------
// EM CONVERTER
// --------------

// Strips unit and return plain number
@function _stripUnit($num) {
  @return $num / ($num * 0 + 1);
}

// Convert the number to EM
@function _convertToEm($value, $context: $body-font-size) {
  // if not number, return it as is
  @if type-of($value) != number { @return $value; }
  
  $value: _stripUnit($value) / _stripUnit($context) * 1em;
  // turn 0em into 0
  @if ($value == 0em) {
    $value: 0;
  }
  @return $value;
}

@function em($values, $context: $body-font-size) {
  // if only contain single number, convert it directly
  @if type-of($values) == number {
    @return _convertToEm($values, $context);
  }
  
  // if contains multiple values, loop through it
  $emValues   : ();
  @each $val in $values {
    $emValues: append($emValues, hConvertToEm($val, $context) );
  }
  @return join((), $emValues, space );
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
edge_framework-2.1.1 assets/sass/edge/utility/_em.scss
edge_framework-2.1.0 assets/sass/edge/utility/_em.scss