2016-08-31 14:15:12 +00:00
|
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
|
|
|
|
2016-08-25 17:52:55 +00:00
|
|
|
const Button = React.createClass({
|
2016-08-31 14:15:12 +00:00
|
|
|
|
2016-08-25 17:52:55 +00:00
|
|
|
propTypes: {
|
2016-09-07 16:17:15 +00:00
|
|
|
text: React.PropTypes.string,
|
2016-08-31 14:15:12 +00:00
|
|
|
onClick: React.PropTypes.func,
|
2016-09-07 16:17:15 +00:00
|
|
|
disabled: React.PropTypes.bool,
|
|
|
|
block: React.PropTypes.bool,
|
2016-11-23 22:34:12 +00:00
|
|
|
secondary: React.PropTypes.bool,
|
|
|
|
size: React.PropTypes.number,
|
|
|
|
},
|
|
|
|
|
|
|
|
getDefaultProps () {
|
|
|
|
return {
|
|
|
|
size: 36
|
|
|
|
};
|
2016-08-25 17:52:55 +00:00
|
|
|
},
|
|
|
|
|
2016-08-31 14:15:12 +00:00
|
|
|
mixins: [PureRenderMixin],
|
|
|
|
|
2016-08-25 17:52:55 +00:00
|
|
|
handleClick (e) {
|
2016-08-31 14:15:12 +00:00
|
|
|
if (!this.props.disabled) {
|
|
|
|
this.props.onClick();
|
|
|
|
}
|
2016-08-25 17:52:55 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
render () {
|
2016-09-27 21:12:33 +00:00
|
|
|
const style = {
|
2017-01-05 04:24:27 +00:00
|
|
|
fontFamily: 'inherit',
|
2016-09-27 21:12:33 +00:00
|
|
|
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',
|
2016-11-23 22:34:12 +00:00
|
|
|
padding: `0 ${this.props.size / 2.25}px`,
|
|
|
|
height: `${this.props.size}px`,
|
2016-09-27 21:12:33 +00:00
|
|
|
cursor: 'pointer',
|
2016-11-23 22:34:12 +00:00
|
|
|
lineHeight: `${this.props.size}px`,
|
2016-09-27 21:12:33 +00:00
|
|
|
borderRadius: '4px',
|
|
|
|
textDecoration: 'none'
|
|
|
|
};
|
2016-11-23 22:34:12 +00:00
|
|
|
|
2016-08-25 17:52:55 +00:00
|
|
|
return (
|
2016-11-23 22:34:12 +00:00
|
|
|
<button className={`button ${this.props.secondary ? 'button-secondary' : ''}`} disabled={this.props.disabled} onClick={this.handleClick} style={{ ...style, ...this.props.style }}>
|
2016-09-07 16:17:15 +00:00
|
|
|
{this.props.text || this.props.children}
|
2016-08-31 20:58:10 +00:00
|
|
|
</button>
|
2016-08-25 17:52:55 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default Button;
|