_unpack.scss 729 B

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