UNPKG

1.12 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5function constructGradientValue(literals) {
6 var template = '';
7 for (var _len = arguments.length, substitutions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
8 substitutions[_key - 1] = arguments[_key];
9 }
10 for (var i = 0; i < literals.length; i += 1) {
11 template += literals[i];
12 if (i === substitutions.length - 1 && substitutions[i]) {
13 var definedValues = substitutions.filter(function (substitute) {
14 return !!substitute;
15 });
16 // Adds leading coma if properties preceed color-stops
17 if (definedValues.length > 1) {
18 template = template.slice(0, -1);
19 template += ", " + substitutions[i];
20 // No trailing space if color-stops is the only param provided
21 } else if (definedValues.length === 1) {
22 template += "" + substitutions[i];
23 }
24 } else if (substitutions[i]) {
25 template += substitutions[i] + " ";
26 }
27 }
28 return template.trim();
29}
30var _default = exports["default"] = constructGradientValue;
31module.exports = exports.default;
\No newline at end of file