Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring radial-gradient function and mixin up to spec
- Loading branch information
Phil LaPier
committed
Apr 5, 2013
1 parent
b343003
commit c9c10af
Showing
10 changed files
with
154 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...heets/helpers/calc-gradient-position.scss → ...ets/helpers/_linear-positions-parser.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
@function _radial-arg-parser($G1, $G2, $pos, $shape-size) { | ||
@each $value in $G1, $G2 { | ||
$first-val: nth($value, 1); | ||
$pos-type: type-of($first-val); | ||
$spec-at-index: null; | ||
|
||
// Determine if spec was passed to mixin | ||
@if type-of($value) == list { | ||
$spec-at-index: if(index($value, at), index($value, at), false); | ||
} | ||
@if $spec-at-index { | ||
@if $spec-at-index > 1 { | ||
@for $i from 1 through ($spec-at-index - 1) { | ||
$shape-size: $shape-size nth($value, $i); | ||
} | ||
@for $i from ($spec-at-index + 1) through length($value) { | ||
$pos: $pos nth($value, $i); | ||
} | ||
} | ||
@else if $spec-at-index == 1 { | ||
@for $i from ($spec-at-index + 1) through length($value) { | ||
$pos: $pos nth($value, $i); | ||
} | ||
} | ||
$G1: false; | ||
} | ||
|
||
// If not spec calculate correct values | ||
@else { | ||
@if ($pos-type != color) or ($first-val != "transparent") { | ||
@if ($pos-type == number) | ||
or ($first-val == "center") | ||
or ($first-val == "top") | ||
or ($first-val == "right") | ||
or ($first-val == "bottom") | ||
or ($first-val == "left") { | ||
|
||
$pos: $value; | ||
|
||
@if $pos == $G1 { | ||
$G1: false; | ||
} | ||
} | ||
|
||
@else if | ||
($first-val == "ellipse") | ||
or ($first-val == "circle") | ||
or ($first-val == "closest-side") | ||
or ($first-val == "closest-corner") | ||
or ($first-val == "farthest-side") | ||
or ($first-val == "farthest-corner") | ||
or ($first-val == "contain") | ||
or ($first-val == "cover") { | ||
|
||
$shape-size: $value; | ||
|
||
@if $value == $G1 { | ||
$G1: false; | ||
} | ||
|
||
@else if $value == $G2 { | ||
$G2: false; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
@return $G1, $G2, $pos, $shape-size; | ||
} |
18 changes: 18 additions & 0 deletions
18
app/assets/stylesheets/helpers/_radial-positions-parser.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@function _radial-positions-parser($gradient-pos) { | ||
$shape-size: nth($gradient-pos, 1); | ||
$pos: nth($gradient-pos, 2); | ||
$shape-size-spec: _shape-size-stripper($shape-size); | ||
|
||
$pre-spec: unquote(if($pos, "#{$pos}, ", null)) | ||
unquote(if($shape-size, "#{$shape-size},", null)); | ||
$pos-spec: if($pos, "at #{$pos}", null); | ||
|
||
$spec: "#{$shape-size-spec} #{$pos-spec}"; | ||
|
||
// Add comma | ||
@if ($spec != ' ') { | ||
$spec: "#{$spec}," | ||
} | ||
|
||
@return $pre-spec $spec; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@function _shape-size-stripper($shape-size) { | ||
$shape-size-spec: null; | ||
@each $value in $shape-size { | ||
@if ($value == "cover") or ($value == "contain") { | ||
$value: null; | ||
} | ||
$shape-size-spec: "#{$shape-size-spec} #{$value}"; | ||
} | ||
@return $shape-size-spec; | ||
} |