2022-06-14 19:15:06 +03:00

36 lines
742 B
TypeScript

import { Button as AntButton } from 'antd';
import type { BaseButtonProps } from 'antd/lib/button/button';
import { throttle } from 'lodash';
import type { BaseElementProps } from './types';
type ElementProps = {
action: () => void;
text: string;
};
export default function Button({
status,
action,
text,
...props
}: BaseElementProps<never> & ElementProps) {
const throttledAction = throttle(action, 1200, {
trailing: false,
});
return (
<AntButton
disabled={status === 'Disabled'}
loading={status === 'Loading'}
onClick={throttledAction}
{...props}
>
{text}
</AntButton>
);
}
type ButtonProps = BaseButtonProps & Pick<ElementProps, 'text'>;
export type { ButtonProps };