2016-05-02 14:50:50 +05:30
|
|
|
import React, { PropTypes } from 'react';
|
2016-05-02 12:45:42 +05:30
|
|
|
|
|
|
|
import classNames from 'classnames';
|
|
|
|
|
|
|
|
import buttons from 'components/ui/buttons.scss';
|
2016-05-30 10:10:59 +05:30
|
|
|
import { colors, COLOR_GREEN } from 'components/ui';
|
2016-07-29 22:44:52 +05:30
|
|
|
import { omit } from 'functions';
|
2016-05-02 12:45:42 +05:30
|
|
|
|
2016-05-02 14:50:50 +05:30
|
|
|
import FormComponent from './FormComponent';
|
|
|
|
|
|
|
|
export default class Button extends FormComponent {
|
2016-05-02 12:45:42 +05:30
|
|
|
static displayName = 'Button';
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
label: PropTypes.oneOfType([
|
|
|
|
PropTypes.shape({
|
|
|
|
id: PropTypes.string
|
|
|
|
}),
|
|
|
|
PropTypes.string
|
|
|
|
]).isRequired,
|
|
|
|
block: PropTypes.bool,
|
2016-11-06 19:49:52 +05:30
|
|
|
small: PropTypes.bool,
|
|
|
|
color: PropTypes.oneOf(colors),
|
|
|
|
className: PropTypes.string
|
2016-05-30 10:10:59 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
color: COLOR_GREEN
|
2016-05-02 12:45:42 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2016-11-06 19:49:52 +05:30
|
|
|
const { color, block, small, className } = this.props;
|
2016-05-02 12:45:42 +05:30
|
|
|
|
2016-07-29 22:44:52 +05:30
|
|
|
const props = omit(this.props, Object.keys(Button.propTypes));
|
2016-05-02 12:45:42 +05:30
|
|
|
|
2016-07-29 22:44:52 +05:30
|
|
|
const label = this.formatMessage(this.props.label);
|
2016-05-02 12:45:42 +05:30
|
|
|
|
|
|
|
return (
|
|
|
|
<button className={classNames(buttons[color], {
|
2016-05-14 16:56:17 +05:30
|
|
|
[buttons.block]: block,
|
|
|
|
[buttons.smallButton]: small
|
2016-11-06 19:49:52 +05:30
|
|
|
}, className)}
|
2016-07-29 22:44:52 +05:30
|
|
|
{...props}
|
|
|
|
>
|
|
|
|
{label}
|
2016-05-02 12:45:42 +05:30
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|