Skip to content

Commit

Permalink
fix issue with complex union types
Browse files Browse the repository at this point in the history
  • Loading branch information
tizayi committed May 20, 2024
1 parent 50d7866 commit c96dbf8
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 48 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"type": "module",
"scripts": {
"dev": "vite --port 3000",
"check-types": "tsc",
"build": "vite build",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview --port 3000",
"test": "npx vitest",
Expand Down
10 changes: 4 additions & 6 deletions src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { Box, Stack } from "@mui/material";
import { Stack } from "@mui/material";
import DataSideBar from "./data-entry/dataSideBar";
import CentrePlot from "./plot/centrePlot";
import BasicAppBar from "./basicAppBar";

export default function App(): JSX.Element {
return (
<Box>
<>
<BasicAppBar />
<Stack direction={"row"} spacing={1} margin={1}>
<Box>
<DataSideBar />
</Box>
<Stack direction={"column"} spacing={1} flexGrow={1}>
<CentrePlot />
</Stack>
</Stack>
</Box>
</Stack>
</>
);
}
3 changes: 0 additions & 3 deletions src/basicAppBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import AppBar from "@mui/material/AppBar";
import Box from "@mui/material/Box";
import Toolbar from "@mui/material/Toolbar";
import Typography from "@mui/material/Typography";
import { useDetectorStore } from "./data-entry/detectorStore";
Expand Down Expand Up @@ -39,7 +38,6 @@ export default function BasicAppBar(): JSX.Element {
};

return (
<Box>
<AppBar position="static">
<Toolbar>
<Typography variant="h6" component="div" sx={{ flexGrow: 1 }}>
Expand All @@ -59,6 +57,5 @@ export default function BasicAppBar(): JSX.Element {
/>
</Toolbar>
</AppBar>
</Box>
);
}
2 changes: 1 addition & 1 deletion src/data-entry/beamstop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function BeamStopDataEntry(): JSX.Element {
</Stack>
{/* Position */}
<Typography>Position:</Typography>
<Stack direction={"row"} spacing={2}>
<Stack direction={"row"} spacing={1}>
<TextField
type="number"
size="small"
Expand Down
6 changes: 3 additions & 3 deletions src/data-entry/dataSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ export default function DataSideBar(): JSX.Element {
};

return (
<Card>
<Card sx={{ maxHeight: "92vh", overflow: "scroll"}}>
<CardContent>
<Stack spacing={1}>
<Typography variant="h6">Beamline</Typography>
<Stack direction={"row"} spacing={2}>
<Stack direction={"row"} spacing={1}>
<Autocomplete
size="small"
options={Object.keys(beamlineConfigStore.beamlineRecord)}
Expand All @@ -102,7 +102,7 @@ export default function DataSideBar(): JSX.Element {
</Stack>
<Divider />
<Typography variant="h6">Detector</Typography>
<Stack direction={"row"} spacing={2}>
<Stack direction={"row"} spacing={1}>
<Autocomplete
size="small"
options={Object.keys(detectorStore.detectorRecord)}
Expand Down
6 changes: 1 addition & 5 deletions src/plot/centrePlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
SvgRect,
VisCanvas,
} from "@h5web/lib";
import { Box, Card, CardContent, Stack } from "@mui/material";
import {Card, CardContent, Stack } from "@mui/material";
import { Unit, MathType, divide, multiply, unit, createUnit } from "mathjs";
import { Vector2, Vector3 } from "three";
import { computeQrange } from "../calculations/qrange";
Expand Down Expand Up @@ -167,7 +167,6 @@ export default function CentrePlot(): JSX.Element {
const domains = getDomains(plotDetector);

return (
<Box>
<Stack direction="column" spacing={1}>
<Stack direction="row" spacing={1}>
<Card>
Expand Down Expand Up @@ -304,16 +303,13 @@ export default function CentrePlot(): JSX.Element {
</div>
</CardContent>
</Card>
<Box flexGrow={1}>
<LegendBar />
</Box>
</Stack>
<ResultsBar
visableQRange={visibleQRangeUnits}
fullQrange={fullQRangeUnits}
/>
</Stack>
</Box>
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/plot/legendBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function LegendBar(): JSX.Element {
const plotConfig = usePlotStore();

return (
<Card sx={{ height: 1, width: 1 }}>
<Card sx={{flexGrow: 1}}>
<CardContent>
<Stack spacing={1}>
<Typography variant="h6"> Legend</Typography>
Expand Down
39 changes: 17 additions & 22 deletions src/results/rangeTable.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {
Box,
FormControl,
InputLabel,
MenuItem,
Paper,
Select,
SelectChangeEvent,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
Expand Down Expand Up @@ -49,35 +47,34 @@ export default function RangeTable(props: { qRange: UnitRange }): JSX.Element {
.to(resultsStore.dUnits as string);

return (
<Box flexGrow={1}>
<TableContainer component={Paper}>
<TableContainer component={Paper} sx={{ maxWidth: "30vw"}}>
<Table sx={{ minWidth: 50 }} aria-label="simple table" size="small">
{/* TABLE HEAD */}
<TableHead>
<TableRow>
<TableCell>Values</TableCell>
<TableCell align="right">Min</TableCell>
<TableCell align="right">Max</TableCell>
<TableCell align="right">Units</TableCell>
<TableCell align="center">Values</TableCell>
<TableCell align="center">Min</TableCell>
<TableCell align="center">Max</TableCell>
<TableCell align="center">Units</TableCell>
</TableRow>
</TableHead>
{/* TABLE BODY */}
<TableRow key={"q"}>
{/* Q RANGE ROW */}
<TableCell component="th" scope="row">
<TableCell component="th" scope="row" align="center">
{ScatteringOptions.q}
</TableCell>
<TableCell align="right">
<TableCell align="center">
{isNaN(qRange.min.toNumber())
? ""
: qRange.min.toNumber().toFixed(4)}
</TableCell>
<TableCell align="right">
<TableCell align="center">
{isNaN(qRange.max.toNumber())
? ""
: qRange.max.toNumber().toFixed(4)}
</TableCell>
<TableCell align="right">
<TableCell align="center">
<FormControl>
<InputLabel>q</InputLabel>
<Select
Expand All @@ -98,20 +95,20 @@ export default function RangeTable(props: { qRange: UnitRange }): JSX.Element {
</TableRow>
<TableRow key={"s"}>
{/* S RANGE ROW*/}
<TableCell component="th" scope="row">
<TableCell component="th" scope="row" align="center">
{ScatteringOptions.s}
</TableCell>
<TableCell align="right">
<TableCell align="center">
{isNaN(sRange.min.toNumber())
? ""
: sRange.min.toNumber().toFixed(4)}
</TableCell>
<TableCell align="right">
<TableCell align="center">
{isNaN(sRange.max.toNumber())
? ""
: sRange.max.toNumber().toFixed(4)}
</TableCell>
<TableCell align="right">
<TableCell align="center">
<FormControl>
<InputLabel>s</InputLabel>
<Select
Expand All @@ -132,20 +129,20 @@ export default function RangeTable(props: { qRange: UnitRange }): JSX.Element {
</TableRow>
<TableRow key={"d"}>
{/* D RANGE ROW*/}
<TableCell component="th" scope="row">
<TableCell component="th" scope="row" align="center">
{ScatteringOptions.d}
</TableCell>
<TableCell align="right">
<TableCell align="center">
{isNaN(dRange.min.toNumber())
? ""
: dRange.min.toNumber().toFixed(4)}
</TableCell>
<TableCell align="right">
<TableCell align="center">
{isNaN(dRange.max.toNumber())
? ""
: dRange.max.toNumber().toFixed(4)}
</TableCell>
<TableCell align="right">
<TableCell align="center">
<FormControl>
<InputLabel>d</InputLabel>
<Select
Expand All @@ -164,9 +161,7 @@ export default function RangeTable(props: { qRange: UnitRange }): JSX.Element {
</FormControl>
</TableCell>
</TableRow>
<TableBody></TableBody>
</Table>
</TableContainer>
</Box>
);
}
11 changes: 6 additions & 5 deletions src/results/resultsBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Box,
Card,
CardContent,
Divider,
Expand Down Expand Up @@ -161,8 +160,10 @@ export default function ResultsBar({

const units = displayUnits(textBoxUnits);
return (
<Box sx={{ flexGrow: 1 }}>
<Card sx={{ height: 1 }}>
<Card sx={{
height: 1 ,
maxHeight: "27vh",
overflow: "scroll", flexGrow: 1,}}>
<CardContent>
<Stack spacing={1}>
<Typography variant="h6"> Results</Typography>
Expand Down Expand Up @@ -210,7 +211,7 @@ export default function ResultsBar({
</Stack>
<RangeFormControl resultStore={resultStore} />
</Stack>
</Stack>

{diagramVisible && diagramFull && diagramRequested ? (
<RangeDiagram
visibleRange={diagramVisible satisfies UnitRange}
Expand All @@ -219,11 +220,11 @@ export default function ResultsBar({
) : (
<MessageDiagram message="No solution" />
)}
</Stack>
</Stack>
</Stack>
</Stack>
</CardContent>
</Card>
</Box>
);
}

0 comments on commit c96dbf8

Please sign in to comment.