forked from nodejs/nodejs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
48 lines (40 loc) · 1.04 KB
/
Copy pathindex.tsx
File metadata and controls
48 lines (40 loc) · 1.04 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
import type { FC, PropsWithChildren } from 'react';
import Link from '@/components/Link';
import WithRouterSelect from '@/components/withRouterSelect';
import styles from './index.module.css';
type LinkTab = { key: string; label: string; link: string };
type LinkTabsProps = {
label?: string;
tabs: Array<LinkTab>;
activeTab: string;
};
const LinkTabs: FC<PropsWithChildren<LinkTabsProps>> = ({
tabs,
label,
activeTab,
children,
}) => (
<>
<div className={styles.tabsList}>
{tabs.map(tab => (
<Link
key={tab.key}
href={tab.link}
className={styles.tabsTrigger}
data-state={tab.key === activeTab ? 'active' : 'inactive'}
>
{tab.label}
</Link>
))}
</div>
<div className={styles.tabsSelect}>
<WithRouterSelect
label={label}
defaultValue={tabs.find(tab => tab.key === activeTab)?.link}
values={tabs.map(tab => ({ label: tab.label, value: tab.link }))}
/>
</div>
{children}
</>
);
export default LinkTabs;