@use "sass:map";
@use "sass:math";
@use "../tools/convert";

$map: (
  "none": 0,
  "xsmall": 5px,
  "small": 10px,
  "medium": 20px,
  "large": 30px,
  "xlarge": 60px,
);

/// Get space size from $space
/// @param {String} $size ['medium'] - Size of space
/// @example
///   get-space();
///   get-space('small');
@function get($size: "medium") {
  @if map.has-key($map, $size) {
    $space: map.get($map, $size);

    @return if(math.unit($space) == "rem", $space, convert.to-rem($space));
  } @else {
    @error 'Cannot find key ($size) \'#{$size}\' in $space \'#{$space}\'';
  }
}
