one-click-accessibility/modules/settings/assets/js/components/quota-bar/index.js
VasylD f0dce2793e
[APP-1923][APP-1924] manage remediations, global remediations (#424)
* [APP-1923] change remediation management (#411)

* [APP-1988] Add tabs

* [APP-1988][APP-1989] add tabs, remove menu item

* [APP-1988][APP-1989] add tabs, remove menu item

* [APP-1992] add empty state and tab navigation

* [APP-1993][APP-1994] Change view for manage AI fixes, change delete confirmation modal

* [APP-1996] add view for alt text fixes

* [APP-1996] add edit for alt text fixes

* [APP-1996] add edit for alt text fixes

* [APP-1996] add edit for alt text fixes

* [APP-1996] add edit for alt text fixes

* [APP-1996] add edit for alt text fixes

* [APP-1995] Color contrast form

* [APP-2001] add global remediation logic (#415)

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2003] add disable across scans (#418)

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* add logs

* add logs

* add logs

* remove logs

* remove logs

* remove logs

* remove logs

* remove logs

* remove logs

* remove logs

* remove logs

* remove logs

* remove logs

* change to theme value

* change to theme value

* change to theme value

* change to theme value

* add edit mode

* add edit mode

* add edit mode
2025-11-10 16:25:45 +07:00

107 lines
2.8 KiB
JavaScript

import InfoCircleIcon from '@elementor/icons/InfoCircleIcon';
import LockFilledIcon from '@elementor/icons/LockFilledIcon';
import Box from '@elementor/ui/Box';
import Infotip from '@elementor/ui/Infotip';
import LinearProgress from '@elementor/ui/LinearProgress';
import Typography from '@elementor/ui/Typography';
import { styled } from '@elementor/ui/styles';
import { QuotaBarData } from '@ea11y/components/quota-bar/data';
import { formatPlanValue } from '../../utils/index';
const QuotaBar = ({ type, quotaData }) => {
const planUsage =
quotaData?.allowed === 0
? 0
: Math.round((quotaData?.used / quotaData?.allowed) * 100);
const isLocked = quotaData?.allowed === 0;
/**
* Get the color for the progress bar based on the usage.
* @return {string} The color for the progress bar.
*/
const progressBarColor = () => {
if (planUsage < 80) {
return 'info';
}
if (planUsage >= 80 && planUsage < 95) {
return 'warning';
}
return 'error';
};
return (
<StyledOuterWrapper>
<Box display="flex" justifyContent="space-between">
<Typography
variant="body2"
color={!isLocked ? 'text.secondary' : 'text.disabled'}
display="flex"
alignItems="center"
sx={{ fontSize: '12px' }}
>
{QuotaBarData[type]?.title}
<Infotip
placement="right"
PopperProps={{
sx: { width: '300px', marginLeft: 1 },
disablePortal: true,
}}
content={
<Typography color="text.secondary" variant="body2" padding={2}>
{!isLocked
? QuotaBarData[type]?.infotipDescription
: QuotaBarData[type]?.lockedDescription}
</Typography>
}
>
{!isLocked ? (
<InfoCircleIcon
sx={{
fontSize: 'medium',
}}
/>
) : (
<LockFilledIcon
sx={{ fontSize: 'medium', color: 'text.primary', opacity: 0.5 }}
/>
)}
</Infotip>
</Typography>
<Box display="flex" flexDirection="row" gap={0.5} alignItems="center">
<Typography
variant="body2"
color={!isLocked ? 'text.primary' : 'text.disabled'}
sx={{ fontSize: '12px' }}
>
{!isLocked
? `${formatPlanValue(quotaData?.used)} / ${formatPlanValue(quotaData?.allowed)}`
: '0/0'}
</Typography>
</Box>
</Box>
<LinearProgress
sx={{
'& .MuiLinearProgress-bar': {
animation: 'none',
backgroundColor: isLocked && 'text.disabled',
},
animation: 'none',
}}
value={planUsage}
variant="buffer"
valueBuffer={100}
color={progressBarColor()}
/>
</StyledOuterWrapper>
);
};
export default QuotaBar;
const StyledOuterWrapper = styled(Box)`
display: inline-flex;
flex-direction: column;
gap: ${({ theme }) => theme.spacing(1)};
width: 100%;
margin-bottom: ${({ theme }) => theme.spacing(1)};
`;