Skip to content

Commit 77167b3

Browse files
author
crorisvanjski4
committed
hotfix fullscreen compatibility
1 parent 1fb243e commit 77167b3

File tree

4 files changed

+72
-27
lines changed

4 files changed

+72
-27
lines changed

src/assets/scss/Dashboard.module.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
}
88

99
div[data-fullscreen] .dashboard {
10-
padding: 1.5rem;
11-
gap: 1.5rem;
10+
padding: 1rem;
11+
gap: 1rem;
1212
justify-content: space-between;
1313
}

src/assets/scss/SortBoxContainer.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@
66
height: 66vh;
77
justify-content: center;
88
}
9+
10+
div[data-fullscreen] .bar-container {
11+
flex: 1;
12+
}
Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,58 @@
1-
import ToggleButton from "@mui/material/ToggleButton";
2-
import ToggleButtonGroup from "@mui/material/ToggleButtonGroup";
3-
import SortIcon from "@mui/icons-material/Sort";
41
import Algorithm, {
52
ALGORITHM_KEYS,
63
IAlgorithmKey,
74
SortingState,
85
} from "../algorithms/Algorithm";
9-
import Stack from "@mui/material/Stack";
10-
import { Typography } from "@mui/material";
6+
import {
7+
FormControl,
8+
InputLabel,
9+
MenuItem,
10+
OutlinedInput,
11+
Select,
12+
SelectChangeEvent,
13+
} from "@mui/material";
1114
import { AlgorithmContext } from "./Dashboard";
12-
import { useContext } from "react";
15+
import { useContext, useState } from "react";
16+
import { Theme, useTheme } from "@mui/material/styles";
1317

1418
export type AlgorithmSelectionProps = {};
1519

20+
const ITEM_HEIGHT = 48;
21+
const ITEM_PADDING_TOP = 8;
22+
const MenuProps = {
23+
PaperProps: {
24+
style: {
25+
maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
26+
width: 450,
27+
},
28+
},
29+
};
30+
31+
function getStyles(algorithmKey: string, textValue: string[], theme: Theme) {
32+
return {
33+
fontWeight:
34+
textValue.indexOf(algorithmKey) === -1
35+
? theme.typography.fontWeightRegular
36+
: theme.typography.fontWeightMedium,
37+
};
38+
}
39+
1640
export default function AlgorithmSelection(props: AlgorithmSelectionProps) {
1741
const state = useContext(AlgorithmContext);
42+
const theme = useTheme();
43+
const [textValue, setTextValue] = useState<string[]>(state.algorithms);
44+
45+
const handleChange = (event: SelectChangeEvent<typeof ALGORITHM_KEYS>) => {
46+
const {
47+
target: { value },
48+
} = event;
49+
50+
const algorithms = (
51+
Array.isArray(value) ? value : !value ? [] : [value]
52+
) as IAlgorithmKey[];
1853

19-
const handleAlgorithmSelection = (
20-
event: React.MouseEvent<HTMLElement>,
21-
algorithms: IAlgorithmKey[]
22-
) => {
2354
if (algorithms.length > 0) {
55+
setTextValue(typeof value === "string" ? value.split(",") : value);
2456
const sortingStateEval: SortingState = algorithms.reduce(
2557
(prev, algorithmKey) => ({ ...prev, [algorithmKey]: false }),
2658
{}
@@ -32,19 +64,28 @@ export default function AlgorithmSelection(props: AlgorithmSelectionProps) {
3264
};
3365

3466
return (
35-
<Stack spacing={1} direction="row" alignItems="center">
36-
<SortIcon fontSize="large" />
37-
<Typography gutterBottom>Algorithms</Typography>
38-
<ToggleButtonGroup
39-
value={state.algorithms}
40-
onChange={handleAlgorithmSelection}
41-
>
42-
{ALGORITHM_KEYS.map((key) => (
43-
<ToggleButton key={key} value={key}>
44-
{Algorithm[key].name}
45-
</ToggleButton>
46-
))}
47-
</ToggleButtonGroup>
48-
</Stack>
67+
<div>
68+
<FormControl sx={{ width: "80vw" }}>
69+
<InputLabel id="algorithm-selection">Algorithms</InputLabel>
70+
<Select
71+
labelId="algorithm-selection"
72+
multiple
73+
value={textValue as IAlgorithmKey[]}
74+
onChange={handleChange}
75+
input={<OutlinedInput label="Algorithms" />}
76+
MenuProps={MenuProps}
77+
>
78+
{ALGORITHM_KEYS.map((algorithmKey) => (
79+
<MenuItem
80+
key={algorithmKey}
81+
value={algorithmKey}
82+
style={getStyles(algorithmKey, textValue, theme)}
83+
>
84+
{Algorithm[algorithmKey].name}
85+
</MenuItem>
86+
))}
87+
</Select>
88+
</FormControl>
89+
</div>
4990
);
5091
}

src/components/ConfigContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type ConfigContainerProps = {
99
};
1010

1111
export default function ConfigContainer(props: ConfigContainerProps) {
12-
const spacing = props.spacing ?? 2;
12+
const spacing = props.spacing ?? 1;
1313

1414
return (
1515
<Card>

0 commit comments

Comments
 (0)