MatxProgressBar.jsx 1.23 KB
Newer Older
Giang Tran committed
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 46 47
import React from 'react'
import { Grid, LinearProgress, Typography } from '@material-ui/core'
import { withStyles } from '@material-ui/styles'

const CustomLinearProgress = withStyles((theme) => ({
    root: {
        borderRadius: 2,
        background: 'rgba(0, 0, 0, 0.1)',
    },
}))(LinearProgress)

const MatxProgressBar = ({
    value = 75,
    color = 'primary',
    text = '',
    spacing = 2,
    coloredText = false,
    className,
}) => {
    return (
        <Grid
            container
            spacing={spacing}
            alignItems="center"
            className={className}
        >
            <Grid item xs={text ? 8 : 12}>
                <CustomLinearProgress
                    color={color}
                    value={value}
                    variant="determinate"
                ></CustomLinearProgress>
            </Grid>
            {text !== '' && (
                <Grid item xs={text ? 4 : false}>
                    <Typography color={color}>
                        <small className={`${coloredText ? '' : 'text-muted'}`}>
                            {text}
                        </small>
                    </Typography>
                </Grid>
            )}
        </Grid>
    )
}

export default MatxProgressBar