Parse angular orientation
This commit is contained in:
parent
eb33883a04
commit
bf419dfe7d
|
@ -29,6 +29,7 @@ module.exports = (function() {
|
|||
pixelValue: /^([0-9]+)px/,
|
||||
percentageValue: /^([0-9]+)\%/,
|
||||
emValue: /^([0-9]+)em/,
|
||||
angleValue: /^([0-9]+)deg/,
|
||||
startCall: /^\(/,
|
||||
endCall: /^\)/,
|
||||
comma: /^,/
|
||||
|
@ -116,7 +117,8 @@ module.exports = (function() {
|
|||
}
|
||||
|
||||
function matchOrientation() {
|
||||
return matchSideOrCorner();
|
||||
return matchSideOrCorner() ||
|
||||
matchAngle();
|
||||
}
|
||||
|
||||
function matchSideOrCorner() {
|
||||
|
@ -129,6 +131,16 @@ module.exports = (function() {
|
|||
}
|
||||
}
|
||||
|
||||
function matchAngle() {
|
||||
var captures = scan(tokens.angleValue);
|
||||
if (captures) {
|
||||
return {
|
||||
type: 'angle',
|
||||
value: captures[1]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function matchColorStops() {
|
||||
var color = matchColorStop(),
|
||||
colors = [];
|
||||
|
|
|
@ -151,4 +151,21 @@ describe('gradient-parser.js', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
[
|
||||
{type: 'angle', unparsedValue: '145deg', value: '145'},
|
||||
{type: 'directional', unparsedValue: 'to left top', value: 'left top'}
|
||||
].forEach(function(orientation) {
|
||||
describe('parse orientation ' + orientation.type, function() {
|
||||
beforeEach(function() {
|
||||
ast = gradientParser('linear-gradient(' + orientation.unparsedValue + ', blue, green)');
|
||||
subject = ast[0];
|
||||
});
|
||||
|
||||
it('should parse the ' + orientation.type + ' orientation', function() {
|
||||
expect(subject.orientation.type).to.equal(orientation.type);
|
||||
expect(subject.orientation.value).to.equal(orientation.value);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue