insomnia/app/ui/components/base/Button.js

31 lines
690 B
JavaScript
Raw Normal View History

import React, {PureComponent, PropTypes} from 'react';
import {shell} from 'electron';
class Button extends PureComponent {
_handleClick = e => {
2017-01-23 22:41:31 +00:00
const {onClick, onDisabledClick, disabled} = this.props;
const fn = disabled ? onDisabledClick : onClick;
if (this.props.hasOwnProperty('value')) {
2017-01-23 22:41:31 +00:00
fn && fn(this.props.value, e);
} else {
2017-01-23 22:41:31 +00:00
fn && fn(e);
}
};
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,
};
export default Button;