feat(example): Add custom edge example

update(example): fit view on custom node example
* node selection to use hooks
* dev script to use vue-tsc
This commit is contained in:
Braks
2021-08-08 19:28:45 +02:00
parent 6b9c608381
commit 2188c5d3d3
8 changed files with 209 additions and 34 deletions
+31
View File
@@ -0,0 +1,31 @@
import { EdgeProps, getBezierPath, getMarkerEnd } from '../../src';
import { FunctionalComponent } from 'vue';
const CustomEdge: FunctionalComponent<EdgeProps> = ({
id,
sourceX,
sourceY,
targetX,
targetY,
sourcePosition,
targetPosition,
data,
arrowHeadType,
markerEndId
}) => {
const edgePath = getBezierPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition });
const markerEnd = getMarkerEnd(arrowHeadType, markerEndId);
return () => (
<>
<path id={id} class="react-flow__edge-path" d={edgePath} marker-end={markerEnd} />
<text>
<textPath href={`#${id}`} style={{ fontSize: '12px' }} startOffset="50%" text-anchor="middle">
{data.text}
</textPath>
</text>
</>
);
};
export default CustomEdge;