-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
index.js
53 lines (47 loc) · 1.06 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { createElement, forwardRef } from '@wordpress/element';
export function Button( props, ref ) {
const {
href,
target,
isPrimary,
isLarge,
isSmall,
isTertiary,
isToggled,
isBusy,
isDefault,
isLink,
isDestructive,
className,
disabled,
...additionalProps
} = props;
const classes = classnames( 'components-button', className, {
'is-button': isDefault || isPrimary || isLarge || isSmall,
'is-default': isDefault || isLarge || isSmall,
'is-primary': isPrimary,
'is-large': isLarge,
'is-small': isSmall,
'is-tertiary': isTertiary,
'is-toggled': isToggled,
'is-busy': isBusy,
'is-link': isLink,
'is-destructive': isDestructive,
} );
const tag = href !== undefined && ! disabled ? 'a' : 'button';
const tagProps = tag === 'a' ? { href, target } : { type: 'button', disabled };
return createElement( tag, {
...tagProps,
...additionalProps,
className: classes,
ref,
} );
}
export default forwardRef( Button );