chore(examples): cleanup
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import React, { memo, FC, CSSProperties } from 'react';
|
import React, { memo, FC, CSSProperties } from 'react';
|
||||||
|
|
||||||
import { Handle, NodeProps, Position } from '@xyflow/react';
|
import { Handle, NodeProps, Position, useInternalNode } from '@xyflow/react';
|
||||||
|
|
||||||
const infoStyle: CSSProperties = { fontSize: 11 };
|
const infoStyle: CSSProperties = { fontSize: 11 };
|
||||||
const idStyle: CSSProperties = {
|
const idStyle: CSSProperties = {
|
||||||
@@ -12,6 +12,8 @@ const idStyle: CSSProperties = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const DebugNode: FC<NodeProps> = ({ zIndex, positionAbsoluteX, positionAbsoluteY, id }) => {
|
const DebugNode: FC<NodeProps> = ({ zIndex, positionAbsoluteX, positionAbsoluteY, id }) => {
|
||||||
|
const node = useInternalNode(id)!;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Handle type="target" position={Position.Top} />
|
<Handle type="target" position={Position.Top} />
|
||||||
@@ -19,6 +21,9 @@ const DebugNode: FC<NodeProps> = ({ zIndex, positionAbsoluteX, positionAbsoluteY
|
|||||||
<div style={infoStyle}>
|
<div style={infoStyle}>
|
||||||
x:{Math.round(positionAbsoluteX)} y:{Math.round(positionAbsoluteY)} z:{zIndex}
|
x:{Math.round(positionAbsoluteX)} y:{Math.round(positionAbsoluteY)} z:{zIndex}
|
||||||
</div>
|
</div>
|
||||||
|
<div style={infoStyle}>
|
||||||
|
x:{Math.round(node.position.x)} y:{Math.round(node.position.y)}
|
||||||
|
</div>
|
||||||
<Handle type="source" position={Position.Bottom} />
|
<Handle type="source" position={Position.Bottom} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const defaultViewport = { x: 0, y: 0, zoom: 1.5 };
|
|||||||
const initialNodes: Node[] = [
|
const initialNodes: Node[] = [
|
||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
// type: 'input',
|
type: 'input',
|
||||||
data: { label: 'Node 1' },
|
data: { label: 'Node 1' },
|
||||||
position: { x: 250, y: 5 },
|
position: { x: 250, y: 5 },
|
||||||
className: 'light',
|
className: 'light',
|
||||||
@@ -90,11 +90,10 @@ const initialNodes: Node[] = [
|
|||||||
id: '5',
|
id: '5',
|
||||||
type: 'group',
|
type: 'group',
|
||||||
data: { label: 'Node 5' },
|
data: { label: 'Node 5' },
|
||||||
position: { x: 900, y: 250 },
|
position: { x: 650, y: 250 },
|
||||||
className: 'light',
|
className: 'light',
|
||||||
style: { width: 100, height: 100 },
|
style: { width: 100, height: 100 },
|
||||||
zIndex: 1000,
|
zIndex: 1000,
|
||||||
origin: [1, 0],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '5a',
|
id: '5a',
|
||||||
@@ -107,7 +106,7 @@ const initialNodes: Node[] = [
|
|||||||
{
|
{
|
||||||
id: '5b',
|
id: '5b',
|
||||||
data: { label: 'Node 5b' },
|
data: { label: 'Node 5b' },
|
||||||
position: { x: 225, y: 50 },
|
position: { x: 200, y: 200 },
|
||||||
className: 'light',
|
className: 'light',
|
||||||
parentId: '5',
|
parentId: '5',
|
||||||
expandParent: true,
|
expandParent: true,
|
||||||
@@ -121,9 +120,9 @@ const initialNodes: Node[] = [
|
|||||||
{
|
{
|
||||||
id: '3',
|
id: '3',
|
||||||
data: { label: 'Node 3' },
|
data: { label: 'Node 3' },
|
||||||
position: { x: 250, y: 100 },
|
position: { x: 400, y: 100 },
|
||||||
className: 'light',
|
className: 'light',
|
||||||
// extent: 'parent',
|
extent: 'parent',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -220,6 +219,7 @@ const Subflow = () => {
|
|||||||
onlyRenderVisibleElements={false}
|
onlyRenderVisibleElements={false}
|
||||||
nodeTypes={nodeTypes}
|
nodeTypes={nodeTypes}
|
||||||
fitView
|
fitView
|
||||||
|
nodeOrigin={[0, 0]}
|
||||||
>
|
>
|
||||||
<MiniMap />
|
<MiniMap />
|
||||||
<Controls />
|
<Controls />
|
||||||
|
|||||||
Reference in New Issue
Block a user