Local modifications to ClusterLabs/Anvil by Alteeve
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.

53 lines
1.1 KiB

import { styled } from '@mui/material';
import { PURPLE, RED, BLUE } from '../../lib/consts/DEFAULT_THEME';
import BorderLinearProgress from './BorderLinearProgress';
import Underline from './Underline';
const PREFIX = 'AllocationBar';
const classes = {
barOk: `${PREFIX}-barOk`,
barWarning: `${PREFIX}-barWarning`,
barAlert: `${PREFIX}-barAlert`,
};
const StyledDiv = styled('div')(() => ({
[`& .${classes.barOk}`]: {
backgroundColor: BLUE,
},
[`& .${classes.barWarning}`]: {
backgroundColor: PURPLE,
},
[`& .${classes.barAlert}`]: {
backgroundColor: RED,
},
}));
const breakpointWarning = 70;
const breakpointAlert = 90;
const AllocationBar = ({ allocated }: { allocated: number }): JSX.Element => (
<StyledDiv>
<BorderLinearProgress
classes={{
bar:
/* eslint-disable no-nested-ternary */
allocated > breakpointWarning
? allocated > breakpointAlert
? classes.barAlert
: classes.barWarning
: classes.barOk,
}}
variant="determinate"
value={allocated}
/>
<Underline />
</StyledDiv>
);
export default AllocationBar;