2022-07-27 14:43:34 +00:00
|
|
|
interface Props {
|
|
|
|
total: number;
|
|
|
|
completed: number;
|
|
|
|
inline?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function CompletionBar(props: Props) {
|
|
|
|
const progress = (props.completed / props.total) * 100;
|
2022-07-27 21:10:23 +00:00
|
|
|
return (
|
|
|
|
<span
|
|
|
|
className={`w-full h-2 bg-red-400 ${
|
|
|
|
props.inline ? 'inline-block' : 'block'
|
|
|
|
} relative overflow-hidden rounded-full`}
|
|
|
|
role='progressbar'
|
|
|
|
aria-valuenow={props.completed}
|
|
|
|
aria-valuemin={0}
|
|
|
|
aria-valuemax={props.total}
|
|
|
|
>
|
|
|
|
<span
|
|
|
|
className='w-full h-2 absolute top-0 left-0 block bg-green-400'
|
|
|
|
style={{
|
|
|
|
transform: `translateX(-${100 - progress}%)`,
|
|
|
|
transformOrigin: 'left center',
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
);
|
2022-07-27 14:43:34 +00:00
|
|
|
}
|