Skip to content

Commit 6924efb

Browse files
committed
app/DTNode: visualize node status
1 parent 1fbc58e commit 6924efb

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

app/DTNode.tsx

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,53 @@ const style = {
1313
fontFamily: "Fira Code",
1414
};
1515

16-
const DTNode = ({
16+
type DTStatus = "okay" | "disabled";
17+
18+
export const Dot: FC<{ color: "blue" | "red" }> = ({ color }) => (
19+
<div style={{ width: 10, height: 10, background: color, borderRadius: "100%" }} />
20+
);
21+
22+
export const DataNode: FC<{ data?: object; status: DTStatus }> = ({
1723
data,
18-
isConnectable,
19-
targetPosition = Position.Top,
20-
sourcePosition = Position.Bottom
21-
}: NodeProps) => {
24+
status,
25+
}) => {
2226
const [hovered, setHovered] = useState(false);
2327

2428
const hoverOn = () => setHovered(true);
2529
const hoverOff = () => setHovered(false);
2630

2731
const borderColor = hovered ? "#987987" : "#789789";
2832
const borderStyle = hovered ? "dotted" : "solid";
33+
34+
const dotColor = status === "okay" ? "blue" : "red";
35+
36+
return (
37+
<div
38+
style={{...style, borderColor, borderStyle }}
39+
onMouseEnter={hoverOn}
40+
onMouseLeave={hoverOff}
41+
>
42+
{data?.label}
43+
<Dot color={dotColor} />
44+
</div>
45+
);
46+
};
47+
48+
const DTNode = ({
49+
data,
50+
isConnectable,
51+
targetPosition = Position.Top,
52+
sourcePosition = Position.Bottom
53+
}: NodeProps) => {
54+
const { status, ...nData } = data;
2955
return (
3056
<>
3157
<Handle
3258
type="target"
3359
position={targetPosition}
3460
isConnectable={isConnectable}
3561
/>
36-
<div
37-
style={{...style, borderColor, borderStyle }}
38-
onMouseEnter={hoverOn}
39-
onMouseLeave={hoverOff}
40-
>
41-
{data?.label}
42-
</div>
62+
<DataNode data={nData} status={status} />
4363
<Handle
4464
type="source"
4565
position={sourcePosition}

0 commit comments

Comments
 (0)