-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.tsx
106 lines (94 loc) · 2.79 KB
/
demo.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import * as React from "react";
import CssBaseline from "@mui/material/CssBaseline";
import Box from "@mui/material/Box";
import Button from "@mui/material/Button/Button";
import Paper from "@mui/material/Paper";
import { Allotment } from "allotment";
import "allotment/dist/style.css";
import { useAppDispatch, useAppSelector } from "./hooks";
import { openPanel, closePanel, Panel } from "./perspectiveSlice";
import { AppBar, IconButton } from "@mui/material";
import AddRoad from "@mui/icons-material/AddRoad";
const styles = {
appRoot: {
height: "100vh",
display: "flex",
flexDirection: "column"
},
appContentContainer: {
flex: "1 1 auto",
display: "flex",
flexDirection: "row",
alignItems: "stretch"
},
header: {
height: 50,
display: "flex",
flexDirection: "row",
alignItems: "center"
},
actionBar: {
width: 64,
flex: "0 1"
},
mainArea: {
display: "flex",
flex: "1 1 auto",
flexDirection: "row",
alignItems: "stretch",
justifyContent: "stretch"
},
tabContainer: {
flexGrow: 4,
position: "relative",
overflow: "hidden"
}
};
export default function SimpleContainer() {
const dispatch = useAppDispatch();
const panels: Panel[] = useAppSelector((state) => state.panels);
return (
<React.Fragment>
<CssBaseline />
<Box sx={styles.appRoot}>
<AppBar position="relative" elevation={1} sx={styles.header}>
Perspective Demo
</AppBar>
<Box sx={styles.appContentContainer}>
<Box sx={styles.actionBar}>
<Paper elevation={1}>
<IconButton onClick={(e) => dispatch(openPanel())}>
<AddRoad />
</IconButton>
</Paper>
</Box>
<Box sx={styles.mainArea}>
<Box sx={styles.tabContainer}>
<Allotment snap>
{panels.map((p) => (
<Allotment.Pane key={p.id}>
<div style={{ height: "100%", backgroundColor: "#ccc" }}>
{p.label}{" "}
<Button
onClick={(e) => dispatch(closePanel(p.id))}
variant="outlined"
>
Close Panel
</Button>
<Button
onClick={(e) => dispatch(openPanel(p.id))}
variant="outlined"
>
Split
</Button>
</div>
</Allotment.Pane>
))}
</Allotment>
</Box>
</Box>
</Box>
</Box>
</React.Fragment>
);
}