Experimental book page layout.
[wolnelektury.git] / src / wolnelektury / static / 2021 / css / utils / bourbon / utilities / _compact-shorthand.scss
1 @charset "UTF-8";
2
3 // scss-lint:disable ElsePlacement
4
5 /// Transforms shorthand to its shortest possible form.
6 ///
7 /// @argument {list} $values
8 ///   List of directional values.
9 ///
10 /// @example scss
11 ///   $values: _compact-shorthand(10px 20px 10px 20px);
12 ///
13 ///   // Output
14 ///   $values: 10px 20px;
15 ///
16 /// @return {list}
17 ///
18 /// @access private
19
20 @function _compact-shorthand($values) {
21   $output: null;
22
23   $a: nth($values, 1);
24   $b: if(length($values) < 2, $a, nth($values, 2));
25   $c: if(length($values) < 3, $a, nth($values, 3));
26   $d: if(length($values) < 2, $a, nth($values, if(length($values) < 4, 2, 4)));
27
28   @if $a == 0 { $a: 0; }
29   @if $b == 0 { $b: 0; }
30   @if $c == 0 { $c: 0; }
31   @if $d == 0 { $d: 0; }
32
33   @if $a == $b and $a == $c and $a == $d { $output: $a;          }
34   @else if $a == $c and $b == $d         { $output: $a $b;       }
35   @else if $b == $d                      { $output: $a $b $c;    }
36   @else                                  { $output: $a $b $c $d; }
37
38   @return $output;
39 }