diff --git a/src/components/input/NumericInputWithUnit.tsx b/src/components/input/NumericInputWithUnit.tsx index 78c2c10..a545685 100644 --- a/src/components/input/NumericInputWithUnit.tsx +++ b/src/components/input/NumericInputWithUnit.tsx @@ -128,6 +128,7 @@ export default function NumericInputWithUnit(props: { disabled={disabled} type="number" fullWidth + sx={{ width: { xs: '75%', sm: '80%', md: '90%' } }} value={(inputValue / siPrefixes[prefix]) .toFixed(9) .replace(/(\d*\.\d+?)0+$/, '$1')} @@ -140,6 +141,7 @@ export default function NumericInputWithUnit(props: { fullWidth disabled={disableChangingUnit} value={prefix} + sx={{ width: { xs: '75%', sm: '80%', md: '90%' } }} onChange={(evt) => { handlePrefixChange(evt.target.value || ''); }} @@ -157,6 +159,7 @@ export default function NumericInputWithUnit(props: { fullWidth disabled={disableChangingUnit} placeholder={'Unit'} + sx={{ width: { xs: '75%', sm: '80%', md: '90%' } }} value={unit} onChange={(event) => { setUserSelectedUnit(true); diff --git a/src/pages/tools/number/generic-calc/index.tsx b/src/pages/tools/number/generic-calc/index.tsx index c438c5e..d07b750 100644 --- a/src/pages/tools/number/generic-calc/index.tsx +++ b/src/pages/tools/number/generic-calc/index.tsx @@ -1,4 +1,13 @@ -import { Autocomplete, Box, Radio, Stack, TextField } from '@mui/material'; +import { + Autocomplete, + Box, + MenuItem, + Radio, + Select, + Stack, + TextField, + useTheme +} from '@mui/material'; import React, { useContext, useState } from 'react'; import ToolContent from '@components/ToolContent'; import { ToolComponentProps } from '@tools/defineTool'; @@ -16,6 +25,7 @@ import Qty from 'js-quantities'; import { CustomSnackBarContext } from 'contexts/CustomSnackBarContext'; import Typography from '@mui/material/Typography'; import Grid from '@mui/material/Grid'; +import useMediaQuery from '@mui/material/useMediaQuery'; function numericSolveEquationFor( equation: string, @@ -51,6 +61,8 @@ export default async function makeTool( return function GenericCalc({ title }: ToolComponentProps) { const { showSnackBar } = useContext(CustomSnackBarContext); + const theme = useTheme(); + const lessThanSmall = useMediaQuery(theme.breakpoints.down('sm')); // For UX purposes we need to track what vars are const [valsBoundToPreset, setValsBoundToPreset] = useState<{ @@ -280,61 +292,91 @@ export default async function makeTool( title: 'Variables', component: ( - - - - - Solve For - + {lessThanSmall ? ( + + Solve for + + + ) : ( + + + + + Solve For + + - - + )} {calcData.variables.map((variable) => ( - + - - - - {variable.title} - - - updateVarField( - variable.name, - val.value, - val.unit, - values, - updateField - ) - } - /> - - + + + {variable.title} + + + updateVarField( + variable.name, + val.value, + val.unit, + values, + updateField + ) + } + /> + {variable.alternates?.map((alt) => ( @@ -391,26 +433,28 @@ export default async function makeTool( - - - handleSelectedTargetChange( - variable.name, - updateField - ) - } - /> - + {!lessThanSmall && ( + + + handleSelectedTargetChange( + variable.name, + updateField + ) + } + /> + + )} ))} @@ -422,23 +466,25 @@ export default async function makeTool( { title: 'Extra outputs', component: ( - - {calcData.extraOutputs?.map((extraOutput) => ( - - - {extraOutput.title} - - - - ))} - + + + {calcData.extraOutputs?.map((extraOutput) => ( + + + {extraOutput.title} + + + + ))} + + ) } ]