_unpack.scss (729B)
1 @charset "UTF-8"; 2 3 /// Converts shorthand to the 4-value syntax. 4 /// 5 /// @param {List} $shorthand 6 /// 7 /// @example scss - Usage 8 /// .element { 9 /// margin: unpack(1em 2em); 10 /// } 11 /// 12 /// @example css - CSS Output 13 /// .element { 14 /// margin: 1em 2em 1em 2em; 15 /// } 16 17 @function unpack($shorthand) { 18 @if length($shorthand) == 1 { 19 @return nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1); 20 } @else if length($shorthand) == 2 { 21 @return nth($shorthand, 1) nth($shorthand, 2) nth($shorthand, 1) nth($shorthand, 2); 22 } @else if length($shorthand) == 3 { 23 @return nth($shorthand, 1) nth($shorthand, 2) nth($shorthand, 3) nth($shorthand, 2); 24 } @else { 25 @return $shorthand; 26 } 27 }