@use "sass:math";
@use "sass:meta";
@use "../variables";
@use "strip-unit" as *;

@function to-px($value, $base-font-size: variables.$base-font-size) {
  @if meta.type-of($value) == "number" {
    // If the value is a unitless number, assume it meant to be pixels
    @if math.is-unitless($value) {
      @return $value;
    } @else if math.unit($value) == "rem" or math.unit($value) == "em" {
      @return strip-unit($value * $base-font-size) + 0px;
    } @else if math.unit($value) == "px" {
      @return $value;
    }
  }

  @error "Invalid value \"#{$value}\" given to fluid()";
}
