-
Notifications
You must be signed in to change notification settings - Fork 12
/
LinearProgressWithLabel.jsx
45 lines (39 loc) · 1.05 KB
/
LinearProgressWithLabel.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from 'react';
import PropTypes from 'prop-types';
import makeStyles from '@mui/styles/makeStyles';
import {LinearProgress, Typography, Box} from '@mui/material';
const LinearProgressWithLabel = props => {
return (
<Box display="flex" alignItems="center">
<Box width="100%" mr={1}>
<LinearProgress variant="determinate" {...props} />
</Box>
<Box minWidth={35}>
<Typography variant="body2" color="textSecondary">{`${Math.round(
props.value,
)}%`}</Typography>
</Box>
</Box>
);
}
LinearProgressWithLabel.propTypes = {
/**
* The value of the progress indicator for the determinate and buffer variants.
* Value between 0 and 100.
*/
value: PropTypes.number.isRequired,
};
const useStyles = makeStyles({
root: {
width: '100%',
},
});
const LinearWithValueLabel = ({ progress }) => {
const classes = useStyles();
return (
<div className={classes.root}>
<LinearProgressWithLabel value={progress || 0} />
</div>
);
}
export default LinearWithValueLabel;