button.js 832 B

123456789101112131415161718192021222324252627282930313233343536
  1. import React from 'react';
  2. import Loader from 'misago/components/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 <button type={this.props.onClick ? 'button' : 'submit'}
  13. className={className}
  14. disabled={disabled}
  15. onClick={this.props.onClick}>
  16. {this.props.children}
  17. {this.props.loading ? <Loader /> : null}
  18. </button>;
  19. /* jshint ignore:end */
  20. }
  21. }
  22. Button.defaultProps = {
  23. className: "btn-default",
  24. type: "submit",
  25. loading: false,
  26. disabled: false,
  27. onClick: null
  28. };