|
|
@ -1,5 +1,6 @@
|
|
|
|
import React from 'react';
|
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import classNames from 'classnames';
|
|
|
|
|
|
|
|
|
|
|
|
class Button extends React.PureComponent {
|
|
|
|
class Button extends React.PureComponent {
|
|
|
|
|
|
|
|
|
|
|
@ -10,6 +11,7 @@ class Button extends React.PureComponent {
|
|
|
|
block: PropTypes.bool,
|
|
|
|
block: PropTypes.bool,
|
|
|
|
secondary: PropTypes.bool,
|
|
|
|
secondary: PropTypes.bool,
|
|
|
|
size: PropTypes.number,
|
|
|
|
size: PropTypes.number,
|
|
|
|
|
|
|
|
className: PropTypes.string,
|
|
|
|
style: PropTypes.object,
|
|
|
|
style: PropTypes.object,
|
|
|
|
children: PropTypes.node,
|
|
|
|
children: PropTypes.node,
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -24,6 +26,14 @@ class Button extends React.PureComponent {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setRef = (c) => {
|
|
|
|
|
|
|
|
this.node = c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
focus() {
|
|
|
|
|
|
|
|
this.node.focus();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render () {
|
|
|
|
render () {
|
|
|
|
const style = {
|
|
|
|
const style = {
|
|
|
|
padding: `0 ${this.props.size / 2.25}px`,
|
|
|
|
padding: `0 ${this.props.size / 2.25}px`,
|
|
|
@ -32,11 +42,17 @@ class Button extends React.PureComponent {
|
|
|
|
...this.props.style,
|
|
|
|
...this.props.style,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const className = classNames('button', this.props.className, {
|
|
|
|
|
|
|
|
'button-secondary': this.props.secondary,
|
|
|
|
|
|
|
|
'button--block': this.props.block,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
<button
|
|
|
|
className={`button ${this.props.secondary ? 'button-secondary' : ''} ${this.props.block ? 'button--block' : ''}`}
|
|
|
|
className={className}
|
|
|
|
disabled={this.props.disabled}
|
|
|
|
disabled={this.props.disabled}
|
|
|
|
onClick={this.handleClick}
|
|
|
|
onClick={this.handleClick}
|
|
|
|
|
|
|
|
ref={this.setRef}
|
|
|
|
style={style}
|
|
|
|
style={style}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{this.props.text || this.props.children}
|
|
|
|
{this.props.text || this.props.children}
|
|
|
|