accounts-frontend/packages/app/components/ui/form/Button.tsx

46 lines
1.0 KiB
TypeScript
Raw Normal View History

import React, { ComponentType } from 'react';
2019-12-08 01:13:08 +05:30
import clsx from 'clsx';
import { COLOR_GREEN } from 'app/components/ui';
import { Color } from 'app/components/ui';
2016-05-02 12:45:42 +05:30
2019-12-09 13:17:51 +05:30
import buttons from '../buttons.scss';
interface Props extends React.ButtonHTMLAttributes<HTMLButtonElement> {
block?: boolean;
small?: boolean;
loading?: boolean;
className?: string;
color?: Color;
disabled?: boolean;
component?: string | React.ComponentType<any>;
}
const Button: ComponentType<Props> = ({
color = COLOR_GREEN,
block,
small,
disabled,
className,
loading,
component: ComponentProp = 'button',
...restProps
}) => (
<ComponentProp
className={clsx(
buttons[color],
{
[buttons.loading]: loading,
[buttons.block]: block,
[buttons.smallButton]: small,
[buttons.disabled]: disabled,
},
2020-05-24 04:38:24 +05:30
className,
)}
disabled={disabled}
{...restProps}
/>
);
2016-05-02 12:45:42 +05:30
export default Button;