You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.3 KiB
61 lines
1.3 KiB
4 years ago
|
import { makeStyles, withStyles } from '@material-ui/core/styles';
|
||
4 years ago
|
import { LinearProgress } from '@material-ui/core';
|
||
4 years ago
|
import {
|
||
|
PURPLE_OFF,
|
||
|
RED_ON,
|
||
|
BLUE,
|
||
|
PANEL_BACKGROUND,
|
||
4 years ago
|
} from '../../lib/consts/DEFAULT_THEME';
|
||
4 years ago
|
|
||
|
const breakpointWarning = 70;
|
||
|
const breakpointAlert = 90;
|
||
4 years ago
|
|
||
|
const BorderLinearProgress = withStyles({
|
||
|
root: {
|
||
4 years ago
|
height: 15,
|
||
|
borderRadius: 2,
|
||
4 years ago
|
},
|
||
|
colorPrimary: {
|
||
4 years ago
|
backgroundColor: PANEL_BACKGROUND,
|
||
4 years ago
|
},
|
||
|
bar: {
|
||
4 years ago
|
borderRadius: 3,
|
||
4 years ago
|
},
|
||
|
})(LinearProgress);
|
||
|
|
||
4 years ago
|
const useStyles = makeStyles(() => ({
|
||
|
barOk: {
|
||
|
backgroundColor: BLUE,
|
||
|
},
|
||
|
barWarning: {
|
||
|
backgroundColor: PURPLE_OFF,
|
||
|
},
|
||
|
barAlert: {
|
||
|
backgroundColor: RED_ON,
|
||
|
},
|
||
|
}));
|
||
|
|
||
4 years ago
|
const AllocationBar = ({ allocated }: { allocated: number }): JSX.Element => {
|
||
4 years ago
|
const classes = useStyles();
|
||
4 years ago
|
return (
|
||
|
<>
|
||
4 years ago
|
<BorderLinearProgress
|
||
|
classes={{
|
||
|
bar:
|
||
|
/* eslint-disable no-nested-ternary */
|
||
|
allocated > breakpointWarning
|
||
|
? allocated > breakpointAlert
|
||
|
? classes.barAlert
|
||
|
: classes.barWarning
|
||
|
: classes.barOk,
|
||
|
}}
|
||
|
variant="determinate"
|
||
|
value={allocated}
|
||
|
/>
|
||
4 years ago
|
<LinearProgress variant="determinate" value={0} />
|
||
|
</>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default AllocationBar;
|