tdesign-mobile-vue
Version:
tdesign-mobile-vue
48 lines (40 loc) • 1.57 kB
JavaScript
/**
* tdesign v1.7.0
* (c) 2024 TDesign Group
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_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__default["default"](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, ")");
}
exports.getBackgroundColor = getBackgroundColor;
//# sourceMappingURL=utils.js.map