Sha256: e6c354deab22e123ee7f6dc27b6f08518ad0c1ce18fc2ec0b96f8fd9bee2f5c5

Contents?: true

Size: 1.99 KB

Versions: 5

Compression:

Stored size: 1.99 KB

Contents

@charset "UTF-8";

// scss-lint:disable SpaceAroundOperator

/// Builds directional properties by parsing CSS shorthand values. For example,
/// a value of `10px null` will output top and bottom directional properties,
/// but the `null` skips left and right from being output.
///
/// @argument {string} $property
///   Base property.
///
/// @argument {string} $suffix
///   Suffix to append. Use `null` to omit.
///
/// @argument {list} $values
///   List of values to set for the property.
///
/// @example scss
///   .element {
///     @include _directional-property(border, width, null 5px);
///   }
///
///   // CSS Output
///   .element {
///     border-right-width: 5px;
///     border-left-width: 5px;
///   }
///
/// @require {function} _compact-shorthand
///
/// @require {function} _contains-falsy
///
/// @access private

@mixin _directional-property(
  $property,
  $suffix,
  $values
) {
  $top:    $property + "-top"    + if($suffix, "-#{$suffix}", "");
  $bottom: $property + "-bottom" + if($suffix, "-#{$suffix}", "");
  $left:   $property + "-left"   + if($suffix, "-#{$suffix}", "");
  $right:  $property + "-right"  + if($suffix, "-#{$suffix}", "");
  $all:    $property +             if($suffix, "-#{$suffix}", "");

  $values: _compact-shorthand($values);

  @if _contains-falsy($values) {
    @if nth($values, 1) { #{$top}: nth($values, 1); }

    @if length($values) == 1 {
      @if nth($values, 1) { #{$right}: nth($values, 1); }
    } @else {
      @if nth($values, 2) { #{$right}: nth($values, 2); }
    }

    @if length($values) == 2 {
      @if nth($values, 1) { #{$bottom}: nth($values, 1); }
      @if nth($values, 2) { #{$left}: nth($values, 2); }
    } @else if length($values) == 3 {
      @if nth($values, 3) { #{$bottom}: nth($values, 3); }
      @if nth($values, 2) { #{$left}: nth($values, 2); }
    } @else if length($values) == 4 {
      @if nth($values, 3) { #{$bottom}: nth($values, 3); }
      @if nth($values, 4) { #{$left}: nth($values, 4); }
    }
  } @else {
    #{$all}: $values;
  }
}

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
bourbon-5.1.0 core/bourbon/utilities/_directional-property.scss
bourbon-5.0.1 core/bourbon/utilities/_directional-property.scss
bourbon-5.0.0 core/bourbon/utilities/_directional-property.scss
dream-theme-0.1.0 _sass/bourbon/bourbon/utilities/_directional-property.scss
bourbon-5.0.0.beta.8 core/bourbon/utilities/_directional-property.scss