Skip to content

Commit

Permalink
Added Basic flow for the application
Browse files Browse the repository at this point in the history
  • Loading branch information
itsparser committed Feb 15, 2024
1 parent c6f008f commit 454963b
Show file tree
Hide file tree
Showing 11 changed files with 390 additions and 91 deletions.
7 changes: 6 additions & 1 deletion src/components/flow/components/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export const New: React.FC<any> = () => {
key: "block",
label: "Block",
icon: <CodeBracketSquareIcon className="h-5 w-5 text-gray-400" />
},
{
key: "action_group",
label: "Action group",
icon: <CodeBracketSquareIcon className="h-5 w-5 text-gray-400" />
}
];
const [open, setOpen] = useState(false);
Expand All @@ -47,7 +52,7 @@ export const New: React.FC<any> = () => {
onMouseOver={() => setOpen(true)}
onMouseOut={() => setOpen(false)}
className={
"absolute z-10000 mt-1 max-h-56 w-40 -left-16 overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"
"absolute z-50 mt-1 max-h-56 w-40 -left-16 overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"
}
>
{options.map((item) => (
Expand Down
12 changes: 5 additions & 7 deletions src/components/flow/edge/general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
BaseEdge,
EdgeLabelRenderer,
EdgeProps,
getSmoothStepPath
getStraightPath
} from "reactflow";

// export default function CustomEdge() {
Expand Down Expand Up @@ -41,16 +41,14 @@ export const DefaultEdge: React.FC<EdgeProps> = ({
}
];
const [open, setOpen] = useState(false);
const [edgePath, labelX, labelY] = getSmoothStepPath({
const [edgePath, labelX, labelY] = getStraightPath({
sourceX,
sourceY,
targetX,
targetY,
sourcePosition,
targetPosition
targetY
// sourcePosition,
// targetPosition
});
console.log("edgePath", edgePath);
console.log("edgePath", `M`);

return (
<>
Expand Down
6 changes: 2 additions & 4 deletions src/components/flow/edge/no.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from "reactflow";
import { New } from "../components";

// export default function CustomEdge() {
export const NoEdge: React.FC<EdgeProps> = ({
id,
sourceX,
Expand All @@ -34,9 +33,8 @@ export const NoEdge: React.FC<EdgeProps> = ({
<div
style={{
position: "absolute",
transform: `translate(-50%, -50%) translate(${targetX}px,${
sourceY + 40
}px)`,
transform: `translate(-50%, -50%) translate(${targetX}px,${sourceY + 40
}px)`,
fontSize: 12,
// everything inside EdgeLabelRenderer has no pointer events by default
// if you have an interactive element, set pointer-events: all
Expand Down
73 changes: 63 additions & 10 deletions src/components/flow/flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ let initNode = [
},
{
id: "2",
// type: "actionNode",
type: "actionNode",
position: {
x: 0,
y: 0
Expand All @@ -165,14 +165,47 @@ let initNode = [
},
{
id: "3",
// type: "actionNode",
type: "actionNode",
position: {
x: 0,
y: 0
},
data: {
label: "actionNode 3"
}
},
{
id: "4",
type: "conditionalNode",
position: {
x: 0,
y: 0
},
data: {
label: "actionNode 4"
}
},
{
id: "5",
type: "actionNode",
position: {
x: 0,
y: 0
},
data: {
label: "actionNode 5"
}
},
{
id: "6",
type: "actionNode",
position: {
x: 0,
y: 0
},
data: {
label: "actionNode 6 he how are you"
}
}
];

Expand All @@ -191,6 +224,28 @@ let initEdge = [

target: "3",
source: "1"
},
{
id: "3->4",
type: "defaultE",

target: "4",
source: "3"
},
{
id: "4->5",
type: "yes",
target: "5",
sourceHandle: "yes",
source: "4"
},
{
id: "4->6",
type: "no",
sourceHandle: "no",

target: "6",
source: "4"
}
];

Expand All @@ -216,10 +271,7 @@ export default function RFlow() {
rankdir: "TB",
ranker: "network-simplex",
marginx: 30,
marginy: 30
// height: 2000,
// width: 2000,
// align: "UL"
marginy: 20
});

const nodeWidth = 400;
Expand All @@ -230,10 +282,11 @@ export default function RFlow() {
};

nodes.forEach((node) => {
// let t: string = node["type"];
// let s: any = sizeMatrix[t] || { width: 172, height: 36 };
// console.log("result", s);
dagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });
let t: string = node["type"];
let s: any = sizeMatrix[t] || { width: 172, height: 36 };
console.log("currect value of the width and height ", t, " - ", s);
s = { width: nodeWidth, height: nodeHeight };
dagreGraph.setNode(node.id, s);
});

edges.forEach((edge) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/flow/node/action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const ActionNode: React.FC<NodeProps> = ({ data, xPos, yPos }) => {
/>
<div className="h-10 w-44 border-white bg-indigo-400 rounded-lg shadow-sm hover:shadow-md">
<div className="self-center p-2 align-middle text-center">
[ {data?.payload?.type_field} ]
[ {data.label} ]{/* [ {data?.payload?.type_field} ] */}
</div>
</div>

Expand Down
5 changes: 5 additions & 0 deletions src/components/flow/node/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export const NewNode: React.FC<NodeProps> = ({ data, xPos, yPos }) => {
key: "block",
label: "Block",
icon: <CodeBracketSquareIcon className="h-5 w-5 text-gray-400" />
},
{
key: "action_group",
label: "Action group",
icon: <CodeBracketSquareIcon className="h-5 w-5 text-gray-400" />
}
];
const [selected, setValueSelected] = useState({} as any);
Expand Down
5 changes: 5 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
@tailwind base;
@tailwind components;
@tailwind utilities;


.react-flow__nodes {
z-index: -5 !important;
}
Loading

0 comments on commit 454963b

Please sign in to comment.