@charset 'UTF-8';

////
/// Flavor SCSS Mixins Overflow
/// @group mixins-overflow
/// @author blackmirror1980
////

/// Overflow modes
///
/// @access private
/// @type list
$overflow-modes: array-concat((visible, hidden, scroll, overlay, unset, auto), $css-default-modes);

/// Checks if something is a supported overflow mode
///
/// @access public
/// @param {string} $o - the overflow mode
/// @return {boolean} - true if is overflow mode
@function is-overflow($o) {
  @return is-defined($o) and array-contains($overflow-modes, $o);
}

/// Overflow mixin
///
/// @example scss - Usage
///   .overflow-element {
///     @include overflow(hidden);
///   }
///
/// @example css - Output
///   .overflow-element {
///     overflow-x: hidden;
///     overflow-y: hidden;
///   }
///
/// @example scss - Usage
///   .overflow-element {
///     @include overflow(hidden scroll);
///   }
///
/// @example css - Output
///   .overflow-element {
///     overflow-x: hidden;
///     overflow-y: scroll;
///   }
/// @requires {function} nth-value
/// @access public
/// @param {string} $o - the overflow mode
/// @param {boolean} $important [false] - if true, will render the important rule
@mixin overflow($o, $important: false) {
  $overflow-x: nth-value($o, 1);

  @if is-overflow($overflow-x) {
    overflow-x: $overflow-x important($important);
  }
  @else {
    @warn '`overflow-x: #{$o}` is not a valid overflow value';
  }

  $overflow-y: nth-value($o, 2, $overflow-x);

  @if is-overflow($overflow-y) {
    overflow-y: $overflow-y important($important);
  }
  @else {
    @warn '`overflow-y: #{$o}` is not a valid overflow value';
  }
}
