
/* UNIT */

@function px ( $length ) {

  $unit: unit( $length );

  @if $unit == 'px' {

    @return $length;

  } @else if $unit == 'em' {

    @return $length / 1em * $font-size;

  } @else if $unit == 'rem' {

    @return $length / 1rem * $font-size;

  } @else {

    @error 'Unit `#{$unit}` is not supported. Supported units: px, em, rem';

  }

}

@function em ( $length ) {

  $unit: unit( $length );

  @if $unit == 'em' {

    @return $length;

  } @else if $unit == 'rem' {

    @return $length / 1rem * 1em;

  } @else if $unit == 'px' {

    @return $length / $font-size * 1em;

  } @else {

    @error 'Unit `#{$unit}` is not supported. Supported units: em, rem, px';

  }

}

@function rem ( $length ) {

  $unit: unit( $length );

  @if $unit == 'rem' {

    @return $length;

  } @else if $unit == 'em' {

    @return $length / 1em * 1rem;

  } @else if $unit == 'px' {

    @return $length / $font-size * 1rem;

  } @else {

    @error 'Unit `#{$unit}` is not supported. Supported units: rem, em, px';

  }

}
