/**
 * Quicky and easily set simple or complexe size to any element
 * @param 		{String|Number} 		$size-width				The size like "cover" or "contain", or the width un number
 * @param 		{Number} 				[$height=null] 			The height wanted
 * @param 		{String} 				[$position=absolute] 	The position wanted if the size is "cover" or "contain"
 *
 * @example 	scss
 * .my-cool-image {
 * 	\@include s-size(cover);
 * }
 *
 * @author 		Olivier Bossel <olivier.bossel@gmail.com> (https://olivierbossel.com)
 */
@mixin s-size($size-width, $height: null, $position: absolute) {
  @if $_sugar-test-arguments {
    @if type-of($size-width) != number {
      $size-width: s-test-argument(
        "s-size",
        "size-width",
        (cover, contain, fit),
        $size-width
      );
    } @else {
      $size-width: s-test-argument("s-size", "size-width", number, $size-width);
    }
    $height: s-test-argument("s-size", "height", "number|null", $height);
    $position: s-test-argument(
      "s-size",
      "position",
      (relative, absolute),
      $position
    );
  }

  // apply values
  @if type-of($size-width) == string {
    position: $position;
    @if $size-width == cover or $size-width == contain {
      top: 50%;
      left: 50%;
      transform: translateX(-50%) translateY(-50%);
    }
    @if $size-width == cover {
      min-width: 100%;
      min-height: 100%;
    } @else if $size-width == contain {
      max-width: 100%;
      max-height: 100%;
    } @else if $size-width == fit {
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
    }
  } @else if
    type-of($size-width) ==
    number and
    unitless($size-width) and
    $size-width <
    1
  {
    @include s-ratio($size-width);
  } @else {
    @if $size-width {
      width: $size-width;
    }
    @if $height {
      height: $height;
    }
  }
}
