Skip to content

Instantly share code, notes, and snippets.

@rahmanusta
Created February 26, 2016 13:39
Show Gist options
  • Save rahmanusta/f6a93a1a369f045b2349 to your computer and use it in GitHub Desktop.
Save rahmanusta/f6a93a1a369f045b2349 to your computer and use it in GitHub Desktop.
React Zurb ProgressBar State Gist
var ProgressBar = React.createClass({
getInitialState: function () {
return {
position: 0
};
},
proceed: function () {
this.setState(function (currentState) {
if (currentState.position >= 100) {
currentState.position = 0;
return;
}
return {
position: currentState.position + this.props.step
};
});
},
render: function () {
var color = this.props.color;
var position = this.state.position;
return (
<div>
<div className={classNames("progress", color)} role="progressbar">
<div className="progress-meter" style={{width: position + '%'}}></div>
</div>
<button onClick={this.proceed} type="button" className="success button">Proceed.. {position} %</button>
</div>
);
}
});
var container = document.querySelectorAll(".placeholder");
ReactDOM.render(<ProgressBar color="alert" step={10}/>, container[0]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment