Newer
Older
import React from 'react';
import PropTypes from 'prop-types';
export default class Button extends React.PureComponent {
static propTypes = {
text: PropTypes.node,
onClick: PropTypes.func,
disabled: PropTypes.bool,
block: PropTypes.bool,
secondary: PropTypes.bool,
size: PropTypes.number,
style: PropTypes.object,
};
static defaultProps = {
};
handleClick = (e) => {
setRef = (c) => {
this.node = c;
}
focus() {
this.node.focus();
}
render () {
Eugen Rochko
a validé
padding: `0 ${this.props.size / 2.25}px`,
height: `${this.props.size}px`,
lineHeight: `${this.props.size}px`,
Eugen Rochko
a validé
const className = classNames('button', this.props.className, {
'button-secondary': this.props.secondary,
'button--block': this.props.block,
});
return (
disabled={this.props.disabled}
onClick={this.handleClick}
{this.props.text || this.props.children}
);
}