UNPKG

tdesign-mobile-vue

Version:
40 lines (36 loc) 1.23 kB
/** * tdesign v1.7.0 * (c) 2024 TDesign Group * @license MIT */ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties'; var _excluded = ["from", "to", "direction"]; function getBackgroundColor(color) { if (typeof color === "string") { return color; } if (Array.isArray(color)) { if (color[0] && color[0][0] === "#") { color.unshift("90deg"); } return "linear-gradient( ".concat(color.join(","), " )"); } var from = color.from, to = color.to, _color$direction = color.direction, direction = _color$direction === void 0 ? "to right" : _color$direction, rest = _objectWithoutProperties(color, _excluded); var keys = Object.keys(rest); if (keys.length) { keys = keys.sort(function (a, b) { return parseFloat(a.substr(0, a.length - 1)) - parseFloat(b.substr(0, b.length - 1)); }); var tempArr = keys.map(function (key) { return "".concat(rest[key], " ").concat(key); }); return "linear-gradient(".concat(direction, ", ").concat(tempArr.join(","), ")"); } return "linear-gradient(".concat(direction, ", ").concat(from, ", ").concat(to, ")"); } export { getBackgroundColor }; //# sourceMappingURL=utils.js.map