Skip to content

Commit

Permalink
Updated linear-gradient function to support variable arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil LaPier committed Sep 14, 2012
1 parent dc92ae3 commit 286c76c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
3 changes: 1 addition & 2 deletions app/assets/stylesheets/css3/_background-image.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@
}



//Examples:
//@include background-image(linear-gradient(top, orange, red));
//@include background-image(radial-gradient(50% 50%, cover circle, orange, red));
//@include background-image(url("/images/a.png"), linear-gradient(orange, red));
//@include background-image(url("image.png"), linear-gradient(orange, red), url("image.png"));
//@include background-image(linear-gradient(hsla(0, 100%, 100%, 0.25) 0%, hsla(0, 100%, 100%, 0.08) 50%, transparent 50%), linear-gradient(orange, red);
//@include background-image(linear-gradient(hsla(0, 100%, 100%, 0.25) 0%, hsla(0, 100%, 100%, 0.08) 50%, transparent 50%), linear-gradient(orange, red));
21 changes: 2 additions & 19 deletions app/assets/stylesheets/functions/_linear-gradient.scss
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
@function linear-gradient($pos: top, $G1: false, $G2: false,
$G3: false, $G4: false,
$G5: false, $G6: false,
$G7: false, $G8: false,
$G9: false, $G10: false) {

// Detect what type of value exists in $pos
$pos-type: type-of(nth($pos, 1));

// If $pos is missing from mixin, reassign vars and add default position
@if ($pos-type == color) or (nth($pos, 1) == "transparent") {
$G10: $G9; $G9: $G8; $G8: $G7; $G7: $G6; $G6: $G5;
$G5: $G4; $G4: $G3; $G3: $G2; $G2: $G1; $G1: $pos;
$pos: top; // Default position
}

@function linear-gradient($gradients...) {
$type: linear;
$gradient: compact($pos, $G1, $G2, $G3, $G4, $G5, $G6, $G7, $G8, $G9, $G10);
$type-gradient: append($type, $gradient, comma);
$type-gradient: append($type, $gradients, comma);

@return $type-gradient;
}

0 comments on commit 286c76c

Please sign in to comment.