feat(node-toolbar): change isActive to isVisible and implement default behavior

This commit is contained in:
Christopher Möller
2022-11-16 13:49:15 +01:00
parent 20a6653577
commit edbf894350
4 changed files with 17 additions and 6 deletions
@@ -1,10 +1,10 @@
import { memo, FC } from 'react';
import { Handle, Position, NodeProps, NodeToolbar } from 'reactflow';
const CustomNode: FC<NodeProps> = ({ id, data, selected }) => {
const CustomNode: FC<NodeProps> = ({ id, data }) => {
return (
<>
<NodeToolbar isActive={selected} nodeId={id} position={data.toolbarPosition}>
<NodeToolbar nodeId={id} isVisible={data.toolbarVisible} position={data.toolbarPosition}>
<button>delete</button>
<button>copy</button>
<button>expand</button>
@@ -20,7 +20,7 @@ const initialNodes: Node[] = [
id: '1',
type: 'custom',
data: { label: 'toolbar top', toolbarPosition: Position.Top },
position: { x: 0, y: 100 },
position: { x: 0, y: 0 },
className: 'react-flow__node-default',
},
{
@@ -44,6 +44,13 @@ const initialNodes: Node[] = [
position: { x: 400, y: 200 },
className: 'react-flow__node-default',
},
{
id: '5',
type: 'custom',
data: { label: 'toolbar always open', toolbarPosition: Position.Top, toolbarVisible: true },
position: { x: 0, y: 150 },
className: 'react-flow__node-default',
},
];
const initialEdges: Edge[] = [