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

56 lines
1.4 KiB
JavaScript
Raw Normal View History

// @flow
import type { MessageDescriptor } from 'react-intl';
import type { ComponentType } from 'react';
import type { Color } from 'components/ui';
import React from 'react';
2016-05-02 12:45:42 +05:30
import classNames from 'classnames';
import buttons from 'components/ui/buttons.scss';
import { COLOR_GREEN } from 'components/ui';
2016-05-02 12:45:42 +05:30
import FormComponent from './FormComponent';
export default class Button extends FormComponent<{
label: string | MessageDescriptor,
block?: bool,
small?: bool,
loading?: bool,
className?: string,
color: Color,
disabled?: bool,
component: string | ComponentType<any>,
}> {
2016-05-30 10:10:59 +05:30
static defaultProps = {
color: COLOR_GREEN,
component: 'button',
2016-05-02 12:45:42 +05:30
};
render() {
const {
color,
block,
small,
disabled,
className,
loading,
label,
component: ComponentProp,
...restProps
} = this.props;
2016-05-02 12:45:42 +05:30
return (
<ComponentProp
className={classNames(buttons[color], {
[buttons.loading]: loading,
[buttons.block]: block,
[buttons.smallButton]: small,
[buttons.disabled]: disabled,
}, className)}
disabled={disabled}
{...restProps}
>
{this.formatMessage(label)}
</ComponentProp>
2016-05-02 12:45:42 +05:30
);
}
}