2017-08-20 21:15:21 +05:30
|
|
|
// @flow
|
2018-04-19 01:19:10 +05:30
|
|
|
import type { MessageDescriptor } from 'react-intl';
|
2018-03-26 00:46:45 +05:30
|
|
|
import type { ComponentType } from 'react';
|
2018-05-03 00:25:34 +05:30
|
|
|
import type { Color } from 'components/ui';
|
2017-08-20 21:15:21 +05:30
|
|
|
import React from 'react';
|
2016-05-02 12:45:42 +05:30
|
|
|
import classNames from 'classnames';
|
|
|
|
import buttons from 'components/ui/buttons.scss';
|
2017-08-20 21:15:21 +05:30
|
|
|
import { COLOR_GREEN } from 'components/ui';
|
2016-05-02 12:45:42 +05:30
|
|
|
|
2016-05-02 14:50:50 +05:30
|
|
|
import FormComponent from './FormComponent';
|
|
|
|
|
2018-03-26 00:46:45 +05:30
|
|
|
export default class Button extends FormComponent<{
|
|
|
|
label: string | MessageDescriptor,
|
|
|
|
block?: bool,
|
|
|
|
small?: bool,
|
|
|
|
loading?: bool,
|
|
|
|
className?: string,
|
2018-05-03 00:25:34 +05:30
|
|
|
color: Color,
|
2018-03-26 00:46:45 +05:30
|
|
|
disabled?: bool,
|
2018-05-03 00:25:34 +05:30
|
|
|
component: string | ComponentType<any>,
|
2018-04-19 01:19:10 +05:30
|
|
|
}> {
|
2016-05-30 10:10:59 +05:30
|
|
|
static defaultProps = {
|
2018-03-26 00:46:45 +05:30
|
|
|
color: COLOR_GREEN,
|
|
|
|
component: 'button',
|
2016-05-02 12:45:42 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2017-08-20 21:15:21 +05:30
|
|
|
const {
|
|
|
|
color,
|
|
|
|
block,
|
|
|
|
small,
|
2018-03-26 00:46:45 +05:30
|
|
|
disabled,
|
2017-08-20 21:15:21 +05:30
|
|
|
className,
|
|
|
|
loading,
|
|
|
|
label,
|
2018-03-26 00:46:45 +05:30
|
|
|
component: ComponentProp,
|
2017-08-20 21:15:21 +05:30
|
|
|
...restProps
|
|
|
|
} = this.props;
|
2016-05-02 12:45:42 +05:30
|
|
|
|
|
|
|
return (
|
2018-03-26 00:46:45 +05:30
|
|
|
<ComponentProp
|
2017-08-23 02:30:10 +05:30
|
|
|
className={classNames(buttons[color], {
|
|
|
|
[buttons.loading]: loading,
|
|
|
|
[buttons.block]: block,
|
2018-03-26 00:46:45 +05:30
|
|
|
[buttons.smallButton]: small,
|
|
|
|
[buttons.disabled]: disabled,
|
2017-08-23 02:30:10 +05:30
|
|
|
}, className)}
|
2018-03-26 00:46:45 +05:30
|
|
|
disabled={disabled}
|
2017-08-20 21:15:21 +05:30
|
|
|
{...restProps}
|
2016-07-29 22:44:52 +05:30
|
|
|
>
|
2017-08-20 21:15:21 +05:30
|
|
|
{this.formatMessage(label)}
|
2018-03-26 00:46:45 +05:30
|
|
|
</ComponentProp>
|
2016-05-02 12:45:42 +05:30
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|