diff options
Diffstat (limited to 'subprojects/frontend/src/graph/GraphArea.tsx')
-rw-r--r-- | subprojects/frontend/src/graph/GraphArea.tsx | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/subprojects/frontend/src/graph/GraphArea.tsx b/subprojects/frontend/src/graph/GraphArea.tsx new file mode 100644 index 00000000..d5801b9a --- /dev/null +++ b/subprojects/frontend/src/graph/GraphArea.tsx | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | |||
7 | import Box from '@mui/material/Box'; | ||
8 | import { useTheme } from '@mui/material/styles'; | ||
9 | import { observer } from 'mobx-react-lite'; | ||
10 | import { useResizeDetector } from 'react-resize-detector'; | ||
11 | |||
12 | import DotGraphVisualizer from './DotGraphVisualizer'; | ||
13 | import type GraphStore from './GraphStore'; | ||
14 | import VisibilityPanel from './VisibilityPanel'; | ||
15 | import ZoomCanvas from './ZoomCanvas'; | ||
16 | |||
17 | function GraphArea({ graph }: { graph: GraphStore }): JSX.Element { | ||
18 | const { breakpoints } = useTheme(); | ||
19 | const { ref, width, height } = useResizeDetector({ | ||
20 | refreshMode: 'debounce', | ||
21 | }); | ||
22 | |||
23 | const breakpoint = breakpoints.values.sm; | ||
24 | const dialog = | ||
25 | width === undefined || | ||
26 | height === undefined || | ||
27 | width < breakpoint || | ||
28 | height < breakpoint; | ||
29 | |||
30 | return ( | ||
31 | <Box | ||
32 | width="100%" | ||
33 | height="100%" | ||
34 | overflow="hidden" | ||
35 | position="relative" | ||
36 | ref={ref} | ||
37 | > | ||
38 | <ZoomCanvas> | ||
39 | {(fitZoom) => <DotGraphVisualizer graph={graph} fitZoom={fitZoom} />} | ||
40 | </ZoomCanvas> | ||
41 | <VisibilityPanel graph={graph} dialog={dialog} /> | ||
42 | </Box> | ||
43 | ); | ||
44 | } | ||
45 | |||
46 | export default observer(GraphArea); | ||