_radial-gradient.scss 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Requires Sass 3.1+
  2. @mixin radial-gradient($G1, $G2,
  3. $G3: null, $G4: null,
  4. $G5: null, $G6: null,
  5. $G7: null, $G8: null,
  6. $G9: null, $G10: null,
  7. $pos: null,
  8. $shape-size: null,
  9. $fallback: null) {
  10. $data: _radial-arg-parser($G1, $G2, $pos, $shape-size);
  11. $G1: nth($data, 1);
  12. $G2: nth($data, 2);
  13. $pos: nth($data, 3);
  14. $shape-size: nth($data, 4);
  15. $full: $G1, $G2, $G3, $G4, $G5, $G6, $G7, $G8, $G9, $G10;
  16. // Strip deprecated cover/contain for spec
  17. $shape-size-spec: _shape-size-stripper($shape-size);
  18. // Set $G1 as the default fallback color
  19. $first-color: nth($full, 1);
  20. $fallback-color: nth($first-color, 1);
  21. @if (type-of($fallback) == color) or ($fallback == "transparent") {
  22. $fallback-color: $fallback;
  23. }
  24. // Add Commas and spaces
  25. $shape-size: if($shape-size, '#{$shape-size}, ', null);
  26. $pos: if($pos, '#{$pos}, ', null);
  27. $pos-spec: if($pos, 'at #{$pos}', null);
  28. $shape-size-spec: if(($shape-size-spec != ' ') and ($pos == null), '#{$shape-size-spec}, ', '#{$shape-size-spec} ');
  29. background-color: $fallback-color;
  30. background-image: -webkit-radial-gradient(unquote(#{$pos}#{$shape-size}#{$full}));
  31. background-image: unquote("radial-gradient(#{$shape-size-spec}#{$pos-spec}#{$full})");
  32. }