_linear-gradient-parser.scss 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. @function _linear-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. $has-multiple-vals: str-index($first-val, " ");
  10. $has-single-position: unquote(_position-flipper($first-val) + "");
  11. $has-angle: _is-num(str-slice($first-val, 0, 0));
  12. @if $has-multiple-vals {
  13. $gradients: _linear-side-corner-parser($image, $first-val, $prefix, $suffix, $has-multiple-vals);
  14. }
  15. @else if $has-single-position != "" {
  16. $pos: unquote($has-single-position + "");
  17. $gradients: (
  18. webkit-image: -webkit- + $image,
  19. spec-image: $prefix + "to " + $pos + $suffix
  20. );
  21. }
  22. @else if $has-angle {
  23. // Rotate degree for webkit
  24. $gradients: _linear-angle-parser($image, $first-val, $prefix, $suffix);
  25. }
  26. @else {
  27. $gradients: (
  28. webkit-image: -webkit- + $image,
  29. spec-image: $image
  30. );
  31. }
  32. @return $gradients;
  33. }