@use 'sass:list';
@use 'sass:math';
@use '../functions/units';
// NOTE does not set border, $border is only used for calculations

// setting $height and $vertical-padding will use $font-size and overwrite
// any values set to the other variable ie $height overrides
// $vertical-padding and the other way around. $height takes precedence
@mixin input-size($height: false, $padding: false, $border: 0px, $spacing: 0, $font-size: $base-font-size) {
  @if $height == false and $padding == false {
    @error "You HAVE to supply at least one of the following: $height, $padding.";
  }

  @if $padding == false {
    $padding: 0 0;
  } @else if type-of($padding) != 'list' {
    $padding: $padding $padding;
  }

  $font-size: units.px($font-size);
  $border: units.px($border);

  @if $height != false {
    $height: units.px($height);

    $padding: math.div(($height - $font-size - $border * 2), 2) list.nth($padding, 2);
  } @else {
    $padding: units.px($padding);

    $height: list.nth($padding, 1) * 2 + $border * 2 + $font-size;
  }

  display: block;
  padding: units.rem(0 list.nth($padding, 2));
  margin: units.rem(0 0 $spacing 0);
  font-size: $font-size;
  height: $height;
  width: 100%;
}
