_linear-gradient.scss 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. @mixin linear-gradient($pos, $G1, $G2: null,
  2. $G3: null, $G4: null,
  3. $G5: null, $G6: null,
  4. $G7: null, $G8: null,
  5. $G9: null, $G10: null,
  6. $fallback: null) {
  7. // Detect what type of value exists in $pos
  8. $pos-type: type-of(nth($pos, 1));
  9. $pos-spec: null;
  10. $pos-degree: null;
  11. // If $pos is missing from mixin, reassign vars and add default position
  12. @if ($pos-type == color) or (nth($pos, 1) == "transparent") {
  13. $G10: $G9; $G9: $G8; $G8: $G7; $G7: $G6; $G6: $G5;
  14. $G5: $G4; $G4: $G3; $G3: $G2; $G2: $G1; $G1: $pos;
  15. $pos: null;
  16. }
  17. @if $pos {
  18. $positions: _linear-positions-parser($pos);
  19. $pos-degree: nth($positions, 1);
  20. $pos-spec: nth($positions, 2);
  21. }
  22. $full: $G1, $G2, $G3, $G4, $G5, $G6, $G7, $G8, $G9, $G10;
  23. // Set $G1 as the default fallback color
  24. $fallback-color: nth($G1, 1);
  25. // If $fallback is a color use that color as the fallback color
  26. @if (type-of($fallback) == color) or ($fallback == "transparent") {
  27. $fallback-color: $fallback;
  28. }
  29. background-color: $fallback-color;
  30. background-image: -webkit-linear-gradient($pos-degree $full); // Safari 5.1+, Chrome
  31. background-image: unquote("linear-gradient(#{$pos-spec}#{$full})");
  32. }