Skip to content

Commit d898de4

Browse files
committed
Add custom connection line
1 parent f3d4cfe commit d898de4

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {
2+
getStraightPath,
3+
type ConnectionLineComponentProps,
4+
} from "@xyflow/react";
5+
6+
export default function BuildingLinkConnectionLine({
7+
fromX,
8+
fromY,
9+
toX,
10+
toY,
11+
connectionLineStyle,
12+
}: ConnectionLineComponentProps) {
13+
const [edgePath] = getStraightPath({
14+
sourceX: fromX,
15+
sourceY: fromY,
16+
targetX: toX,
17+
targetY: toY,
18+
});
19+
20+
return (
21+
<g>
22+
<path
23+
style={{
24+
stroke: "var(--mantine-color-dark-1)",
25+
...connectionLineStyle,
26+
}}
27+
fill="none"
28+
d={edgePath}
29+
/>
30+
</g>
31+
);
32+
}

mindy-website/www/src/components/LogicVMFlow.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ProcessorKind } from "mindy-website";
1717

1818
import { useLogicVM } from "../hooks";
1919
import { packPoint } from "../utils";
20+
import BuildingLinkConnectionLine from "./BuildingLinkConnectionLine";
2021
import BuildingLinkEdge from "./BuildingLinkEdge";
2122
import DisplayNode, { type DisplayNodeType } from "./nodes/DisplayNode";
2223
import ProcessorNode, { type ProcessorNodeType } from "./nodes/ProcessorNode";
@@ -209,6 +210,7 @@ export default function LogicVMFlow() {
209210
onEdgesChange={onEdgesChange}
210211
onBeforeDelete={onBeforeDelete}
211212
onConnect={onConnect}
213+
connectionLineComponent={BuildingLinkConnectionLine}
212214
fitView
213215
>
214216
<Background variant={BackgroundVariant.Dots} />

0 commit comments

Comments
 (0)