@nodeject/ui-components
Version:
UI library for non-trivial components
29 lines (28 loc) • 1.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Edge = void 0;
var React = require("react");
var styles = require("./Edge.module.less");
var Edge = function (props) {
var xSource = props.xSource, ySource = props.ySource, xTarget = props.xTarget, yTarget = props.yTarget, type = props.type;
var path;
// prettier-ignore
if (type === 0) { // WBS style
var xDistance = xSource - xTarget;
if (xDistance > 4) {
path = 'M' + Math.round(xSource) + ' ' + Math.round(ySource) + ' V' + (Math.round(yTarget) + (Math.round(ySource) - Math.round(yTarget)) / 2 + 4) + 'a4,4 0 0 0 -4,-4' + ' H' + Math.round(xTarget) + ' V' + Math.round(yTarget);
}
else if (xDistance >= -20 && xDistance <= 20) {
path = 'M' + Math.round(xSource) + ' ' + Math.round(ySource) + ' V' + (Math.round(yTarget) + (Math.round(ySource) - Math.round(yTarget)) / 2) + ' H' + Math.round(xTarget) + ' V' + Math.round(yTarget);
}
else {
path = 'M' + Math.round(xSource) + ' ' + Math.round(ySource) + ' V' + (Math.round(yTarget) + (Math.round(ySource) - Math.round(yTarget)) / 2 + 4) + 'a4,4 0 0 1 4,-4' + ' H' + Math.round(xTarget) + ' V' + Math.round(yTarget);
}
}
else { // List style
path = 'M' + Math.round(xSource) + ' ' + Math.round(ySource) + ' H' + (Math.round(xTarget) + 5) + 'a4,4 0 0 1 -4,-4' + ' V' + Math.round(yTarget);
}
return (React.createElement("svg", { className: styles.edge, style: { overflow: 'visible' } },
React.createElement("path", { d: path })));
};
exports.Edge = Edge;