@charset "UTF-8";

///
/// Returns $value (a number) expressed in $unit
///
/// @name to-length
///
/// @param {Integer} $value - Number value to add unit to
/// @param {String} $unit - String representation of the unit
///
/// @group mixin
@function to-length($value, $unit) {
  $units: ('px': 1px, 'cm': 1cm, 'mm': 1mm, '%': 1%, 'ch': 1ch, 'pc': 1pc, 'in': 1in, 'em': 1em, 'rem': 1rem, 'pt': 1pt, 'ex': 1ex, 'vw': 1vw, 'vh': 1vh, 'vmin': 1vmin, 'vmax': 1vmax);

  @if not index(map-keys($units), $unit) {
    $_: log('Invalid unit `#{$unit}`.');
  }

  @return $value * map-get($units, $unit);
}
