Skip to content

Commit 03d437f

Browse files
committed
refactor: clean up examples
1 parent ae011f2 commit 03d437f

File tree

10 files changed

+205
-245
lines changed

10 files changed

+205
-245
lines changed

playground/examples/color-mode/page.tsx

Lines changed: 49 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,58 @@ import { type ColorMode } from "@xyflow/system";
22
import { createSignal } from "solid-js";
33

44
import { Background, Controls, MiniMap, Panel, SolidFlow } from "@/index";
5-
import type { Edge, Node } from "@/types";
65

7-
const initialNodes: Node[] = [
8-
{
9-
id: "A",
10-
type: "default",
11-
position: { x: 0, y: 0 },
12-
data: { label: "Node A" },
13-
},
14-
{
15-
id: "B",
16-
type: "default",
17-
position: { x: -100, y: 100 },
18-
data: { label: "Node B" },
19-
},
20-
{
21-
id: "C",
22-
type: "default",
23-
position: { x: 100, y: 100 },
24-
data: { label: "Node C" },
25-
},
26-
{
27-
id: "D",
28-
type: "default",
29-
position: { x: 0, y: 200 },
30-
data: { label: "Node D" },
31-
},
32-
];
6+
export function ColorMode() {
7+
const [nodes] = createSignal([
8+
{
9+
id: "A",
10+
type: "default",
11+
position: { x: 0, y: 0 },
12+
data: { label: "Node A" },
13+
},
14+
{
15+
id: "B",
16+
type: "default",
17+
position: { x: -100, y: 100 },
18+
data: { label: "Node B" },
19+
},
20+
{
21+
id: "C",
22+
type: "default",
23+
position: { x: 100, y: 100 },
24+
data: { label: "Node C" },
25+
},
26+
{
27+
id: "D",
28+
type: "default",
29+
position: { x: 0, y: 200 },
30+
data: { label: "Node D" },
31+
},
32+
]);
3333

34-
const initialEdges: Edge[] = [
35-
{
36-
id: "A-B",
37-
source: "A",
38-
target: "B",
39-
},
40-
{
41-
id: "A-C",
42-
source: "A",
43-
target: "C",
44-
},
45-
{
46-
id: "B-D",
47-
source: "B",
48-
target: "D",
49-
},
50-
{
51-
id: "C-D",
52-
source: "C",
53-
target: "D",
54-
},
55-
];
34+
const [edges] = createSignal([
35+
{
36+
id: "A-B",
37+
source: "A",
38+
target: "B",
39+
},
40+
{
41+
id: "A-C",
42+
source: "A",
43+
target: "C",
44+
},
45+
{
46+
id: "B-D",
47+
source: "B",
48+
target: "D",
49+
},
50+
{
51+
id: "C-D",
52+
source: "C",
53+
target: "D",
54+
},
55+
]);
5656

57-
export function ColorMode() {
58-
const [nodes] = createSignal(initialNodes);
59-
const [edges] = createSignal(initialEdges);
6057
const [colorMode, setColorMode] = createSignal<ColorMode>("light");
6158

6259
return (

playground/examples/custom-node/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const nodeTypes = {
2020
export function CustomNode() {
2121
const [backgroundColor, setBackgroundColor] = createSignal("#1A192B");
2222

23-
const [nodes, _setNodes] = createNodeStore<typeof nodeTypes>([
23+
const [nodes] = createNodeStore<typeof nodeTypes>([
2424
{
2525
id: "1",
2626
type: "input",
@@ -50,7 +50,7 @@ export function CustomNode() {
5050
},
5151
]);
5252

53-
const [edges, _setEdges] = createEdgeStore([
53+
const [edges] = createEdgeStore([
5454
{
5555
id: "e1-2",
5656
source: "1",

playground/examples/drag-n-drop/page.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { createEffect } from "solid-js";
2-
31
import { createEdgeStore } from "@/data/createEdgeStore";
42
import { createNodeStore } from "@/data/createNodeStore";
53
import { useSolidFlow } from "@/hooks";
@@ -32,7 +30,7 @@ export function DragNDrop() {
3230
},
3331
]);
3432

35-
const [edges, _setEdges] = createEdgeStore([
33+
const [edges] = createEdgeStore([
3634
{
3735
id: "1-2",
3836
type: "default",
@@ -81,14 +79,9 @@ export function DragNDrop() {
8179
data: { label: `${type} node` },
8280
};
8381

84-
console.log("ADD NODE >>>>", newNode);
8582
addNodes(newNode);
8683
};
8784

88-
createEffect(() => {
89-
console.log("DRAG AND DROP NODES UPDATED >>>", nodes);
90-
});
91-
9285
return (
9386
<main style={{ height: "100%", display: "flex" }}>
9487
<SolidFlow nodes={nodes} edges={edges} fitView onDragOver={onDragOver} onDrop={onDrop}>

0 commit comments

Comments
 (0)