2014-09-04 16:53:26 +00:00
|
|
|
// Copyright (c) 2014 Rafael Caricio. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-09-04 22:34:08 +00:00
|
|
|
var GradientParser = module.exports = (function() {
|
2014-09-04 16:53:26 +00:00
|
|
|
|
|
|
|
var types = {
|
|
|
|
gradients: [
|
|
|
|
'linear-gradient',
|
|
|
|
'radial-gradient',
|
|
|
|
'repeating-radial-gradient'
|
|
|
|
],
|
|
|
|
colors: [
|
|
|
|
'hex',
|
|
|
|
'rgb',
|
|
|
|
'rgba',
|
|
|
|
'hsl',
|
|
|
|
'literal'
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
function Constructor() {
|
|
|
|
}
|
|
|
|
|
2014-09-04 22:34:08 +00:00
|
|
|
var def = Constructor.prototype;
|
|
|
|
|
|
|
|
def.parse = function(input) {
|
2014-09-04 16:53:26 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Constructor;
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
2014-09-04 22:34:08 +00:00
|
|
|
var p = new GradientParser('linear-gradient(to right, transparent 10px, #c2c2c2 10px)');
|
2014-09-04 16:53:26 +00:00
|
|
|
var ast = p.parse();
|
|
|
|
|
|
|
|
if (ast == [
|
|
|
|
{
|
|
|
|
type: 'linear-gradient',
|
|
|
|
orientation: {
|
|
|
|
type: 'directional',
|
|
|
|
value: 'right'
|
|
|
|
},
|
|
|
|
colorStops: [
|
|
|
|
{
|
|
|
|
type: 'literal',
|
|
|
|
value: 'transparent',
|
|
|
|
length: {
|
|
|
|
value: '10',
|
|
|
|
type: 'px'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'hex',
|
|
|
|
value: 'c2c2c2',
|
|
|
|
length: {
|
|
|
|
value: '10',
|
|
|
|
type: 'px'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}]) {
|
|
|
|
console.log('Done!');
|
|
|
|
} else {
|
|
|
|
console.log('Keep working...');
|
|
|
|
}
|