PluginProbe
Code Snippets / 3.5.0
Code Snippets v3.5.0
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 3.0.1 All 64 releases
code-snippets / js / common / ActionButton.tsx

ActionButton.tsx in Code Snippets 3.5.0, at js/common/ActionButton.tsx

41 lines 782 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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