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

50 lines
1.2 KiB
JavaScript
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';
import { omit } from 'functions';
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,
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() {
const { color, block, small, className } = this.props;
2016-05-02 12:45:42 +05:30
const props = omit(this.props, Object.keys(Button.propTypes));
2016-05-02 12:45:42 +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
}, className)}
{...props}
>
{label}
2016-05-02 12:45:42 +05:30
</button>
);
}
}