| 1 |
/** |
| 2 |
* WordPress dependencies. |
| 3 |
*/ |
| 4 |
import { WPElement } from '@wordpress/element'; |
| 5 |
|
| 6 |
/** |
| 7 |
* Progress bar component. |
| 8 |
* |
| 9 |
* @param {object} props Component props. |
| 10 |
* @param {number} props.current Current value. |
| 11 |
* @param {number} props.total Current total. |
| 12 |
* @param {boolean} props.isComplete If operation is complete. |
| 13 |
* @returns {WPElement} Component. |
| 14 |
*/ |
| 15 |
export default ({ isComplete, current, total }) => { |
| 16 |
const now = Math.floor((current / total) * 100); |
| 17 |
|
| 18 |
return ( |
| 19 |
<div |
| 20 |
aria-valuemax={100} |
| 21 |
aria-valuemin={0} |
| 22 |
aria-valuenow={now} |
| 23 |
className={`ep-sync-progress-bar ${isComplete ? `ep-sync-progress-bar--complete` : ``}`} |
| 24 |
role="progressbar" |
| 25 |
> |
| 26 |
<div |
| 27 |
className="ep-sync-progress-bar__progress" |
| 28 |
style={{ minWidth: `${now}%` }} |
| 29 |
>{`${now}%`}</div> |
| 30 |
</div> |
| 31 |
); |
| 32 |
}; |
| 33 |
|