Skip to content

Commit 5ee13a6

Browse files
authored
make menu responsive, update sci-react-ui (#62)
1 parent bac838a commit 5ee13a6

File tree

7 files changed

+337
-144
lines changed

7 files changed

+337
-144
lines changed

web-conexs-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"tsc": "tsc"
1313
},
1414
"dependencies": {
15-
"@diamondlightsource/sci-react-ui": "^0.2.0",
15+
"@diamondlightsource/sci-react-ui": "^0.3.0",
1616
"@emotion/react": "^11.14.0",
1717
"@emotion/styled": "^11.14.0",
1818
"@h5web/lib": "^13.0.0",

web-conexs-client/pnpm-lock.yaml

Lines changed: 36 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web-conexs-client/src/App.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function App() {
4141
<UserProvider>
4242
<Stack height="100vh" width="100vw" spacing={1}>
4343
<Header />
44+
4445
{/* <Stack direction="row" flex={1}> */}
4546
<SideDrawer />
4647
<Routes>
@@ -154,8 +155,11 @@ function App() {
154155
</Routes>
155156
<Footer
156157
copyright="Diamond Light Source"
157-
logo={"null"}
158-
sx={{ zIndex: (theme) => theme.zIndex.drawer + 1 }}
158+
logo={undefined}
159+
sx={{
160+
zIndex: (theme) => theme.zIndex.drawer + 1,
161+
height: "6rem",
162+
}}
159163
></Footer>
160164
</Stack>
161165
</UserProvider>

web-conexs-client/src/components/Header.tsx

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,103 @@
1-
import { Stack, Typography, useTheme } from "@mui/material";
1+
import {
2+
Box,
3+
Drawer,
4+
IconButton,
5+
Stack,
6+
Typography,
7+
useTheme,
8+
} from "@mui/material";
9+
import MenuIcon from "@mui/icons-material/Menu";
210

3-
import { useContext } from "react";
11+
import { useContext, useState } from "react";
412
import { UserContext } from "../UserContext";
513
import {
614
ColourSchemeButton,
715
Navbar,
816
User,
17+
Logo,
918
} from "@diamondlightsource/sci-react-ui";
1019

1120
import ClusterBadge from "./ClusterBadge";
21+
import SideToolbar from "./SideToolbar";
1222

1323
export default function Header() {
1424
const user = useContext(UserContext);
1525
const theme = useTheme();
26+
const [mobileOpen, setMobileOpen] = useState(false);
27+
const [isClosing, setIsClosing] = useState(false);
28+
29+
const handleDrawerClose = () => {
30+
setIsClosing(true);
31+
setMobileOpen(false);
32+
};
33+
34+
const handleDrawerTransitionEnd = () => {
35+
setIsClosing(false);
36+
};
37+
38+
const handleDrawerToggle = () => {
39+
if (!isClosing) {
40+
setMobileOpen(!mobileOpen);
41+
}
42+
};
1643

1744
const handleLogin = () => window.location.assign("/login");
1845

1946
const handleLogout = () => window.location.assign("/oauth2/sign_out");
2047

48+
const icon = theme.logos?.short;
49+
2150
return (
2251
<Navbar
2352
sx={{
2453
zIndex: (theme) => theme.zIndex.drawer + 1,
54+
height: "4rem",
2555
}}
26-
logo="theme"
56+
leftSlot={
57+
<Stack direction="row" alignItems="center">
58+
<IconButton
59+
size="large"
60+
onClick={handleDrawerToggle}
61+
sx={{
62+
color: theme.palette.primary.contrastText,
63+
display: { xs: "block", md: "none" },
64+
}}
65+
>
66+
<MenuIcon fontSize="inherit"></MenuIcon>
67+
</IconButton>
68+
<Drawer
69+
variant="temporary"
70+
open={mobileOpen}
71+
onTransitionEnd={handleDrawerTransitionEnd}
72+
onClose={handleDrawerClose}
73+
onClick={() => {
74+
handleDrawerClose();
75+
handleDrawerTransitionEnd();
76+
}}
77+
>
78+
<SideToolbar open={mobileOpen}></SideToolbar>
79+
</Drawer>
80+
{icon && (
81+
<Box
82+
maxWidth="2rem"
83+
margin="5px"
84+
height="100%"
85+
sx={{
86+
"&:hover": { filter: "brightness(80%);" },
87+
marginRight: { xs: "0", md: "50px" },
88+
}}
89+
>
90+
<Logo short={true}></Logo>
91+
</Box>
92+
)}
93+
</Stack>
94+
}
95+
logo={undefined}
2796
rightSlot={
2897
<Stack direction="row" alignItems="center">
2998
<ClusterBadge></ClusterBadge>
3099
<User
31-
color="white"
100+
colour="white"
32101
onLogin={handleLogin}
33102
onLogout={handleLogout}
34103
user={

web-conexs-client/src/components/MainPanel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export default function MainPanel(props: { children: React.ReactNode }) {
1616
<Paper
1717
flex={1}
1818
sx={{
19-
margin: "10px 10px 10px " + sideGap,
19+
margin: "10px 10px 10px 10px",
20+
ml: { sm: "10px", md: sideGap },
2021
flex: 1,
2122
minHeight: 0,
2223
alignItems: "stretch",

0 commit comments

Comments
 (0)