-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Forecast versus actual comparison icons (#3449)
- Loading branch information
Showing
8 changed files
with
414 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React from 'react' | ||
import { Grid, TextField, Tooltip } from '@mui/material' | ||
import { GridRenderCellParams } from '@mui/x-data-grid' | ||
import RemoveCircleIcon from '@mui/icons-material/RemoveCircle' | ||
import AddBoxIcon from '@mui/icons-material/AddBox' | ||
import { MEDIUM_GREY } from 'app/theme' | ||
|
||
interface ForecastCellProps { | ||
disabled: boolean | ||
label: string | ||
showGreaterThan: boolean | ||
showLessThan: boolean | ||
value: Pick<GridRenderCellParams, 'formattedValue'> | ||
} | ||
|
||
const ForecastCell = ({ disabled, label, showGreaterThan, showLessThan, value }: ForecastCellProps) => { | ||
// We should never display both less than and greater than icons at the same time | ||
if (showGreaterThan && showLessThan) { | ||
throw Error('ForecastCell cannot show both greater than and less than icons at the same time.') | ||
} | ||
return ( | ||
<Grid container sx={{ justifyContent: 'center', alignItems: 'center' }}> | ||
<Grid item xs={2}> | ||
{showLessThan && ( | ||
<Tooltip placement="bottom-end" title="Lower than actual"> | ||
<RemoveCircleIcon | ||
data-testid="forecast-cell-less-than-icon" | ||
sx={{ color: MEDIUM_GREY, fontSize: '1.15rem' }} | ||
/> | ||
</Tooltip> | ||
)} | ||
</Grid> | ||
<Grid item xs={8}> | ||
<TextField | ||
data-testid="forecast-cell-text-field" | ||
disabled={disabled} | ||
size="small" | ||
label={label} | ||
InputLabelProps={{ | ||
shrink: true | ||
}} | ||
sx={{ | ||
'& .MuiOutlinedInput-root': { | ||
'& fieldset': { | ||
borderColor: '#737373', | ||
borderWidth: '2px' | ||
} | ||
}, | ||
'& .Mui-disabled': { | ||
'& fieldset': { | ||
borderWidth: '1px' | ||
} | ||
} | ||
}} | ||
value={value} | ||
></TextField> | ||
</Grid> | ||
<Grid item xs={2} sx={{ marginLeft: 'auto' }}> | ||
{showGreaterThan && ( | ||
<Tooltip placement="bottom-start" title="Higher than actual"> | ||
<AddBoxIcon | ||
data-testid="forecast-cell-greater-than-icon" | ||
sx={{ color: MEDIUM_GREY, fontSize: '1.25rem', marginLeft: '2px' }} | ||
/> | ||
</Tooltip> | ||
)} | ||
</Grid> | ||
</Grid> | ||
) | ||
} | ||
|
||
export default ForecastCell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.