3 // scss-lint:disable SpaceAroundOperator
5 /// Builds directional properties by parsing CSS shorthand values. For example,
6 /// a value of `10px null` will output top and bottom directional properties,
7 /// but the `null` skips left and right from being output.
9 /// @argument {string} $property
12 /// @argument {string} $suffix
13 /// Suffix to append. Use `null` to omit.
15 /// @argument {list} $values
16 /// List of values to set for the property.
20 /// @include _directional-property(border, width, null 5px);
25 /// border-right-width: 5px;
26 /// border-left-width: 5px;
29 /// @require {function} _compact-shorthand
31 /// @require {function} _contains-falsy
35 @mixin _directional-property(
40 $top: $property + "-top" + if($suffix, "-#{$suffix}", "");
41 $bottom: $property + "-bottom" + if($suffix, "-#{$suffix}", "");
42 $left: $property + "-left" + if($suffix, "-#{$suffix}", "");
43 $right: $property + "-right" + if($suffix, "-#{$suffix}", "");
44 $all: $property + if($suffix, "-#{$suffix}", "");
46 $values: _compact-shorthand($values);
48 @if _contains-falsy($values) {
49 @if nth($values, 1) { #{$top}: nth($values, 1); }
51 @if length($values) == 1 {
52 @if nth($values, 1) { #{$right}: nth($values, 1); }
54 @if nth($values, 2) { #{$right}: nth($values, 2); }
57 @if length($values) == 2 {
58 @if nth($values, 1) { #{$bottom}: nth($values, 1); }
59 @if nth($values, 2) { #{$left}: nth($values, 2); }
60 } @else if length($values) == 3 {
61 @if nth($values, 3) { #{$bottom}: nth($values, 3); }
62 @if nth($values, 2) { #{$left}: nth($values, 2); }
63 } @else if length($values) == 4 {
64 @if nth($values, 3) { #{$bottom}: nth($values, 3); }
65 @if nth($values, 4) { #{$left}: nth($values, 4); }