mirror of
https://gh.wpcy.net/https://github.com/elementor/one-click-accessibility.git
synced 2026-04-24 04:01:35 +08:00
* update: app menu and layout * merge: latest changes from feature/remediation * add: alert indicator to the closed sidebar * fix: page layout for statement page * update: menu display names * fix: topbar menu layout * update: sidebar menu width * update: sidebar menu width * fix: popup menu layout * add: hover action to the toggle button * update: my account menu * fix: quota indicator for closed sidebar * fix: icon alignments * fix: scroll behaviour * fix: page scroll behaviour * fix: popup menu hover state * update: quota bar and group layouts * add: tooltips to the menu items * update: make scans page fixed height and scrollable * update: styles with theme references and added new styled components * fix: make sidebar smoother * update: accessibility page heading
106 lines
2.7 KiB
JavaScript
106 lines
2.7 KiB
JavaScript
import { InfoCircleIcon, LockFilledIcon } from '@elementor/icons';
|
|
import { styled } from '@elementor/ui';
|
|
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 { 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)};
|
|
`;
|