Newer
Older
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
export function Tabs({ children }) {
const [tab, setTab] = useState("card-view");
return (
<div>
<div className="flex align-middle w-fit bg-dark-600 rounded-3xl py-2 px-2">
{children.map((child) => {
const { id } = child.props;
return (
<Tab key={id} {...child.props} activeTab={tab} onClick={setTab} />
);
})}
</div>
{children.map((child) => {
if (child.props.id !== tab) return undefined;
return child.props.children;
})}
</div>
);
}
export function Tab({ id, content, activeTab, onClick }) {
return (
<button
className={classNames(
"h-10 py-2 px-6 mx-1 rounded-2xl text-white font-semibold hover:bg-dark-800",
{
"bg-dark-800": activeTab === id,
}
)}
onClick={() => onClick(id)}
>
{content}
</button>
);
}