Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
background-color: #e5e4e2;
}

.dec-root.dark .diagram-background{
--xy-background-pattern-color: inherit;
background-color: inherit;
.dec-root.dark .diagram-background {
--xy-background-pattern-color: inherit;
background-color: inherit;
}

/* react flow pointer behavior */
Expand All @@ -35,7 +35,7 @@

/* node hovering */
.dec-root .react-flow__node {
cursor: pointer !important;
cursor: pointer !important;
}

/* node dragging */
Expand All @@ -61,59 +61,104 @@
/* custom nodes */
@layer custom-nodes {
.dec-root .node-label-container {
@apply
dec:whitespace-pre
dec:p-0.75
dec:text-black
dec:text-sm;
@apply dec:whitespace-pre
dec:p-0.75
dec:text-black
dec:text-sm;
}

.dec-root.dark .node-label-container {
@apply
dec:text-white;
@apply dec:text-white;
}

.dec-root .custom-node-container {
@apply
dec:rounded-[5px]
dec:bg-white
dec:border dec:border-black
dec:transition-[border,box-shadow]
dec:h-full
dec:w-full;
@apply dec:rounded-[5px]
dec:bg-white
dec:border dec:border-black
dec:transition-[border,box-shadow]
dec:h-full
dec:w-full;
}

.dec-root.dark .custom-node-container {
@apply
dec:bg-[rgb(85,83,83)]
dec:border-[#e5e4e2];
@apply dec:bg-[rgb(85,83,83)]
dec:border-[#e5e4e2];
}

.dec-root .custom-node-container:hover {
@apply
dec:hover:border dec:hover:border-black
dec:hover:shadow-[0_0_10px_rgba(0,65,208,0.3)]
dec:hover:h-full
dec:hover:w-full;
@apply dec:hover:border dec:hover:border-black
dec:hover:shadow-[0_0_10px_rgba(0,65,208,0.3)]
dec:hover:h-full
dec:hover:w-full;
}

.dec-root.dark .custom-node-container:hover {
@apply
dec:hover:border-[#5dafd5]
dec:hover:shadow-[0_0_10px_rgba(255,255,255,0.3)];
@apply dec:hover:border-[#5dafd5]
dec:hover:shadow-[0_0_10px_rgba(255,255,255,0.3)];
}

.dec-root .custom-node-container.selected {
@apply
dec:bg-[#aebbd5]
dec:border dec:border-black
dec:shadow-[0_0_10px_rgba(1,79,248,0.3)];
@apply dec:bg-[#aebbd5]
dec:border dec:border-black
dec:shadow-[0_0_10px_rgba(1,79,248,0.3)];
}

.dec-root.dark .custom-node-container.selected {
@apply
dec:bg-[#727676]
dec:border-[#4324dc]
dec:shadow-[0_0_10px_rgba(255,255,255,0.3)];
@apply dec:bg-[#727676]
dec:border-[#4324dc]
dec:shadow-[0_0_10px_rgba(255,255,255,0.3)];
}
}
}

/* custom edges */
/* React flow SVG components do not work with classes defined into layers */
.dec-root .edge-line {
@apply dec:stroke-[#aea6a6]
dec:stroke-2;
}

.dec-root .edge-line.error {
@apply dec:stroke-red-500
dec:[stroke-dasharray:5_5];
}
Comment thread
handreyrc marked this conversation as resolved.

.dec-root .edge-line.condition {
@apply dec:stroke-blue-500;
}

/* custom edge labels */
@layer custom-edge-labels {
.dec-root .edge-label {
@apply dec:bg-white
dec:border dec:border-[#ccc]
dec:rounded-[3px]
dec:py-0.5 dec:px-1.5
dec:absolute
dec:text-[10px]
dec:pointer-events-auto;
}

.dec-root.dark .edge-label {
@apply dec:bg-gray-800
dec:border-gray-600
dec:text-gray-200;
}

.dec-root .edge-label.error {
@apply dec:bg-red-50
dec:border-red-500
dec:text-red-500;
}

.dec-root .edge-label.condition {
@apply dec:bg-blue-50
dec:border-blue-500
dec:text-blue-500;
}

.dec-root.dark .edge-label.condition {
@apply dec:bg-gray-800
dec:border-gray-600
dec:text-gray-200;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ import * as React from "react";
import * as RF from "@xyflow/react";
import { GraphNodeType } from "@serverlessworkflow/sdk";
import { NodeTypes } from "../nodes/Nodes";
import { DEFAULT_NODE_SIZE } from "../../core";
import { DEFAULT_NODE_SIZE, GraphEdgeType } from "../../core";
import "@xyflow/react/dist/style.css";
import "./Diagram.css";
import { ResolvedColorMode } from "../../types/colorMode";
import { EdgeTypes } from "../edges/Edges";

const FIT_VIEW_OPTIONS: RF.FitViewOptions = {
maxZoom: 1,
Expand Down Expand Up @@ -129,20 +130,100 @@ const initialNodes: RF.Node[] = [
data: { label: "Node 12" },
},
];

const initialEdges: RF.Edge[] = [
{ id: "n1-n2", source: "n1", target: "n2" },
{ id: "n2-n3", source: "n2", target: "n3" },
{ id: "n3-n4", source: "n3", target: "n4" },
{ id: "n3-n5", source: "n3", target: "n5" },
{ id: "n3-n6", source: "n3", target: "n6" },
{ id: "n4-n7", source: "n4", target: "n7" },
{ id: "n5-n7", source: "n5", target: "n7" },
{ id: "n6-n7", source: "n6", target: "n7" },
{ id: "n7-n8", source: "n7", target: "n8" },
{ id: "n8-n9", source: "n8", target: "n9" },
{ id: "n9-n10", source: "n9", target: "n10" },
{ id: "n10-n11", source: "n10", target: "n11" },
{ id: "n11-n12", source: "n11", target: "n12" },
{
id: "n1-n2",
source: "n1",
target: "n2",
type: GraphEdgeType.Default,
data: {
wayPoints: [
{ x: 145, y: 60 },
{ x: 170, y: 60 },
{ x: 170, y: 85 },
{ x: 145, y: 85 },
],
},
},
{
id: "n2-n3",
source: "n2",
target: "n3",
type: GraphEdgeType.Default,
data: { label: "Default" },
},
{
id: "n3-n4",
source: "n3",
target: "n4",
type: GraphEdgeType.Condition,
data: { label: "Case 1" },
},
{
id: "n3-n5",
source: "n3",
target: "n5",
type: GraphEdgeType.Condition,
data: { label: "Case 2" },
},
{
id: "n3-n6",
source: "n3",
target: "n6",
type: GraphEdgeType.Condition,
data: { label: "Default" },
animated: true,
},
{
id: "n4-n7",
source: "n4",
target: "n7",
type: GraphEdgeType.Default,
},
{
id: "n5-n7",
source: "n5",
target: "n7",
type: GraphEdgeType.Default,
},
{
id: "n6-n7",
source: "n6",
target: "n7",
type: GraphEdgeType.Default,
},
{
id: "n7-n8",
source: "n7",
target: "n8",
type: GraphEdgeType.Default,
},
{
id: "n8-n9",
source: "n8",
target: "n9",
type: GraphEdgeType.Error,
animated: true,
},
{
id: "n9-n10",
source: "n9",
target: "n10",
type: GraphEdgeType.Default,
},
{
id: "n10-n11",
source: "n10",
target: "n11",
type: GraphEdgeType.Default,
},
{
id: "n11-n12",
source: "n11",
target: "n12",
type: GraphEdgeType.Default,
},
];

/**
Expand Down Expand Up @@ -187,6 +268,7 @@ export const Diagram = ({ divRef, ref, colorMode = "light" }: DiagramProps) => {
<RF.ReactFlow
nodeTypes={NodeTypes}
nodes={nodes}
edgeTypes={EdgeTypes}
edges={edges}
onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange}
Expand All @@ -199,6 +281,13 @@ export const Diagram = ({ divRef, ref, colorMode = "light" }: DiagramProps) => {
selectionOnDrag={true}
fitView
colorMode={colorMode}
defaultEdgeOptions={{
markerEnd: {
type: RF.MarkerType.ArrowClosed,
width: 10,
height: 10,
},
}}
data-testid={"react-flow-canvas"}
>
{minimapVisible && <RF.MiniMap pannable zoomable position={"top-right"} />}
Expand Down
Loading
Loading