-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton.tsx
More file actions
47 lines (43 loc) · 1.1 KB
/
button.tsx
File metadata and controls
47 lines (43 loc) · 1.1 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
import { Box, CircularProgress } from '@mui/material';
import { FunctionComponent } from 'react';
import styles from './button.module.css';
interface ButtonProps {
onClick: () => void;
children: React.ReactNode;
disabled?: boolean;
style?: React.CSSProperties;
loading?: boolean;
variant?: 'primary' | 'secondary' | 'logout';
icon?: React.ReactNode;
}
const Button: FunctionComponent<ButtonProps> = ({
onClick,
children,
disabled,
style,
loading = false,
variant = 'secondary',
icon,
...rest
}) => {
const getButtonClassName = () => {
if (variant === 'primary') return styles.buttonPrimary;
if (variant === 'logout') return styles.buttonLogout;
return styles.button;
};
return (
<button
className={`${getButtonClassName()} ${loading ? styles.buttonLoading : ''} `}
style={style}
onClick={onClick}
disabled={disabled}
{...rest}
>
<Box display="flex" alignItems="center" gap="10px">
{loading ? <CircularProgress size={14} color="inherit" /> : icon}
{children}
</Box>
</button>
);
};
export default Button;