-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHMButton.tsx
More file actions
70 lines (63 loc) · 1.84 KB
/
HMButton.tsx
File metadata and controls
70 lines (63 loc) · 1.84 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 { motion } from 'framer-motion';
import DynamicLink from '../DynamicLink/DynamicLink';
interface Props {
text: string;
color: 'primary' | 'secondary' | 'alert' | 'success' | 'neutral';
style?: 'filled' | 'border' | 'underline' | 'disabled';
span?: boolean;
link: string;
}
const HMButton = ({ text, color, style, span, link }: Props) => {
if (style == null) {
style = 'border';
}
if (link == '') {
style = 'disabled';
}
const key = {
filled: {
primary: ['bg-yellow-500'],
secondary: ['bg-blue-500'],
alert: ['bg-red-500 '],
success: ['bg-green-500'],
neutral: ['bg-neutral-500'],
},
border: {
primary: ['bg-yellow-600/20 border-yellow-500 border'],
secondary: ['bg-blue-600/20 border-blue-500 border'],
alert: ['bg-red-600/20 border-red-500 border'],
success: ['bg-green-600/20 border-green-500 border'],
neutral: ['bg-neutral-400/30 border-neutral-300 border'],
},
underline: {
primary: ['text-yellow-500 underline'],
secondary: ['text-blue-500 underline'],
alert: ['text-red-500 underline'],
success: ['text-green-500 underline'],
neutral: ['text-neutral-300 underline'],
},
};
if (style == 'disabled') {
return (
<div
className={`flex justify-center px-6 py-3 rounded-md bg-neutral-400/30 border-neutral-400 border text-neutral-400 ${
span ? 'w-full' : 'w-fit'
} font-medium`}>
{text}
</div>
);
}
return (
<DynamicLink link={link}>
<motion.div
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
className={`flex justify-center px-6 py-3 rounded-md ${key[style][color]} ${
span ? 'w-full' : 'w-fit'
} font-medium`}>
{text}
</motion.div>
</DynamicLink>
);
};
export default HMButton;