PluginProbe
Code Snippets / 3.6.3
Code Snippets v3.6.3
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 / Button.tsx

Button.tsx in Code Snippets 3.6.3, at js/common/Button.tsx

43 lines 786 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 ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'id' | 'name'> {
5 id?: string
6 name?: string
7 primary?: boolean
8 small?: boolean
9 large?: boolean
10 }
11
12 export const Button: React.FC<ButtonProps> = ({
13 id,
14 children,
15 className,
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', className, {
36 'button-primary': primary,
37 'button-large': large,
38 'button-small': small
39 })}
40 >
41 {children}
42 </button>
43