2017-02-28 21:32:23 +00:00
|
|
|
import React, {PureComponent, PropTypes} from 'react';
|
2017-01-20 21:54:03 +00:00
|
|
|
import {shell} from 'electron';
|
|
|
|
|
2017-02-28 21:32:23 +00:00
|
|
|
class Button extends PureComponent {
|
2017-01-20 21:54:03 +00:00
|
|
|
_handleClick = e => {
|
2017-01-23 22:41:31 +00:00
|
|
|
const {onClick, onDisabledClick, disabled} = this.props;
|
|
|
|
const fn = disabled ? onDisabledClick : onClick;
|
2017-01-20 21:54:03 +00:00
|
|
|
|
|
|
|
if (this.props.hasOwnProperty('value')) {
|
2017-01-23 22:41:31 +00:00
|
|
|
fn && fn(this.props.value, e);
|
2017-01-20 21:54:03 +00:00
|
|
|
} else {
|
2017-01-23 22:41:31 +00:00
|
|
|
fn && fn(e);
|
2017-01-20 21:54:03 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const {children, value, ...props} = this.props;
|
|
|
|
return (
|
|
|
|
<button {...props} onClick={this._handleClick}>{children}</button>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button.propTypes = {
|
|
|
|
value: PropTypes.any,
|
2017-01-23 22:41:31 +00:00
|
|
|
onDisabledClick: PropTypes.func,
|
|
|
|
onClick: PropTypes.func,
|
2017-01-20 21:54:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Button;
|