-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.jsx
94 lines (91 loc) · 1.92 KB
/
Button.jsx
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { motion } from 'framer-motion';
import Image from 'next/image';
const buttonVariants = {
hover: {
scale: 1.06,
},
tap: {
scale: 0.99,
},
};
export default function Button({
type = 'primary',
size = 'medium',
label,
href,
className,
loading,
onClick,
target,
image = null,
containerPos = null,
}) {
const sizeStyles = {
small: { padding: '8px 16px 8px 16px', fontSize: '14px', height: '30px' },
medium: {
padding: '8px 32px 8px 32px',
fontSize: '16px',
height: '60px',
},
large: { padding: '8px 32px 8px 32px', fontSize: '18px', height: '40px' },
};
const colorClasses = {
primary: {
backgroundColor: '#fb8c00',
color: 'white',
},
secondary: {
backgroundColor: '#4f9cf9',
color: 'white',
},
tertiary: {
backgroundColor: 'white',
color: '#043873',
},
special: {
backgroundColor: '#333333',
color: '#ffffff',
},
danger: {
backgroundColor: '#f44336',
color: '#ffffff',
},
success: {
backgroundColor: '#4caf50',
color: '#ffffff',
},
};
return (
<div className={`flex ${containerPos}`}>
<motion.a
variants={buttonVariants}
whileHover="hover"
whileTap="tap"
style={{
...colorClasses[type],
...sizeStyles[size],
borderRadius: '0.25rem ',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
cursor: 'pointer',
}}
href={href}
className={className}
onClick={onClick}
target={target}
>
<div style={{ display: 'flex', alignItems: 'center' }}>
{label}
{image ? (
<Image
src={image}
alt="button arrow"
style={{ marginLeft: '5px' }}
/>
) : null}
</div>
</motion.a>
</div>
);
}