Add a common component for stepped progress bar

[MAILPOET-1439]
This commit is contained in:
Rostislav Wolny
2018-08-08 15:49:41 +02:00
committed by pavel-mailpoet
parent e55df2ca2d
commit 7d47e97b51
2 changed files with 60 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import React from 'react';
const SteppedProgressBar = (props) => {
if (props.step > props.steps_count) {
return null;
}
return (
<div className="mailpoet_stepped_progress_bar">
{
[...Array(props.steps_count).keys()].map(step => (
<div
className={`mailpoet_stepped_progress_bar_step ${(step < props.step ? 'active' : '')}`}
key={`step_${step}`}
style={{ width: `${Math.floor(100 / props.steps_count)}%` }}
/>
))
}
</div>
);
};
SteppedProgressBar.propTypes = {
steps_count: React.PropTypes.number.isRequired,
step: React.PropTypes.number.isRequired,
};
module.exports = SteppedProgressBar;