Skip to content

Commit 5212be4

Browse files
committed
Reafctor implementation
1 parent c612ffd commit 5212be4

File tree

4 files changed

+272
-261
lines changed

4 files changed

+272
-261
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"private": true,
66
"dependencies": {
77
"@codecov/vite-plugin": "1.7.0",
8+
"@dagrejs/dagre": "^1.1.4",
89
"@date-io/date-fns": "3.2.0",
910
"@emotion/react": "^11.11.4",
1011
"@emotion/styled": "^11.11.5",
@@ -33,7 +34,6 @@
3334
"blob-polyfill": "^9.0.20240710",
3435
"browserslist": "^4.23.0",
3536
"browserslist-to-esbuild": "^2.1.1",
36-
"dagre": "^0.8.5",
3737
"date-fns": "4.1.0",
3838
"history": "^5.3.0",
3939
"loglevel": "^1.9.1",

src/systems/systemsNodeHeader.component.tsx

Lines changed: 49 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { MoreHoriz } from '@mui/icons-material';
2-
import { Grid, IconButton } from '@mui/material';
2+
import { Card, Divider, Grid, IconButton } from '@mui/material';
33
import { Handle, Position } from '@xyflow/react';
44
import React from 'react';
55
import { OverflowTip } from '../utils';
@@ -9,92 +9,79 @@ interface SystemsNodeHeaderProps {
99
title: string | React.ReactNode;
1010
label: string | React.ReactNode;
1111
direction?: 'TB' | 'LR';
12-
setNodeDimensions: (nodeId: string, width: number, height: number) => void;
13-
nodeId: string;
12+
id: string;
1413
};
1514
}
1615

1716
const SystemsNodeHeader = (props: SystemsNodeHeaderProps) => {
1817
const { data } = props;
1918

20-
const containerRef = React.useRef<HTMLDivElement | null>(null);
21-
22-
React.useEffect(() => {
23-
if (containerRef.current) {
24-
const { offsetWidth, offsetHeight } = containerRef.current;
25-
data.setNodeDimensions(data.nodeId, offsetWidth, offsetHeight);
26-
}
27-
}, [data, containerRef]);
28-
2919
const isHorizontal = data.direction === 'LR';
3020
return (
31-
<Grid
32-
ref={containerRef}
33-
container
34-
direction="column"
35-
sx={{
36-
border: '1px solid #ddd',
37-
borderRadius: 1,
38-
overflow: 'hidden',
39-
boxShadow: 1,
40-
width: '100%',
41-
padding: 2,
42-
backgroundColor: 'white',
43-
}}
44-
>
45-
{/* Header Section */}
46-
<Grid
47-
item
21+
<>
22+
<Card
23+
component={Grid}
4824
container
49-
alignItems="center"
50-
justifyContent="space-between"
25+
direction="column"
5126
sx={{
52-
borderBottom: '1px solid #ddd',
53-
paddingBottom: 1,
54-
marginBottom: 1,
27+
padding: 2,
28+
width: '100%',
5529
}}
5630
>
31+
{/* Header Section */}
5732
<Grid
5833
item
59-
sx={{ display: 'flex', alignItems: 'center', gap: 1 }}
60-
xs={8}
34+
container
35+
alignItems="center"
36+
justifyContent="space-between"
37+
sx={{
38+
paddingBottom: 1,
39+
marginBottom: 1,
40+
}}
6141
>
62-
<OverflowTip sx={{ fontWeight: 'bold', typography: 'h6' }}>
63-
{data.title}
64-
</OverflowTip>
42+
<Grid
43+
item
44+
sx={{ display: 'flex', alignItems: 'center', gap: 1 }}
45+
xs={8}
46+
>
47+
<OverflowTip sx={{ fontWeight: 'bold', typography: 'h6' }}>
48+
{data.title}
49+
</OverflowTip>
50+
</Grid>
51+
<Grid
52+
item
53+
sx={{ display: 'flex', alignItems: 'center', margin: 1 }}
54+
xs={2}
55+
>
56+
{/* Actions Menu */}
57+
<IconButton size="small">
58+
<MoreHoriz />
59+
</IconButton>
60+
</Grid>
6561
</Grid>
66-
<Grid
67-
item
68-
sx={{ display: 'flex', alignItems: 'center', margin: 1 }}
69-
xs={2}
70-
>
71-
{/* Actions Menu */}
72-
<IconButton size="small">
73-
<MoreHoriz />
74-
</IconButton>
62+
<Divider />
63+
{/* Label Section */}
64+
<Grid item>
65+
{typeof data.label === 'string' ? (
66+
<OverflowTip sx={{ fontWeight: 'bold', typography: 'body2' }}>
67+
{data.label}
68+
</OverflowTip>
69+
) : (
70+
data.label
71+
)}
7572
</Grid>
76-
</Grid>
77-
78-
{/* Label Section */}
79-
<Grid item>
80-
{typeof data.label === 'string' ? (
81-
<OverflowTip sx={{ fontWeight: 'bold', typography: 'body2' }}>
82-
{data.label}
83-
</OverflowTip>
84-
) : (
85-
data.label
86-
)}
87-
</Grid>
88-
73+
</Card>
8974
<Handle
9075
type="source"
9176
position={isHorizontal ? Position.Right : Position.Bottom}
77+
id={data.id}
9278
/>
9379
<Handle
9480
type="target"
9581
position={isHorizontal ? Position.Left : Position.Top}
82+
id={data.id}
9683
/>
97-
</Grid>
84+
</>
9885
);
9986
};
10087

0 commit comments

Comments
 (0)