c98130cc08
* ui: Add the most basic workspace root in /ui * We already have a LICENSE file in the repository root * Change directory path in build scripts ui-v2 -> ui * Make yarn install flags configurable from elsewhere * Minimal workspace root makefile * Call the new docker specific target * Update yarn in the docker build image * Reconfigure the netlify target and move to the higher makefile * Move ui-v2 -> ui/packages/consul-ui * Change repo root to refleect new folder structure * Temporarily don't hoist consul-api-double * Fixup CI configuration * Fixup lint errors * Fixup Netlify target
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
import { helper } from '@ember/component/helper';
|
|
// arguments should be a list of {x: numLike, y: numLike} points
|
|
// numLike meaning they should be numbers (or numberlike strings i.e. "1" vs 1)
|
|
const curve = function() {
|
|
const args = [...arguments];
|
|
// our arguments are destination first control points last
|
|
// SVGs are control points first destination last
|
|
// we 'shift,push' to turn that around and then map
|
|
// through the values to convert it to 'x y, x y' etc
|
|
// whether the curve is cubic-bezier (C) or quadratic-bezier (Q)
|
|
// then depends on the amount of control points
|
|
// `Q|C x y, x y, x y` etc
|
|
return `${arguments.length > 2 ? `C` : `Q`} ${args
|
|
.concat(args.shift())
|
|
.map(p => Object.values(p).join(' '))
|
|
.join(',')}`;
|
|
};
|
|
const move = function(d) {
|
|
return `
|
|
M ${d.x} ${d.y}
|
|
`;
|
|
};
|
|
|
|
export default helper(function([dest], hash) {
|
|
const src = hash.src || { x: 0, y: 0 };
|
|
const type = hash.type || 'cubic';
|
|
let args = [
|
|
dest,
|
|
{
|
|
x: (src.x + dest.x) / 2,
|
|
y: src.y,
|
|
},
|
|
];
|
|
if (type === 'cubic') {
|
|
args.push({
|
|
x: args[1].x,
|
|
y: dest.y,
|
|
});
|
|
}
|
|
return `${move(src)}${curve(...args)}`;
|
|
});
|