repeat node initial support

This commit is contained in:
ari committed 2022-07-13 10:52:56 -04:00
1 parent f392cf17fd
commit de2307901b
13 files changed
+301 -77

No files matched your search

@@ -30,6 +30,10 @@ export const ButtonNode: FC<ButtonNodeProps> = ({
position={flipped ? Position.Top : Position.Left}
/>
{icon}
<Handle
type="source"
position={!flipped ? Position.Bottom : Position.Right}
/>
</>
}
onClick={onClick}
@@ -51,9 +51,6 @@
overflow: auto;
}
.collection-nodes .react-flow__handle {
opacity: 0;
}
.collection-nodes--total {
position: absolute;
@@ -17,7 +17,6 @@ export const CollectionNode: FC<CollectionNodeProps> = ({
width,
flipped,
color,
hasInput = false,
collectionType,
}) => {
const nodeColor = useSequenceNodeColor(color);
@@ -54,13 +53,20 @@ export const CollectionNode: FC<CollectionNodeProps> = ({
type="source"
position={flipped ? Position.Bottom : Position.Right}
/>
{hasInput && (
<>
<Handle
id="default"
key="target"
type="target"
position={flipped ? Position.Top : Position.Left}
/>
)}
<Handle
id="return"
key="target-return"
type="target"
position={!flipped ? Position.Top : Position.Right}
/>
</>
<span className="collection-nodes--total">
{nodes.length} node{nodes.length !== 1 ? "s" : ""}
</span>
@@ -5,14 +5,18 @@ import { CollectionNode } from "./CollectionNode";
import { DAGGraphBoard } from "components/DAGGraph/board";
import { CollectionNodeMaker } from "./index";
import { DEFAULT_DIMS } from "components/DAGGraph/elements/constants";
import { ButtonNodeMaker } from "../ButtonNode";
import { AddCircle } from "@mui/icons-material";
import { MarkerType } from "react-flow-renderer";
const Demo: FC<{
type DemoProps = {
height: number;
width: number;
totalChildNodes: number;
onAddNode: () => void;
enabledChild: boolean;
}> = (args) => {
};
const Demo: FC<DemoProps> = (args) => {
return (
<Page>
<DAGGraphBoard
@@ -124,3 +128,95 @@ Empty.args = {
...Empty.args,
totalChildNodes: 0,
};
export const ReturnTarget: ComponentStory<typeof Demo> = (args) => {
return (
<Page>
<DAGGraphBoard
closeModal={() => {}}
state={{
ready: true,
data: {
elements: {
edges: [
{
id: "1",
source: "root",
target: "btn",
label: "1",
},
{
id: "2",
target: "root",
source: "btn",
animated: true,
targetHandle: "return",
label: "2",
markerEnd: {
type: MarkerType.ArrowClosed,
width: 25,
height: 25,
},
},
{
id: "3",
target: "root",
source: "btn",
label: "3",
},
],
nodes: [
ButtonNodeMaker.makeElement(
{
id: "btn",
position: {
x: 50 + (args.width - DEFAULT_DIMS.node.width) / 2,
y:
50 +
args.height *
2 *
DEFAULT_DIMS.distanceFactor.collection,
},
},
DEFAULT_DIMS,
{
icon: <AddCircle />,
onClick: () => {},
}
),
CollectionNodeMaker.makeElement(
{
id: "root",
position: {
x: 50,
y: 50,
},
},
DEFAULT_DIMS,
{
onAddNode: args.onAddNode,
width: args.width,
height: args.height,
nodes: [
{
enabled: args.enabledChild,
label: "condition",
},
...Array.from(Array(args.totalChildNodes)).map(
(_, i) => ({
enabled: true,
label: `Dummy Node #${i + 1}`,
})
),
],
collectionType: "condition",
}
),
],
},
},
}}
/>
</Page>
);
};
@@ -93,15 +93,15 @@ export const OnMoveAllDirections = Template.bind({});
OnMoveAllDirections.args = {
...OnMoveAllDirections.args,
onMove: {
up: console.log,
down: console.log,
left: console.log,
right: console.log,
up: console.info,
down: console.info,
left: console.info,
right: console.info,
},
onAdd: {
up: console.log,
down: console.log,
left: console.log,
right: console.log,
up: console.info,
down: console.info,
left: console.info,
right: console.info,
},
};