| 1 |
import React from 'react' |
| 2 |
import classnames from 'classnames' |
| 3 |
import { __ } from '@wordpress/i18n' |
| 4 |
import type { InputHTMLAttributes } from 'react' |
| 5 |
|
| 6 |
export interface SubmitButtonProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'name' | 'value'> { |
| 7 |
id?: string |
| 8 |
name?: string |
| 9 |
primary?: boolean |
| 10 |
secondary?: boolean |
| 11 |
small?: boolean |
| 12 |
large?: boolean |
| 13 |
wrap?: boolean |
| 14 |
text?: string |
| 15 |
} |
| 16 |
|
| 17 |
export const SubmitButton: React.FC<SubmitButtonProps> = ({ |
| 18 |
id, |
| 19 |
text, |
| 20 |
name = 'submit', |
| 21 |
primary, |
| 22 |
secondary, |
| 23 |
small, |
| 24 |
large, |
| 25 |
wrap, |
| 26 |
className, |
| 27 |
...inputProps |
| 28 |
}) => { |
| 29 |
const button = |
| 30 |
<input |
| 31 |
id={id ?? name} |
| 32 |
type="submit" |
| 33 |
name={name} |
| 34 |
value={text ?? __('Save Changes', 'code-snippets')} |
| 35 |
className={classnames( |
| 36 |
'button', |
| 37 |
{ |
| 38 |
'button-primary': primary, |
| 39 |
'button-secondary': secondary, |
| 40 |
'button-small': small, |
| 41 |
'button-large': large |
| 42 |
}, |
| 43 |
className |
| 44 |
)} |
| 45 |
{...inputProps} |
| 46 |
/> |
| 47 |
|
| 48 |
return wrap ? <p className="submit">{button}</p> : button |
| 49 |
} |
| 50 |
|