Skip to content

Commit 9fb5c82

Browse files
committed
refactor: update BaseEdge implementation
1 parent dd9ccec commit 9fb5c82

File tree

5 files changed

+79
-81
lines changed

5 files changed

+79
-81
lines changed

playground/examples/edges/CustomEdge3.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const CustomEdge3 = (props: EdgeProps<{ text: string }>) => {
2626
<BaseEdge
2727
id={props.id}
2828
path={pathData().edgePath}
29+
pathLength={100}
2930
class="solid-flow__edge-custom3"
3031
style={{
3132
"stroke-dasharray": "100",

playground/examples/switch/page.tsx

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,86 +2,86 @@ import { type Component, createSignal } from "solid-js";
22

33
import { createEdgeStore, createNodeStore, SolidFlow, SolidFlowProvider } from "../../../src";
44

5-
const [nodesA] = createNodeStore([
6-
{
7-
id: "1a",
8-
type: "input",
9-
data: { label: "Node 1" },
10-
position: { x: 250, y: 5 },
11-
class: "light",
12-
ariaLabel: "Input Node 1",
13-
},
14-
{
15-
id: "2a",
16-
type: "default",
17-
data: { label: "Node 2" },
18-
position: { x: 100, y: 100 },
19-
class: "light",
20-
ariaLabel: "Default Node 2",
21-
},
22-
{
23-
id: "3a",
24-
type: "default",
25-
data: { label: "Node 3" },
26-
position: { x: 400, y: 100 },
27-
class: "light",
28-
},
29-
]);
5+
const SwitchFlow: Component = () => {
6+
const [nodesA] = createNodeStore([
7+
{
8+
id: "1a",
9+
type: "input",
10+
data: { label: "Node 1" },
11+
position: { x: 250, y: 5 },
12+
class: "light",
13+
ariaLabel: "Input Node 1",
14+
},
15+
{
16+
id: "2a",
17+
type: "default",
18+
data: { label: "Node 2" },
19+
position: { x: 100, y: 100 },
20+
class: "light",
21+
ariaLabel: "Default Node 2",
22+
},
23+
{
24+
id: "3a",
25+
type: "default",
26+
data: { label: "Node 3" },
27+
position: { x: 400, y: 100 },
28+
class: "light",
29+
},
30+
]);
3031

31-
const [edgesA] = createEdgeStore([
32-
{ id: "e1-2", source: "1a", target: "2a" },
33-
{ id: "e1-3", source: "1a", target: "3a" },
34-
]);
32+
const [edgesA] = createEdgeStore([
33+
{ id: "e1-2", source: "1a", target: "2a" },
34+
{ id: "e1-3", source: "1a", target: "3a" },
35+
]);
3536

36-
const [nodesB] = createNodeStore([
37-
{
38-
id: "inputb",
39-
type: "input",
40-
data: { label: "Input" },
41-
position: { x: 300, y: 5 },
42-
class: "light",
43-
ariaLabel: "Input Node",
44-
},
45-
{
46-
id: "1b",
47-
type: "default",
48-
data: { label: "Node 1" },
49-
position: { x: 0, y: 100 },
50-
class: "light",
51-
ariaLabel: "Node with id 1",
52-
},
53-
{
54-
id: "2b",
55-
type: "default",
56-
data: { label: "Node 2" },
57-
position: { x: 200, y: 100 },
58-
class: "light",
59-
ariaLabel: "Node with id 2",
60-
},
61-
{
62-
id: "3b",
63-
type: "default",
64-
data: { label: "Node 3" },
65-
position: { x: 400, y: 100 },
66-
class: "light",
67-
},
68-
{
69-
id: "4b",
70-
type: "default",
71-
data: { label: "Node 4" },
72-
position: { x: 600, y: 100 },
73-
class: "light",
74-
},
75-
]);
37+
const [nodesB] = createNodeStore([
38+
{
39+
id: "inputb",
40+
type: "input",
41+
data: { label: "Input" },
42+
position: { x: 300, y: 5 },
43+
class: "light",
44+
ariaLabel: "Input Node",
45+
},
46+
{
47+
id: "1b",
48+
type: "default",
49+
data: { label: "Node 1" },
50+
position: { x: 0, y: 100 },
51+
class: "light",
52+
ariaLabel: "Node with id 1",
53+
},
54+
{
55+
id: "2b",
56+
type: "default",
57+
data: { label: "Node 2" },
58+
position: { x: 200, y: 100 },
59+
class: "light",
60+
ariaLabel: "Node with id 2",
61+
},
62+
{
63+
id: "3b",
64+
type: "default",
65+
data: { label: "Node 3" },
66+
position: { x: 400, y: 100 },
67+
class: "light",
68+
},
69+
{
70+
id: "4b",
71+
type: "default",
72+
data: { label: "Node 4" },
73+
position: { x: 600, y: 100 },
74+
class: "light",
75+
},
76+
]);
7677

77-
const [edgesB] = createEdgeStore([
78-
{ id: "e1b", source: "inputb", target: "1b", ariaLabel: "edge to connect" },
79-
{ id: "e2b", source: "inputb", target: "2b" },
80-
{ id: "e3b", source: "inputb", target: "3b" },
81-
{ id: "e4b", source: "inputb", target: "4b" },
82-
]);
78+
const [edgesB] = createEdgeStore([
79+
{ id: "e1b", source: "inputb", target: "1b", ariaLabel: "edge to connect" },
80+
{ id: "e2b", source: "inputb", target: "2b" },
81+
{ id: "e3b", source: "inputb", target: "3b" },
82+
{ id: "e4b", source: "inputb", target: "4b" },
83+
]);
8384

84-
const SwitchFlow: Component = () => {
8585
const [nodes, setNodes] = createSignal(nodesA);
8686
const [edges, setEdges] = createSignal(edgesA);
8787

src/components/graph/edge/BaseEdge.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export const BaseEdge = (props: ParentProps<BaseEdgeProps>) => {
1414
);
1515

1616
const [local, rest] = splitProps(_props, [
17-
"id",
1817
"class",
1918
"style",
2019
"path",
@@ -30,13 +29,13 @@ export const BaseEdge = (props: ParentProps<BaseEdgeProps>) => {
3029
return (
3130
<>
3231
<path
33-
id={local.id}
3432
d={local.path}
3533
class={clsx(["solid-flow__edge-path", local.class])}
3634
marker-start={local.markerStart}
3735
marker-end={local.markerEnd}
3836
fill="none"
3937
style={local.style}
38+
{...rest}
4039
/>
4140

4241
<Show when={local.interactionWidth > 0}>
@@ -46,7 +45,6 @@ export const BaseEdge = (props: ParentProps<BaseEdgeProps>) => {
4645
stroke-width={local.interactionWidth}
4746
fill="none"
4847
class="solid-flow__edge-interaction"
49-
{...rest}
5048
/>
5149
</Show>
5250

src/data/createSolidFlow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const getInitialViewport = (
121121
};
122122

123123
export const createSolidFlow = <NodeType extends Node = Node, EdgeType extends Edge = Edge>(
124-
props: Partial<SolidFlowProps<NodeType, EdgeType>>,
124+
props: SolidFlowProps<NodeType, EdgeType>,
125125
) => {
126126
const _props = mergeProps(getDefaultFlowStateProps<NodeType, EdgeType>(), props);
127127

src/types/edge.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export type EdgeProps<
5858
* Props for built-in edge components that render the actual SVG path.
5959
*/
6060
export type BaseEdgeProps = {
61-
id?: string;
6261
/** SVG path of the edge */
6362
path: string;
6463
/** The x coordinate of the label */

0 commit comments

Comments
 (0)