accounts-frontend/src/components/ui/form/Button.jsx

47 lines
1.1 KiB
React
Raw Normal View History

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-05-02 12:45:42 +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-05-30 10:10:59 +05:30
color: PropTypes.oneOf(colors)
};
static defaultProps = {
color: COLOR_GREEN
2016-05-02 12:45:42 +05:30
};
render() {
2016-05-30 10:10:59 +05:30
const { color, block, small } = this.props;
2016-05-02 12:45:42 +05:30
const props = {
...this.props
};
props.label = this.formatMessage(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-05-02 12:45:42 +05:30
})} {...props}>
{props.label}
</button>
);
}
}