import {styled} from '@mui/material/styles';
import LinearProgress from '@mui/material/LinearProgress';
import {IProgressBarProgress} from '../progress-bar.type';
import {themeDetector} from '../../../../../helpers/theme-detector/theme-detector';
import {ProgressBarSizeStyle as sizes} from './progress-bar-size.style';
import {TypographyComponent} from '../../../atoms';

const Container = styled('div')`
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    direction: ltr;
`;

const Label = styled(TypographyComponent)`
    color: ${({theme, color}) =>
        !!color ? theme.palette[color][500] : theme.palette.typography[700]};
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    padding-inline-start: 0.5rem;
`;

const Progress = styled(LinearProgress)<IProgressBarProgress>`
    flex: 1;
    border-radius: 100rem;
    background-color: ${({theme}) => theme.palette.gray[200]};
    height: 8px;
    ${({size}) => sizes[size || 'sm']};
    ${({isRtl}) => (isRtl ? 'transform: rotateY(180deg);' : '')}
    & .MuiLinearProgress-bar {
        background-color: ${({theme, scheme}) =>
            theme.palette[themeDetector(false, scheme)][600]};
        border-radius: inherit;
    }
`;

export const ProgressBarStyle = {
    Progress,
    Container,
    Label,
};
