Skip to content

Commit 0ae0381

Browse files
committed
A mostly working navbar
1 parent 1c3aa1d commit 0ae0381

File tree

8 files changed

+184
-27
lines changed

8 files changed

+184
-27
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"react-dom": "^18.3.1",
2929
"react-error-boundary": "^4.1.2",
3030
"react-query": "^3.39.3",
31+
"react-router-dom": "^5.3.4",
3132
"stream": "^0.0.3"
3233
},
3334
"devDependencies": {

src/App.tsx

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { OavMover } from "./screens/OavMover";
66
import "./App.css";
77
import { ParamsPanel } from "./screens/CollectionPanel";
88
import { ColourSchemeButton, Footer } from "@diamondlightsource/sci-react-ui";
9+
import { Switch, Route } from "react-router-dom";
10+
import { BeamlineI24 } from "./routes/BeamlineI24";
11+
import { FixedTarget } from "./routes/FixedTarget";
12+
import { SerialNavBar } from "./components/SerialNavBar";
913

1014
interface TabPanelProps {
1115
children?: React.ReactNode;
@@ -81,9 +85,35 @@ function FixedTargetPanels() {
8185
);
8286
}
8387

88+
// function App() {
89+
// const theme = useTheme();
90+
91+
// return (
92+
// <Box
93+
// sx={[
94+
// () => ({
95+
// display: "flex",
96+
// justifyContent: "space-between",
97+
// flexDirection: "column",
98+
// minHeight: "100vh",
99+
// minWidth: "320px",
100+
// margin: 0,
101+
// }),
102+
// ]}
103+
// >
104+
// <FixedTargetPanels />
105+
// <Footer
106+
// logo={theme.logos?.short}
107+
// color={theme.palette.primary.main}
108+
// leftSlot={<ColourSchemeButton />}
109+
// containerWidth={false}
110+
// />
111+
// </Box>
112+
// );
113+
// }
114+
84115
function App() {
85116
const theme = useTheme();
86-
87117
return (
88118
<Box
89119
sx={[
@@ -97,7 +127,15 @@ function App() {
97127
}),
98128
]}
99129
>
100-
<FixedTargetPanels />
130+
<SerialNavBar />
131+
<Switch>
132+
<Route exact path="/">
133+
<BeamlineI24 />
134+
</Route>
135+
<Route path="/fixed-target">
136+
<FixedTarget />
137+
</Route>
138+
</Switch>
101139
<Footer
102140
logo={theme.logos?.short}
103141
color={theme.palette.primary.main}

src/assets/i24ssx.svg

Lines changed: 4 additions & 0 deletions
Loading

src/components/SerialNavBar.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {
2+
Navbar,
3+
NavLinks,
4+
NavLink,
5+
type ImageColourSchemeSwitchType,
6+
} from "@diamondlightsource/sci-react-ui";
7+
import { Link } from "react-router-dom";
8+
import i24ssx from "../assets/i24ssx.svg";
9+
10+
// import { i24ssx } from "../assets/i24ssx.svg";
11+
12+
const ssxLogo: ImageColourSchemeSwitchType = {
13+
src: i24ssx,
14+
srcDark: i24ssx,
15+
alt: "i24 ssx",
16+
width: "100",
17+
};
18+
19+
export function SerialNavBar() {
20+
return (
21+
<Navbar logo={ssxLogo} containerWidth={false}>
22+
<NavLinks>
23+
<NavLink linkComponent={Link} to="/">
24+
Home
25+
</NavLink>
26+
<NavLink linkComponent={Link} to="/fixed-target">
27+
Fixed Target
28+
</NavLink>
29+
</NavLinks>
30+
</Navbar>
31+
);
32+
}

src/main.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import "./index.css";
44
import App from "./App.tsx";
55
import { Provider } from "react-redux";
66
import { store } from "@diamondlightsource/cs-web-lib";
7+
import { BrowserRouter } from "react-router-dom";
78

89
import { QueryClient, QueryClientProvider } from "react-query";
910
import { ThemeProvider } from "@diamondlightsource/sci-react-ui";
@@ -19,7 +20,9 @@ createRoot(document.getElementById("root")!).render(
1920
<ThemeProvider theme={I24DiamondTheme}>
2021
<Provider store={store}>
2122
<QueryClientProvider client={queryClient}>
22-
<App />
23+
<BrowserRouter>
24+
<App />
25+
</BrowserRouter>
2326
</QueryClientProvider>
2427
</Provider>
2528
</ThemeProvider>

src/routes/BeamlineI24.tsx

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { Box, Tab, Tabs, useTheme } from "@mui/material";
2+
import { BeamlineStatsTabPanel } from "../screens/BeamlineStats";
3+
import { DetectorMotionTabPanel } from "../screens/DetectorMotion";
4+
import { OavMover } from "../screens/OavMover";
5+
import React from "react";
6+
7+
interface TabPanelProps {
8+
children?: React.ReactNode;
9+
index: number;
10+
value: number;
11+
}
12+
13+
function a11yProps(index: number) {
14+
return {
15+
id: `simple-tab-${index}`,
16+
"aria-controls": `simple-tabpanel-${index}`,
17+
};
18+
}
19+
20+
function CustomTabPanel(props: TabPanelProps) {
21+
const { children, value, index, ...other } = props;
22+
23+
return (
24+
<div
25+
role="tabpanel"
26+
hidden={value !== index}
27+
id={`simple-tabpanel-${index}`}
28+
aria-labelledby={`simple-tab-${index}`}
29+
{...other}
30+
>
31+
{value === index && <Box sx={{ p: 3 }}>{children}</Box>}
32+
</div>
33+
);
34+
}
35+
36+
export function BeamlineI24() {
37+
const theme = useTheme();
38+
const [value, setValue] = React.useState(0);
39+
40+
const handleChange = (_event: React.SyntheticEvent, newValue: number) => {
41+
setValue(newValue);
42+
};
43+
return (
44+
<Box
45+
component="section"
46+
sx={{
47+
borderBottom: 1,
48+
borderColor: "divider",
49+
color: theme.palette.text.secondary,
50+
}}
51+
>
52+
<Tabs
53+
value={value}
54+
onChange={handleChange}
55+
aria-label="basic tabs example"
56+
textColor="secondary"
57+
centered
58+
>
59+
<Tab label="Beamline info" {...a11yProps(0)} />
60+
<Tab label="Detector position" {...a11yProps(1)} />
61+
<Tab label="OAV view" {...a11yProps(2)} />
62+
</Tabs>
63+
<CustomTabPanel value={value} index={0}>
64+
<BeamlineStatsTabPanel />
65+
</CustomTabPanel>
66+
<CustomTabPanel value={value} index={1}>
67+
<DetectorMotionTabPanel />
68+
</CustomTabPanel>
69+
<CustomTabPanel value={value} index={2}>
70+
<OavMover />
71+
</CustomTabPanel>
72+
</Box>
73+
);
74+
}

src/routes/FixedTarget.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Box } from "@mui/material";
2+
import { ParamsPanel } from "../screens/CollectionPanel";
3+
4+
export function FixedTarget() {
5+
return (
6+
<Box>
7+
<ParamsPanel />
8+
</Box>
9+
);
10+
}

0 commit comments

Comments
 (0)