2023-09-21 10:09:45 +00:00
|
|
|
export interface IProgressBar {
|
|
|
|
total: number;
|
|
|
|
done: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ProgressBar = ({ total = 0, done = 0 }: IProgressBar) => {
|
|
|
|
const calPercentage = (doneValue: number, totalValue: number): string => {
|
|
|
|
if (doneValue === 0 || totalValue === 0) return (0).toFixed(0);
|
|
|
|
return ((100 * doneValue) / totalValue).toFixed(0);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="relative flex items-center gap-2">
|
|
|
|
<div className="w-full">
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="w-full overflow-hidden rounded-full bg-custom-background-80 shadow">
|
2023-09-21 10:09:45 +00:00
|
|
|
<div
|
2023-12-10 10:18:10 +00:00
|
|
|
className="h-[6px] rounded-full bg-green-500 transition-all"
|
2023-09-21 10:09:45 +00:00
|
|
|
style={{ width: `${calPercentage(done, total)}%` }}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="flex-shrink-0 text-xs font-medium">{calPercentage(done, total)}% Done</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|