Skip to content

Commit b6f31dd

Browse files
committed
added AppBar and Drawer in NFA to DFA feature screens
1 parent 227008a commit b6f31dd

File tree

6 files changed

+324
-235
lines changed

6 files changed

+324
-235
lines changed

src/consts/DrawerWidth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const DrawerWidth = 200;
1+
export const DrawerWidth = 230;

src/features/components/nfaToDfa/ModifiedTable.tsx

Lines changed: 93 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import {
88
MenuItem,
99
Select,
1010
SelectChangeEvent,
11-
Typography,
1211
} from "@mui/material";
1312
import { GridColumns } from "@mui/x-data-grid";
14-
import { useEffect, useState } from "react";
13+
import { useContext, useEffect, useState } from "react";
1514
import { AnimationDurationOptions } from "../../../consts/AnimationDurationOptions";
1615
import { PossibleTransitionValues } from "../../../consts/PossibleTransitionValues";
1716
import { RowModel } from "../../../models";
@@ -21,14 +20,23 @@ import { ToolsTransitionTable } from "../tools/TransitionTable";
2120
import PlayArrowRoundedIcon from "@mui/icons-material/PlayArrowRounded";
2221
import PauseRoundedIcon from "@mui/icons-material/PauseRounded";
2322
import ReplayRoundedIcon from "@mui/icons-material/ReplayRounded";
24-
import { stateSelectedColor } from "../../../consts/Colors";
2523
import { ModifiedTableStateId } from "../../../consts/StateIdsExtensions";
24+
import { AppBarAndDrawer } from "../../../common/AppBarAndDrawer";
25+
import { DrawerHeader } from "../../../common/DrawerHeader";
26+
import { MainContent } from "../../../common/MainContent";
27+
import { AppBarAndDrawerProps } from "../../../common/props/AppBarAndDrawerProps";
28+
import { GetDrawerTransitionTableColumns } from "../../../utils/GetDrawerTransitionTableColumns";
29+
import { GetDrawerTransitionTableRows } from "../../../utils/GetDrawerTransitionTableRows";
30+
import { DataContext } from "../../../components/Editor";
2631

2732
const numberOfColumns = 3; // one for state, one for a and one for b
2833
let index = numberOfColumns;
2934

3035
export const ModifiedTable = (props: ModifiedTableProps) => {
3136
console.log("re rendering modified table, props: ", props);
37+
38+
const dataContext = useContext(DataContext);
39+
3240
const [duration, setDuration] = useState(AnimationDurationOptions[0]);
3341
const [isPlaying, setIsPlaying] = useState(false);
3442

@@ -62,6 +70,8 @@ export const ModifiedTable = (props: ModifiedTableProps) => {
6270
},
6371
];
6472

73+
const [open, setOpen] = useState(1);
74+
6575
useEffect(() => {
6676
console.log(
6777
"ModifiedTable useEffect, isPlaying, duration: ",
@@ -217,87 +227,92 @@ export const ModifiedTable = (props: ModifiedTableProps) => {
217227
columns: columns,
218228
};
219229

230+
const appBarAndDrawerProps: AppBarAndDrawerProps = {
231+
title: "Modified Transition Table",
232+
open,
233+
setOpen,
234+
transitionTableProps: {
235+
rows: GetDrawerTransitionTableRows(dataContext, ModifiedTableStateId),
236+
columns: GetDrawerTransitionTableColumns(dataContext, false),
237+
},
238+
};
239+
220240
return (
221241
<>
222-
<Box sx={{ flexGrow: 1, m: 1, mt: 5 }}>
223-
<Typography
224-
variant="h5"
225-
component="div"
226-
gutterBottom
227-
align="center"
228-
fontWeight={"bold"}
229-
bgcolor={stateSelectedColor}
230-
>
231-
Modified Transition Table (replace each state with its null closure)
232-
</Typography>
233-
{/* Grid to incorporate Transition table and Playground */}
234-
<Grid
235-
container
236-
columnSpacing={{
237-
xs: 1,
238-
sm: 2,
239-
md: 3,
240-
}}
241-
>
242-
{/* Transition table grid */}
243-
<Grid item xs={12} md={4}>
244-
{/* Grid for Add a Row button and Tools */}
245-
<Grid container alignItems={"center"}>
246-
<Grid item xs={12}>
247-
<ButtonGroup
248-
disableElevation
249-
fullWidth
250-
variant="outlined"
251-
size="large"
252-
>
253-
<FormControl fullWidth>
254-
<InputLabel id="delay-select-label">Delay</InputLabel>
255-
<Select
256-
labelId="delay-select-label"
257-
id="delay-select"
258-
value={duration.toString()}
259-
label="Delay"
260-
onChange={handleDurationChange}
261-
>
262-
{AnimationDurationOptions.map((option) => (
263-
<MenuItem key={option} value={option}>
264-
{option}
265-
</MenuItem>
266-
))}
267-
</Select>
268-
</FormControl>
269-
{/* <Button onClick={handleAnimationPause}>Pause</Button> */}
270-
<Button
271-
onClick={handleAnimation}
272-
startIcon={
273-
isPlaying ? (
274-
<PauseRoundedIcon />
275-
) : isComplete ? (
276-
<ReplayRoundedIcon />
277-
) : (
278-
<PlayArrowRoundedIcon />
279-
)
280-
}
281-
>
282-
{isPlaying ? "Pause" : isComplete ? "Replay" : "Play"}
283-
</Button>
284-
<Button
285-
variant={isComplete ? "contained" : "outlined"}
286-
onClick={showNextRow}
287-
disabled={isReady}
242+
<Box sx={{ display: "flex", m: 1, mt: 5 }}>
243+
<AppBarAndDrawer {...appBarAndDrawerProps} />
244+
245+
<MainContent open={open} sx={{ paddingBottom: 12 }}>
246+
<DrawerHeader />
247+
{/* Grid to incorporate Transition table and Playground */}
248+
<Grid
249+
container
250+
columnSpacing={{
251+
xs: 1,
252+
sm: 2,
253+
md: 3,
254+
}}
255+
>
256+
{/* Transition table grid */}
257+
<Grid item xs={12} md={4}>
258+
{/* Grid for Add a Row button and Tools */}
259+
<Grid container alignItems={"center"}>
260+
<Grid item xs={12}>
261+
<ButtonGroup
262+
disableElevation
263+
fullWidth
264+
variant="outlined"
265+
size="large"
288266
>
289-
{isComplete ? "Complete" : "Next"}
290-
</Button>
291-
</ButtonGroup>
267+
<FormControl fullWidth>
268+
<InputLabel id="delay-select-label">Delay</InputLabel>
269+
<Select
270+
labelId="delay-select-label"
271+
id="delay-select"
272+
value={duration.toString()}
273+
label="Delay"
274+
onChange={handleDurationChange}
275+
>
276+
{AnimationDurationOptions.map((option) => (
277+
<MenuItem key={option} value={option}>
278+
{option}
279+
</MenuItem>
280+
))}
281+
</Select>
282+
</FormControl>
283+
{/* <Button onClick={handleAnimationPause}>Pause</Button> */}
284+
<Button
285+
onClick={handleAnimation}
286+
startIcon={
287+
isPlaying ? (
288+
<PauseRoundedIcon />
289+
) : isComplete ? (
290+
<ReplayRoundedIcon />
291+
) : (
292+
<PlayArrowRoundedIcon />
293+
)
294+
}
295+
>
296+
{isPlaying ? "Pause" : isComplete ? "Replay" : "Play"}
297+
</Button>
298+
<Button
299+
variant={isComplete ? "contained" : "outlined"}
300+
onClick={showNextRow}
301+
disabled={isReady}
302+
>
303+
{isComplete ? "Complete" : "Next"}
304+
</Button>
305+
</ButtonGroup>
306+
</Grid>
292307
</Grid>
308+
<ToolsTransitionTable {...transitionTableProps} />
309+
</Grid>
310+
{/* Playground grid */}
311+
<Grid item xs={12} md={8}>
312+
{/* <NfaToDfaPlayground {...playgroundProps} /> */}
293313
</Grid>
294-
<ToolsTransitionTable {...transitionTableProps} />
295-
</Grid>
296-
{/* Playground grid */}
297-
<Grid item xs={12} md={8}>
298-
{/* <NfaToDfaPlayground {...playgroundProps} /> */}
299314
</Grid>
300-
</Grid>
315+
</MainContent>
301316
</Box>
302317
{/* {isComplete && <ResultantDfa {...resultantDfaProps} />} */}
303318
</>

0 commit comments

Comments
 (0)