_radial-gradient-parser.scss 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. @function _radial-gradient-parser($image) {
  2. $image: unquote($image);
  3. $gradients: ();
  4. $start: str-index($image, "(");
  5. $end: str-index($image, ",");
  6. $first-val: str-slice($image, $start + 1, $end - 1);
  7. $prefix: str-slice($image, 0, $start);
  8. $suffix: str-slice($image, $end, str-length($image));
  9. $is-spec-syntax: str-index($first-val, "at");
  10. @if $is-spec-syntax and $is-spec-syntax > 1 {
  11. $keyword: str-slice($first-val, 1, $is-spec-syntax - 2);
  12. $pos: str-slice($first-val, $is-spec-syntax + 3, str-length($first-val));
  13. $pos: append($pos, $keyword, comma);
  14. $gradients: (
  15. webkit-image: -webkit- + $prefix + $pos + $suffix,
  16. spec-image: $image
  17. )
  18. }
  19. @else if $is-spec-syntax == 1 {
  20. $pos: str-slice($first-val, $is-spec-syntax + 3, str-length($first-val));
  21. $gradients: (
  22. webkit-image: -webkit- + $prefix + $pos + $suffix,
  23. spec-image: $image
  24. )
  25. }
  26. @else if str-index($image, "cover") or str-index($image, "contain") {
  27. @warn "Radial-gradient needs to be updated to conform to latest spec.";
  28. $gradients: (
  29. webkit-image: null,
  30. spec-image: $image
  31. )
  32. }
  33. @else {
  34. $gradients: (
  35. webkit-image: -webkit- + $image,
  36. spec-image: $image
  37. )
  38. }
  39. @return $gradients;
  40. }