The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

60 lines
1.4 KiB

  1. import PureRenderMixin from 'react-addons-pure-render-mixin';
  2. const Button = React.createClass({
  3. propTypes: {
  4. text: React.PropTypes.string,
  5. onClick: React.PropTypes.func,
  6. disabled: React.PropTypes.bool,
  7. block: React.PropTypes.bool,
  8. secondary: React.PropTypes.bool,
  9. size: React.PropTypes.number,
  10. },
  11. getDefaultProps () {
  12. return {
  13. size: 36
  14. };
  15. },
  16. mixins: [PureRenderMixin],
  17. handleClick (e) {
  18. if (!this.props.disabled) {
  19. this.props.onClick();
  20. }
  21. },
  22. render () {
  23. const style = {
  24. fontFamily: 'inherit',
  25. display: this.props.block ? 'block' : 'inline-block',
  26. width: this.props.block ? '100%' : 'auto',
  27. position: 'relative',
  28. boxSizing: 'border-box',
  29. textAlign: 'center',
  30. border: '10px none',
  31. color: '#fff',
  32. fontSize: '14px',
  33. fontWeight: '500',
  34. letterSpacing: '0',
  35. textTransform: 'uppercase',
  36. padding: `0 ${this.props.size / 2.25}px`,
  37. height: `${this.props.size}px`,
  38. cursor: 'pointer',
  39. lineHeight: `${this.props.size}px`,
  40. borderRadius: '4px',
  41. textDecoration: 'none'
  42. };
  43. return (
  44. <button className={`button ${this.props.secondary ? 'button-secondary' : ''}`} disabled={this.props.disabled} onClick={this.handleClick} style={{ ...style, ...this.props.style }}>
  45. {this.props.text || this.props.children}
  46. </button>
  47. );
  48. }
  49. });
  50. export default Button;