@import "./variables";

$breakpoints: (
  'xs': 0,
  'sm': $screen-xs-min,
  'md': $screen-sm-min,
  'lg': $screen-md-min,
  'xl': $screen-lg-min
);

@mixin respond-to($breakpoint, $type:'min') {
  // Retrieves the value from the key
  $value: map-get($breakpoints, $breakpoint);

  @if $type == 'max' {
    $value: $value - 1
  }

  // If the key exists in the map
  @if $value != null {
    // Prints a media query based on the value
    @media (#{$type}-width: $value) {
      @content;
    }
  }
  // If the key doesn't exist in the map
  @else {
    @warn "Unfortunately, no value could be retrieved from `#{$breakpoint}`. "
        + "Please make sure it is defined in `$breakpoints` map.";
  }
}
