-
Notifications
You must be signed in to change notification settings - Fork 157
Expand file tree
/
Copy pathButton.js
More file actions
70 lines (66 loc) · 1.63 KB
/
Copy pathButton.js
File metadata and controls
70 lines (66 loc) · 1.63 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React from 'react';
import classNames from 'classnames';
import PropTypes from 'prop-types';
/**
*
* @param {children} props
* @param {type} props primary, danger, secondary
* @param {size} props small, medium, large,
* @param {disabled} props true, false
* @param {fullWidth} props Button width is 100% of parent
* @param {typography} props capitalize, uppercase, lowercase, only
* @param {floating} props Adds a shadow under the button
*/
const Button = (props) => {
const {
children,
floating,
type,
size,
shape,
typography,
disabled,
fullWidth,
id,
onClick,
} = props;
return (
<button
id={id}
disabled={disabled}
onClick={onClick}
className={classNames({
button: true,
[type]: !disabled,
disabled: disabled,
'shadow-floating hover:shadow': floating,
'w-full': fullWidth,
[size]: true,
[shape]: true,
[typography]: true,
})}
>
{children}
</button>
);
};
Button.propTypes = {
size: PropTypes.oneOf(['small', 'medium', 'large']),
type: PropTypes.oneOf(['primary', 'secondary', 'tertiary', 'disabled', 'danger']),
typography: PropTypes.oneOf(['uppercase', 'capitalize', 'lowercase', 'none']),
shape: PropTypes.oneOf(['square', 'rounded', 'pill']),
children: PropTypes.node,
disabled: PropTypes.bool,
floating: PropTypes.bool,
fullWidth: PropTypes.bool,
onClick: PropTypes.func.isRequired,
id: PropTypes.string,
};
Button.defaultProps = {
size: 'medium',
type: 'primary',
typography: 'uppercase',
shape: 'rounded',
floating: false,
};
export default Button;