-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIconButton.jsx
42 lines (39 loc) · 1.02 KB
/
IconButton.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
import React from "react";
function IconButton({ Icon, showBadge, count, text, activeTab, onPress }) {
return (
<button
className="p-4 rounded-xl hover:bg-teal-50 cursor-pointer group"
onClick={() => onPress(text)}
>
{showBadge ? (
<BadgeIcon
Icon={Icon}
count={count}
text={text}
activeTab={activeTab}
/>
) : (
<Icon
className={`w-5 h-5 group-hover:text-teal-600 ${
activeTab === text ? "text-teal-600" : "text-gray-400"
}`}
/>
)}
</button>
);
}
function BadgeIcon({ Icon, count, text, activeTab }) {
return (
<div className="relative">
<Icon
className={`w-5 h-5 group-hover:text-teal-600 ${
activeTab === text ? "text-teal-600" : "text-gray-400"
}`}
/>
<span className="absolute top-0 right-0 rounded-full p-1 bg-red-400 flex justify-center items-center">
{count ? count : ""}
</span>
</div>
);
}
export default IconButton;