Make easier to match different gradient types
This commit is contained in:
parent
e1399c0168
commit
a7981cc9dc
1 changed files with 9 additions and 5 deletions
|
@ -21,6 +21,7 @@ module.exports = (function() {
|
||||||
|
|
||||||
var tokens = {
|
var tokens = {
|
||||||
linearGradient: /^linear\-gradient/i,
|
linearGradient: /^linear\-gradient/i,
|
||||||
|
radialGradient: /^radial\-gradient/i,
|
||||||
sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|left|right|top|bottom)/i,
|
sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|left|right|top|bottom)/i,
|
||||||
startCall: /^\(/,
|
startCall: /^\(/,
|
||||||
endCall: /^\)/,
|
endCall: /^\)/,
|
||||||
|
@ -68,11 +69,14 @@ module.exports = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function matchDefinition() {
|
function matchDefinition() {
|
||||||
return matchLinearGradient();
|
return matchGradient(
|
||||||
|
'linear-gradient',
|
||||||
|
tokens.linearGradient,
|
||||||
|
matchOrientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
function matchLinearGradient() {
|
function matchGradient(gradientType, token, orientationMatcher) {
|
||||||
var captures = scan(tokens.linearGradient),
|
var captures = scan(token),
|
||||||
orientation,
|
orientation,
|
||||||
colorStops;
|
colorStops;
|
||||||
|
|
||||||
|
@ -81,7 +85,7 @@ module.exports = (function() {
|
||||||
error('Missing (');
|
error('Missing (');
|
||||||
}
|
}
|
||||||
|
|
||||||
orientation = matchOrientation();
|
orientation = orientationMatcher();
|
||||||
if (orientation) {
|
if (orientation) {
|
||||||
if (!scan(tokens.comma)) {
|
if (!scan(tokens.comma)) {
|
||||||
error('Missing comma before color stops');
|
error('Missing comma before color stops');
|
||||||
|
@ -98,7 +102,7 @@ module.exports = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'linear-gradient',
|
type: gradientType,
|
||||||
orientation: orientation,
|
orientation: orientation,
|
||||||
colorStops: colorStops
|
colorStops: colorStops
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue