Sha256: f161d1ef151a7d4883400d20f6090d01c6dcad1a9039a2d20ed72ebdb4392339

Contents?: true

Size: 1007 Bytes

Versions: 10

Compression:

Stored size: 1007 Bytes

Contents

@charset "UTF-8";

// scss-lint:disable ElsePlacement

/// Transforms shorthand to its shortest possible form.
///
/// @argument {list} $values
///   List of directional values.
///
/// @example scss
///   $values: _compact-shorthand(10px 20px 10px 20px);
///
///   // Output
///   $values: 10px 20px;
///
/// @return {list}
///
/// @access private

@function _compact-shorthand($values) {
  $output: null;

  $a: nth($values, 1);
  $b: if(length($values) < 2, $a, nth($values, 2));
  $c: if(length($values) < 3, $a, nth($values, 3));
  $d: if(length($values) < 2, $a, nth($values, if(length($values) < 4, 2, 4)));

  @if $a == 0 { $a: 0; }
  @if $b == 0 { $b: 0; }
  @if $c == 0 { $c: 0; }
  @if $d == 0 { $d: 0; }

  @if $a == $b and $a == $c and $a == $d { $output: $a;          }
  @else if $a == $c and $b == $d         { $output: $a $b;       }
  @else if $b == $d                      { $output: $a $b $c;    }
  @else                                  { $output: $a $b $c $d; }

  @return $output;
}

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
bourbon-5.1.0 core/bourbon/utilities/_compact-shorthand.scss
bourbon-5.0.1 core/bourbon/utilities/_compact-shorthand.scss
bourbon-5.0.0 core/bourbon/utilities/_compact-shorthand.scss
dream-theme-0.1.0 _sass/bourbon/bourbon/utilities/_compact-shorthand.scss
bourbon-5.0.0.beta.8 core/bourbon/utilities/_compact-shorthand.scss
spice-rack-0.4.0 _sass/bourbon/bourbon/utilities/_compact-shorthand.scss
spice-rack-0.3.0 _sass/bourbon/bourbon/utilities/_compact-shorthand.scss
spice-rack-0.2.0 _sass/bourbon/bourbon/utilities/_compact-shorthand.scss
spice-rack-0.1.0 _sass/bourbon/bourbon/utilities/_compact-shorthand.scss
bourbon-5.0.0.beta.7 core/bourbon/utilities/_compact-shorthand.scss