button.js 818 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React from 'react';
  2. import Loader from './loader'; // jshint ignore:line
  3. export default class Button extends React.Component {
  4. render() {
  5. let className = 'btn ' + this.props.className;
  6. let disabled = this.props.disabled;
  7. if (this.props.loading) {
  8. className += ' btn-loading';
  9. disabled = true;
  10. }
  11. /* jshint ignore:start */
  12. return (
  13. <button
  14. className={className}
  15. disabled={disabled}
  16. onClick={this.props.onClick}
  17. type={this.props.onClick ? 'button' : 'submit'}
  18. >
  19. {this.props.children}
  20. {this.props.loading ? <Loader /> : null}
  21. </button>
  22. );
  23. /* jshint ignore:end */
  24. }
  25. }
  26. Button.defaultProps = {
  27. className: "btn-default",
  28. type: "submit",
  29. loading: false,
  30. disabled: false,
  31. onClick: null
  32. };