refactor: adapt progress bar to use storage bar style

main
Josue 4 years ago committed by Tsu-ba-me
parent f15c164835
commit e1e4df084f
  1. 62
      striker-ui/components/ProgressBar.tsx

@ -1,14 +1,16 @@
import { makeStyles, withStyles } from '@material-ui/core/styles'; import { makeStyles, withStyles } from '@material-ui/core/styles';
import { LinearProgress, Typography } from '@material-ui/core'; import { LinearProgress } from '@material-ui/core';
import { import {
PURPLE_OFF, PURPLE_OFF,
BLUE,
PANEL_BACKGROUND, PANEL_BACKGROUND,
TEXT,
} from '../lib/consts/DEFAULT_THEME'; } from '../lib/consts/DEFAULT_THEME';
const completed = 100;
const BorderLinearProgress = withStyles({ const BorderLinearProgress = withStyles({
root: { root: {
height: 25, height: 10,
borderRadius: 3, borderRadius: 3,
}, },
colorPrimary: { colorPrimary: {
@ -16,48 +18,38 @@ const BorderLinearProgress = withStyles({
}, },
bar: { bar: {
borderRadius: 3, borderRadius: 3,
backgroundColor: PURPLE_OFF,
}, },
})(LinearProgress); })(LinearProgress);
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles(() => ({
root: { barOk: {
flexGrow: 1, backgroundColor: BLUE,
},
margin: {
margin: theme.spacing(1),
}, },
leftLabel: { barInProgress: {
position: 'absolute', backgroundColor: PURPLE_OFF,
color: TEXT,
top: 0,
left: '2%',
},
centerLabel: {
position: 'absolute',
color: TEXT,
top: 0,
left: '70%',
},
rightLabel: {
position: 'absolute',
color: TEXT,
top: 0,
left: '90%',
}, },
})); }));
const ProgressBar = ({ allocated }: { allocated: number }): JSX.Element => { const ProgressBar = ({
progressPercentage,
}: {
progressPercentage: number;
}): JSX.Element => {
const classes = useStyles(); const classes = useStyles();
return ( return (
<div style={{ position: 'relative' }}> <>
<BorderLinearProgress variant="determinate" value={allocated} /> <BorderLinearProgress
<Typography className={classes.leftLabel}>53.5%</Typography> classes={{
<Typography className={classes.centerLabel}>570MiB/s</Typography> bar:
<Typography className={classes.rightLabel}>1:15:30</Typography> progressPercentage < completed
? classes.barInProgress
: classes.barOk,
}}
variant="determinate"
value={progressPercentage}
/>
<LinearProgress variant="determinate" value={0} /> <LinearProgress variant="determinate" value={0} />
</div> </>
); );
}; };

Loading…
Cancel
Save