2016-09-01 00:15:12 +10:00
|
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
|
|
|
|
2016-08-26 03:52:55 +10:00
|
|
|
const Button = React.createClass({
|
2016-09-01 00:15:12 +10:00
|
|
|
|
2016-08-26 03:52:55 +10:00
|
|
|
propTypes: {
|
2016-09-08 02:17:15 +10:00
|
|
|
text: React.PropTypes.string,
|
2016-09-01 00:15:12 +10:00
|
|
|
onClick: React.PropTypes.func,
|
2016-09-08 02:17:15 +10:00
|
|
|
disabled: React.PropTypes.bool,
|
|
|
|
block: React.PropTypes.bool,
|
|
|
|
secondary: React.PropTypes.bool
|
2016-08-26 03:52:55 +10:00
|
|
|
},
|
|
|
|
|
2016-09-01 00:15:12 +10:00
|
|
|
mixins: [PureRenderMixin],
|
|
|
|
|
2016-08-26 03:52:55 +10:00
|
|
|
handleClick (e) {
|
2016-09-01 00:15:12 +10:00
|
|
|
if (!this.props.disabled) {
|
|
|
|
this.props.onClick();
|
|
|
|
}
|
2016-08-26 03:52:55 +10:00
|
|
|
},
|
|
|
|
|
|
|
|
render () {
|
2016-09-28 07:12:33 +10:00
|
|
|
const style = {
|
|
|
|
fontFamily: 'Roboto',
|
|
|
|
display: this.props.block ? 'block' : 'inline-block',
|
|
|
|
width: this.props.block ? '100%' : 'auto',
|
|
|
|
position: 'relative',
|
|
|
|
boxSizing: 'border-box',
|
|
|
|
textAlign: 'center',
|
|
|
|
border: '10px none',
|
|
|
|
color: '#fff',
|
|
|
|
fontSize: '14px',
|
|
|
|
fontWeight: '500',
|
|
|
|
letterSpacing: '0',
|
|
|
|
textTransform: 'uppercase',
|
|
|
|
padding: '0 16px',
|
|
|
|
height: '36px',
|
|
|
|
cursor: 'pointer',
|
|
|
|
lineHeight: '36px',
|
|
|
|
borderRadius: '4px',
|
|
|
|
textDecoration: 'none'
|
|
|
|
};
|
|
|
|
|
2016-08-26 03:52:55 +10:00
|
|
|
return (
|
2016-09-28 07:12:33 +10:00
|
|
|
<button className={`button ${this.props.secondary ? 'button-secondary' : ''}`} disabled={this.props.disabled} onClick={this.handleClick} style={style}>
|
2016-09-08 02:17:15 +10:00
|
|
|
{this.props.text || this.props.children}
|
2016-09-01 06:58:10 +10:00
|
|
|
</button>
|
2016-08-26 03:52:55 +10:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default Button;
|