PluginProbe
Code Snippets / 3.9.6
Code Snippets v3.9.6
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / js / components / common / SubmitButton.tsx

SubmitButton.tsx in Code Snippets 3.9.6, at js/components/common/SubmitButton.tsx

47 lines 913 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 small?: boolean
11 large?: boolean
12 wrap?: boolean
13 text?: string
14 }
15
16 export const SubmitButton: React.FC<SubmitButtonProps> = ({
17 id,
18 text,
19 name = 'submit',
20 primary,
21 small,
22 large,
23 wrap,
24 className,
25 ...inputProps
26 }) => {
27 const button =
28 <input
29 id={id ?? name}
30 type="submit"
31 name={name}
32 value={text ?? __('Save Changes', 'code-snippets')}
33 className={classnames(
34 'button',
35 {
36 'button-primary': primary,
37 'button-small': small,
38 'button-large': large
39 },
40 className
41 )}
42 {...inputProps}
43 />
44
45 return wrap ? <p className="submit">{button}</p> : button
46 }
47