Skip to content

Instantly share code, notes, and snippets.

@scottkellum
Last active March 7, 2019 15:06
Show Gist options
  • Save scottkellum/57fd435cb7c894a7c854 to your computer and use it in GitHub Desktop.
Save scottkellum/57fd435cb7c894a7c854 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.2.19)
// Compass (v0.12.7)
// ----
@function linear-gradient($parameters...) {
$return: linear-gradient;
@each $parameter in $parameters {
$return: append($return,$parameter, comma);
}
@return $return;
}
@mixin background-image($parameters) {
@if nth($parameters,1) == linear-gradient {
$webkit-return: ();
@if nth(nth($parameters,2),1) == to {
@for $i from 3 through length($parameters) {
$webkit-return: append(nth($parameters,$i),$webkit-return, comma);
}
}
@if nth(nth($parameters,2),2) == right {
$webkit-return: append(left,$webkit-return, comma);
}
background-image: unquote('-webkit-linear-gradient(' + $webkit-return + ')');
$standard-return: ();
@for $i from 2 through length($parameters) {
$standard-return: append($standard-return,nth($parameters,$i), comma);
}
background-image: unquote('linear-gradient(' + $standard-return + ')');
}
@else {
background-image: $parameters;
}
}
foo {
@include background-image(linear-gradient(to right, red, green));
}
foo {
background-image: -webkit-linear-gradient(left, green, red);
background-image: linear-gradient(to right, red, green);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment