PluginProbe
Code Snippets / 4.0.0-beta.2
Code Snippets v4.0.0-beta.2
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 4.0.0-beta.2, at js/components/common/SubmitButton.tsx

50 lines 982 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 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