-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (28 loc) · 776 Bytes
/
Copy pathindex.js
File metadata and controls
35 lines (28 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
var camelcase = require('camel-case');
var extend = require('extend-shallow');
var gradients = require('./gradients.json');
module.exports = function(name, options) {
if (name === 'default') {
return '';
}
var opts = extend({}, options);
opts = extend({}, opts, opts.hash);
var gradient;
for (var i = 0; i < gradients.length; i++) {
var ele = gradients[i];
if (camelcase(ele.name) === camelcase(name)) {
gradient = ele.colors;
break;
}
}
if (!gradient) {
return '';
}
if (opts.reverse) {
gradient = gradient.slice().reverse();
}
var to = gradient[1];
var from = gradient[0];
return 'background-color: ' + to + ';\n background-image: linear-gradient(to left, ' + from + ', ' + to + ');';
};