Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions frontend/unified/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box, Divider, Grid2 as Grid, Stack, Typography } from "@mui/material";
import { SessionSelector } from "./components/SessionSelector";

const VERTICAL_SPACING = 2;
const HORIZONTAL_SPACING = 2;
Expand All @@ -9,11 +10,7 @@ export const App: React.FC = () => {
<Grid container spacing={HORIZONTAL_SPACING} columns={2}>
<Stack spacing={VERTICAL_SPACING}>
<Typography variant="h5">Session</Typography>
<PlaceholderComponent
placeholderText="Session selector component placeholder"
height={100}
width={500}
/>
<SessionSelector />
<Divider sx={{ width: "100%" }} />
<Typography variant="h5">Scan</Typography>
<PlaceholderComponent
Expand Down
66 changes: 66 additions & 0 deletions frontend/unified/src/components/SessionSelector.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import {
Chip,
TextField,
ToggleButton,
ToggleButtonGroup,
Stack,
} from "@mui/material";
import { useState } from "react";

enum SessionSelectionMode {
Latest = "Latest",
Custom = "Custom",
}

export const SessionSelector: React.FC = () => {
// TODO: initial value based on fetching latest session associated with logged-in user
const [session] = useState<string>("latest-session");
// TODO: initial value based on the initial session
const [beamline] = useState<string>("Beamline: depends-on-session");
const [sessionSelectionMode, setSessionSelectionMode] =
useState<SessionSelectionMode>(SessionSelectionMode.Latest);
const [textInputValue, setTextInputValue] = useState<string>("");

return (
<Stack direction="row" spacing={2} alignItems={"center"}>
<ToggleButtonGroup
exclusive
value={sessionSelectionMode}
onChange={(_, toggleButtonLabel: string) => {
if (toggleButtonLabel === SessionSelectionMode.Latest) {
setSessionSelectionMode(SessionSelectionMode.Latest);
} else if (toggleButtonLabel === SessionSelectionMode.Custom) {
setSessionSelectionMode(SessionSelectionMode.Custom);
}
}}
>
<ToggleButton
sx={{ textTransform: "none" }}
value={SessionSelectionMode.Latest}
>
{SessionSelectionMode.Latest}
</ToggleButton>
<ToggleButton
sx={{ textTransform: "none" }}
value={SessionSelectionMode.Custom}
>
{SessionSelectionMode.Custom}
</ToggleButton>
</ToggleButtonGroup>
<TextField
variant="outlined"
label="Session"
disabled={sessionSelectionMode === SessionSelectionMode.Latest}
value={
sessionSelectionMode === SessionSelectionMode.Latest
? session
: textInputValue
}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
setTextInputValue(e.currentTarget.value);
}}
/>
<Chip label={beamline} variant="outlined" color="primary"></Chip>
</Stack>
);
};
Loading