tdesign-react
Version:
TDesign Component for React
40 lines (36 loc) • 1.26 kB
JavaScript
/**
* tdesign v1.15.1
* (c) 2025 tdesign
* @license MIT
*/
import { _ as _objectWithoutProperties } from '../_chunks/dep-6b660ef0.js';
var _excluded = ["from", "to", "direction"];
var getBackgroundColor = 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 as default };
//# sourceMappingURL=linearGradient.js.map