Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/code-snippets/js/components/common/Button.tsx

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
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 +