Skip to content

Commit

Permalink
Refactored common settings and ESC settings to use MUI components. Di…
Browse files Browse the repository at this point in the history
…splay two ESCs next to each other if possible. #164
  • Loading branch information
stylesuxx committed Jan 12, 2022
1 parent c38d0ac commit a870d3b
Show file tree
Hide file tree
Showing 25 changed files with 413 additions and 539 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"react-gtm-module": "^2.0.11",
"react-highlight-within-textarea": "^1.0.1",
"react-i18next": "^11.8.8",
"react-input-range": "^1.3.0",
"react-scripts": "4.0.3",
"react-toastify": "^7.0.3",
"scheduler": "0.14.0",
Expand Down
1 change: 0 additions & 1 deletion src/Components/App/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ body {
background-color: lightgray;
margin: 0px;
padding: 0px;
width: 100%;
overflow-x: hidden;
}

Expand Down
26 changes: 12 additions & 14 deletions src/Components/AppSettings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,14 @@ function AppSettings({
switch(setting.type) {
case 'boolean': {
return (
<>
<Checkbox
hint={t(`${key}Hint`)}
key={key}
label={t(key)}
name={key}
onChange={handleCheckboxChange}
value={setting.value ? 1 : 0}
/>

<Divider />
</>
<Checkbox
hint={t(`${key}Hint`)}
key={key}
label={t(key)}
name={key}
onChange={handleCheckboxChange}
value={setting.value ? 1 : 0}
/>
);
}
}
Expand All @@ -59,10 +55,12 @@ function AppSettings({
open={open}
>
<FormControl
component="fieldset"
fullWidth
variant="standard"
>
<Stack spacing={1}>
<Stack
spacing={2}
>
{settingElements}
</Stack>
</FormControl>
Expand Down
4 changes: 2 additions & 2 deletions src/Components/FirmwareSelector/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function FirmwareSelector({
<div className="center-wrapper">
<Stack spacing={1}>
<Checkbox
hint={force ? t('forceFlashHint') : null}
help={force ? t('forceFlashHint') : null}
key='force'
label={t('forceFlashText')}
name='force'
Expand All @@ -225,7 +225,7 @@ function FirmwareSelector({
/>

<Checkbox
hint={migrate ? t('migrateFlashHint') : null}
help={migrate ? t('migrateFlashHint') : null}
key='migrate'
label={t('migrateFlashText')}
name='migrate'
Expand Down
122 changes: 62 additions & 60 deletions src/Components/Flash/CommonSettings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import React, {
useState,
} from 'react';

import Box from '@mui/material/Box';
import Divider from '@mui/material/Divider';
import Grid from '@mui/material/Grid';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';

import {
getMasterSettings,
Expand Down Expand Up @@ -159,73 +162,53 @@ function CommonSettings({
switch (setting.type) {
case 'bool': {
return (
<>
<Checkbox
disabled={disabled}
hint={hint}
inSync={inSync}
key={setting.name}
label={t(setting.label)}
name={setting.name}
onChange={handleCheckboxChange}
value={value}
<Grid container>
<Grid
item
xs={6}
/>

<Divider />
</>
<Grid
className="inset"
item
xs={6}
>
<Checkbox
disabled={disabled}
hint={hint}
inSync={inSync}
key={setting.name}
label={t(setting.label)}
name={setting.name}
onChange={handleCheckboxChange}
value={value}
/>
</Grid>
</Grid>
);
}

case 'enum': {
const { options } = setting;
return (
<>
<Select
disabled={disabled}
hint={hint}
inSync={inSync}
key={setting.name}
label={t(setting.label)}
name={setting.name}
onChange={handleSelectChange}
options={options}
value={value}
/>

<Divider />
</>
<Select
disabled={disabled}
hint={hint}
inSync={inSync}
key={setting.name}
label={t(setting.label)}
name={setting.name}
onChange={handleSelectChange}
options={options}
value={value}
/>
);
}

case 'number': {
if(directInput) {
return (
<>
<Number
disabled={disabled}
factor={setting.displayFactor}
hint={hint}
inSync={inSync}
key={setting.name}
label={t(setting.label)}
max={setting.max}
min={setting.min}
name={setting.name}
offset={setting.displayOffset}
onChange={handleNumberChange}
round={false}
step={setting.step}
value={value}
/>

<Divider />
</>
);
}

return (
<>
<Slider
<Number
disabled={disabled}
factor={setting.displayFactor}
hint={hint}
Expand All @@ -241,9 +224,26 @@ function CommonSettings({
step={setting.step}
value={value}
/>
);
}

<Divider />
</>
return (
<Slider
disabled={disabled}
factor={setting.displayFactor}
hint={hint}
inSync={inSync}
key={setting.name}
label={t(setting.label)}
max={setting.max}
min={setting.min}
name={setting.name}
offset={setting.displayOffset}
onChange={handleNumberChange}
round={false}
step={setting.step}
value={value}
/>
);
}

Expand All @@ -254,16 +254,18 @@ function CommonSettings({
return (
<div className="gui-box grey">
<div className="gui-box-titlebar">
<div className="spacer-box-title">
<Typography className="spacer-box-title">
{t('commonParameters')}
</div>
</Typography>
</div>

<div className="spacer-box">
<Stack spacing={1}>
<Box sx={{ p: 2 }}>
<Stack
spacing={1}
>
{settingElements}
</Stack>
</div>
</Box>
</div>
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/Components/Flash/CommonSettings/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
color: red;
font-weight: bold;
}

.inset > * {
margin-left: -1.25rem;
}
1 change: 0 additions & 1 deletion src/Components/Flash/Escs/Esc/__tests__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ describe('Esc', () => {
/>
);

expect(screen.getByText(/hints:COMMON_MOTOR_DIRECTION/i)).toBeInTheDocument();
expect(screen.getByText(/escMotorDirection/i)).toBeInTheDocument();

userEvent.click(screen.getByRole(/checkbox/i));
Expand Down
Loading

0 comments on commit a870d3b

Please sign in to comment.