created new progressBar component
This commit is contained in:
parent
3e71511d8e
commit
3c9e68f91b
@ -1,30 +1,37 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const ProgressBar = ( {completeValue, totalValue} ) =>
|
const ProgressBar = ({
|
||||||
{
|
plannedWork = 100,
|
||||||
|
completedWork = 0,
|
||||||
|
height = "8px",
|
||||||
const getProgress = (complete, total) => {
|
className = "mb-4",
|
||||||
return (total * 100) / complete + "%";
|
rounded = true,
|
||||||
|
}) => {
|
||||||
|
const getProgress = (planned, completed) => {
|
||||||
|
if (!planned || planned === 0) return "0%";
|
||||||
|
return `${Math.min((completed / planned) * 100, 100).toFixed(2)}%`;
|
||||||
};
|
};
|
||||||
return (
|
|
||||||
<div className="progress mb-4 rounded" style={{height: "8px"}}>
|
const progressStyle = {
|
||||||
<div className="progress p-0">
|
width: getProgress(plannedWork, completedWork),
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`progress ${className} ${rounded ? "rounded" : ""}`}
|
||||||
|
style={{ height }}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
className="progress-bar"
|
className={`progress-bar ${rounded ? "rounded" : ""}`}
|
||||||
role="progressbar"
|
role="progressbar"
|
||||||
style={{
|
style={progressStyle}
|
||||||
width: `${getProgress( totalValue,completeValue)}`,
|
aria-valuenow={completedWork}
|
||||||
height: "10px",
|
|
||||||
}}
|
|
||||||
aria-valuenow={completeValue}
|
|
||||||
aria-valuemin="0"
|
aria-valuemin="0"
|
||||||
aria-valuemax={totalValue}
|
aria-valuemax={plannedWork}
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProgressBar;
|
export default ProgressBar;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user