resizeable collection nodes

This commit is contained in:
ari committed 2022-07-10 13:12:37 -04:00
1 parent 7483f2b65d
commit 1d7b6e96c1
4 files changed
+234 -39

No files matched your search

@@ -1,11 +1,26 @@
.collection-nodes {
.collection-nodes--wrap {
--padding: 1.5em;
/* outline: 1px dotted white; */
min-width: var(--node-width);
min-height: var(--node-height);
max-width: var(--node-width);
max-height: var(--node-height);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.collection-nodes {
position: relative;
display: flex;
flex-wrap: wrap;
flex-direction: row;
align-items: center;
gap: 1.5em;
max-width: var(--node-width);
max-height: var(--node-height);
border-color: var(--node-color);
border-style: solid;
@@ -13,4 +28,8 @@
border-radius: 10px;
overflow: auto;
padding: var(--padding);
}
.collection-nodes .react-flow__handle {
opacity: 0;
}
@@ -22,37 +22,37 @@ export const CollectionNode: FC<CollectionNodeProps> = ({
return (
<div
className="collection-nodes"
className="collection-nodes--wrap"
style={
{
"--node-color": nodeColor,
minHeight: `calc(${height}px - 2*var(--padding))`,
minWidth: `calc(${width}px - 2*var(--padding))`,
maxHeight: `calc(${height}px - 2*var(--padding))`,
maxWidth: `calc(${width}px - 2*var(--padding))`,
"--node-height": `calc(${height}px - 2*var(--padding))`,
"--node-width": `calc(${width}px - 2*var(--padding))`,
} as any
}
>
{nodes.map((n, i) => (
<SequenceNodeElement
{...n}
{...sequenceNode}
key={i}
color={color}
flipped={flipped}
/>
))}
<ButtonIcon icon={<Add />} onClick={onAddNode} />
<Handle
type="source"
position={flipped ? Position.Bottom : Position.Right}
/>
{hasInput && (
<div className="collection-nodes">
{nodes.map((n, i) => (
<SequenceNodeElement
{...n}
{...sequenceNode}
key={i}
color={color}
flipped={flipped}
/>
))}
<ButtonIcon icon={<Add />} onClick={onAddNode} />
<Handle
type="target"
position={flipped ? Position.Top : Position.Left}
type="source"
position={flipped ? Position.Bottom : Position.Right}
/>
)}
{hasInput && (
<Handle
type="target"
position={flipped ? Position.Top : Position.Left}
/>
)}
</div>
</div>
);
};