-
Notifications
You must be signed in to change notification settings - Fork 0
/
Button.js
55 lines (49 loc) · 1.47 KB
/
Button.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
54
55
import PropTypes from 'prop-types';
import { BiLoaderAlt } from 'react-icons/bi';
function Button(props) {
const {
children = null,
className: customClassName = '',
disabled = false,
form,
href,
isLoading = false,
onClick,
to,
type = 'button',
use: Use = 'button'
} = props;
const className = `py-2 px-4 border border-transparent rounded-md shadow-sm
text-sm font-medium text-white bg-indigo-500 hover:bg-indigo-600
focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-400
disabled:opacity-50 disabled:bg-indigo-500 ${customClassName}`;
return (
<Use
className={ className }
disabled={ disabled }
form={ form }
href={ href }
onClick={ onClick }
to={ to }
type={ type }
>
{ children }
{ isLoading && (
<span className="inline-block ml-2 animate-spin">
<BiLoaderAlt className="h-4 w-4 text-indigo-400" />
</span>
) }
</Use>
);
}
Button.propTypes = {
className: PropTypes.string,
disabled: PropTypes.bool,
form: PropTypes.string,
href: PropTypes.string,
isLoading: PropTypes.bool,
onClick: PropTypes.func,
to: PropTypes.string,
type: PropTypes.string
};
export default Button;