| 1 |
import React, { ButtonHTMLAttributes } from 'react' |
| 2 |
import classnames from 'classnames' |
| 3 |
|
| 4 |
export interface ActionButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'id' | 'name'> { |
| 5 |
id?: string |
| 6 |
name?: string |
| 7 |
primary?: boolean |
| 8 |
small?: boolean |
| 9 |
large?: boolean |
| 10 |
text: string |
| 11 |
} |
| 12 |
|
| 13 |
export const ActionButton: React.FC<ActionButtonProps> = ({ |
| 14 |
id, |
| 15 |
text, |
| 16 |
name = 'submit', |
| 17 |
primary = false, |
| 18 |
small = false, |
| 19 |
large = false, |
| 20 |
type = 'button', |
| 21 |
onClick, |
| 22 |
...props |
| 23 |
}) => |
| 24 |
<button |
| 25 |
id={id ?? name} |
| 26 |
name={name} |
| 27 |
type={type} |
| 28 |
{...props} |
| 29 |
onClick={event => { |
| 30 |
if (onClick) { |
| 31 |
event.preventDefault() |
| 32 |
onClick(event) |
| 33 |
} |
| 34 |
}} |
| 35 |
className={classnames('button', { |
| 36 |
'button-primary': primary, |
| 37 |
'button-large': large, |
| 38 |
'button-small': small |
| 39 |
})} |
| 40 |
>{text}</button> |
| 41 |
|