/* ============================================================================
   @CORE -> FUNCTIONS -> CONVERT PX TO EM/REM
   ========================================================================= */


/**
 * To convert `px` to `em`s or `rem`s.
 *
 * N.B. this function is used mainly to feed the mixins.
 *
 * @example
   .foo {margin-left: to-em(8, 20);}
   .foo {padding: to-rem(8) 0;}
 *
 */


/**
 * `em`.
 */

@function to-em($value, $context: $font-size) {
  // If value is a named breakpoint
  @if type-of($value) == "string" {
    @if map-has-key($breakpoints, $value) {
      $value: map-get($breakpoints, $value);
    } @else {
      @warn "Breakpoint name '#{$value}' not recognised.";
    }// endif
  }// endif
  @return $value / $context * 1em;
}


/**
 * `rem`.
 */

@function to-rem($value) {
  @return $value / $font-size * 1rem;
}
