-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathButton.tsx
More file actions
53 lines (51 loc) · 1.14 KB
/
Button.tsx
File metadata and controls
53 lines (51 loc) · 1.14 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
import React from 'react';
import clsx from 'clsx';
import { generateClasses } from '../utils';
import Loading from "./Loading";
interface ClassNames {
button?: string;
}
interface Props {
classNames?: ClassNames;
disabled: boolean;
displayText: string;
onClick: () => {};
overrideClasses?: boolean;
isLoading?: boolean;
LoadingIndicator?: React.FC;
}
const Button: React.FC<Props> = ({
classNames,
disabled,
displayText,
onClick,
overrideClasses,
isLoading = false,
LoadingIndicator
}) => (
<button
className={clsx([
generateClasses(
'py-xs px-sm text-basefont-medium bg-primary text-white w-full hover:bg-primary-dark flex justify-center item-center',
classNames?.button,
overrideClasses,
),
{
'bg-gray-500': disabled,
'hover:bg-gray-600': disabled || isLoading
},
])}
disabled={disabled}
type="button"
onClick={() => {
if (!disabled) {
onClick();
}
}}
>
{isLoading ?
<Loading/>:
<span className="items-center">{displayText}</span>}
</button>
);
export default Button;