Skip to content

Commit 3007bd2

Browse files
committed
Make a component for an input text field with a tooltip included
1 parent 4dd4298 commit 3007bd2

File tree

3 files changed

+68
-73
lines changed

3 files changed

+68
-73
lines changed

src/components/ParameterInputs.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { TextField, Tooltip } from "@mui/material";
2+
import React from "react";
3+
4+
interface InputProps<T> {
5+
value: T;
6+
onSet: React.Dispatch<React.SetStateAction<T>>;
7+
label: string;
8+
tooltip?: string;
9+
}
10+
11+
export function ParameterInput<T>(props: InputProps<T>) {
12+
const handleChange = (newValue: string) => {
13+
if (typeof props.value === "number") {
14+
props.onSet(Number(newValue));
15+
} else {
16+
props.onSet(newValue);
17+
}
18+
};
19+
return (
20+
<Tooltip title={props.tooltip ? props.tooltip : ""} placement="left">
21+
<TextField
22+
size="small"
23+
label={props.label}
24+
defaultValue={props.value}
25+
onChange={(e) => handleChange(e.target.value)}
26+
style={{ width: 180 }}
27+
/>
28+
</Tooltip>
29+
);
30+
}

src/components/SelectionControl.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function SelectionWithPlanRunner(props: SelectionProps) {
2929
submitAndRunPlanImmediately({
3030
planName: props.plan_name,
3131
planParams: { position: newValue },
32+
instrumentSession: "", // FIXME, temporary
3233
});
3334
};
3435

src/screens/CollectionPanel.tsx

Lines changed: 37 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import {
66
MenuItem,
77
Select,
88
Stack,
9-
TextField,
109
Tooltip,
1110
} from "@mui/material";
1211
import React from "react";
1312
import { PumpProbeOptions } from "../components/FixedTarget/PumpProbeComponents";
1413
import { MapView } from "../components/FixedTarget/FixedTargetMapComponents";
1514
import { chipTypes, MapTypes, pumpProbeMode } from "../components/params";
1615
import { AbortButton, RunPlanButton } from "../blueapi/BlueapiComponents";
16+
import { ParameterInput } from "../components/ParameterInputs";
1717

1818
type ParametersProps = {
1919
subDir: string;
@@ -91,78 +91,42 @@ function CollectionInput() {
9191
<Grid2 container spacing={2}>
9292
<Grid2 size={4.5}>
9393
<Stack direction={"column"} spacing={1} alignItems={"center"}>
94-
<Tooltip
95-
title="Location inside visit directory to save data"
96-
placement="left"
97-
>
98-
<TextField
99-
size="small"
100-
label="Sub-directory"
101-
defaultValue={subDir}
102-
onChange={(e) => setSubDir(String(e.target.value))}
103-
style={{ width: 180 }}
104-
/>
105-
</Tooltip>
106-
<Tooltip
107-
title="Chip identifier, this will be used as filename"
108-
placement="left"
109-
>
110-
<TextField
111-
size="small"
112-
label="Chip Name"
113-
defaultValue={chipName}
114-
onChange={(e) => setChipName(String(e.target.value))}
115-
style={{ width: 180 }}
116-
/>
117-
</Tooltip>
118-
<Tooltip
119-
title="How many consecutive times each window should be collected."
120-
placement="left"
121-
>
122-
<TextField
123-
size="small"
124-
label="Shots Per Aperture"
125-
defaultValue={shots}
126-
onChange={(e) => setShots(Number(e.target.value))}
127-
style={{ width: 180 }}
128-
/>
129-
</Tooltip>
130-
<Tooltip
131-
title="Exposure time for each window, in seconds"
132-
placement="left"
133-
>
134-
<TextField
135-
size="small"
136-
label="Exposure Time (s)"
137-
defaultValue={expTime}
138-
onChange={(e) => setExpTime(Number(e.target.value))}
139-
style={{ width: 180 }}
140-
/>
141-
</Tooltip>
142-
<Tooltip
143-
title="Request transmission for collection, expressed as a fraction"
144-
placement="left"
145-
>
146-
<TextField
147-
size="small"
148-
label="Transmission (fraction)"
149-
defaultValue={trans}
150-
onChange={(e) => setTrans(Number(e.target.value))}
151-
style={{ width: 180 }}
152-
/>
153-
</Tooltip>
154-
<Tooltip
155-
title="Distance to move the detector y stage to, in millimeters"
156-
placement="left"
157-
>
158-
<TextField
159-
size="small"
160-
label="Detector Distance (mm)"
161-
defaultValue={detDist}
162-
onChange={(e) => setDetDist(Number(e.target.value))}
163-
style={{ width: 180 }}
164-
/>
165-
</Tooltip>
94+
<ParameterInput
95+
value={subDir}
96+
onSet={setSubDir}
97+
label="Sub-directory"
98+
tooltip="Location inside visit directory to save data"
99+
/>
100+
<ParameterInput
101+
value={chipName}
102+
onSet={setChipName}
103+
label="Chip Name"
104+
tooltip="Chip identifier, this will be used as filename"
105+
/>
106+
<ParameterInput
107+
value={shots}
108+
onSet={setShots}
109+
label="Shots Per Aperture"
110+
tooltip="How many consecutive times each window should be collected"
111+
/>
112+
<ParameterInput
113+
value={expTime}
114+
onSet={setExpTime}
115+
label="Exposure Time (s)"
116+
tooltip="Exposure time for each window, in seconds"
117+
/>
118+
<ParameterInput
119+
value={trans}
120+
onSet={setTrans}
121+
label="Transmission (fraction)"
122+
tooltip="Request transmission for collection, expressed as a fraction"
123+
/>
124+
<ParameterInput
125+
value={detDist}
126+
onSet={setDetDist}
127+
label="Detector Distance (mm)"
128+
tooltip="Distance to move the detector y stage to, in millimeters"
129+
/>
166130
</Stack>
167131
</Grid2>
168132
<Grid2 size={3}>

0 commit comments

Comments
 (0)