PluginProbe
Code Snippets / 3.8.1
Code Snippets v3.8.1
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 / components / common / Button.tsx

Button.tsx in Code Snippets 3.8.1, at js/components/common/Button.tsx

50 lines 929 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 type { ButtonHTMLAttributes } from 'react'
4
5 export interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'id' | 'name'> {
6 id?: string
7 name?: string
8 primary?: boolean
9 secondary?: boolean
10 small?: boolean
11 large?: boolean
12 link?: boolean
13 }
14
15 export const Button: React.FC<ButtonProps> = ({
16 id,
17 children,
18 className,
19 name,
20 primary = false,
21 secondary = false,
22 small = false,
23 large = false,
24 link = false,
25 type = 'button',
26 onClick,
27 ...props
28 }) =>
29 <button
30 id={id ?? name}
31 name={name}
32 type={type}
33 {...props}
34 onClick={event => {
35 if (onClick) {
36 event.preventDefault()
37 onClick(event)
38 }
39 }}
40 className={classnames('button', className, {
41 'button-primary': primary,
42 'button-secondary': secondary,
43 'button-large': large,
44 'button-small': small,
45 'button-link': link
46 })}
47 >
48 {children}
49 </button>
50