wealth/packages/island/src/molecules/tab-links/TabLinks.tsx

49 lines
1.6 KiB
TypeScript
Raw Normal View History

import NextLink from 'next/link';
import { FlexBox } from '../../atoms/flex-box';
import { Typography } from '../../atoms/typography';
import { cn } from '../../tools/cn';
import type { TabLinksProps } from './types';
import { tabLinksVariants, tabLinkVariants } from './variants';
/**
* A row of section tabs where each section is its own route, such as the investor داشبورد's
* «اشتراک‌ها» · «تراکنش‌ها» · «دنبال‌شده‌ها» (U2; U8 ۴.۱, ۶.۱; U8 ۵.۲: the 48px row, not a pill
* row). Mobile sets `band` under the top bar; desktop sits it in the column. Plain links in a named
* nav, so Tab walks them and Enter follows one; no state, so it renders on the server, and its
* place stays put while a tab's content loads.
*/
export function TabLinks({
items,
label,
fill = false,
band,
className,
}: TabLinksProps) {
return (
<FlexBox
tag="nav"
aria-label={label}
gap="gap-1"
className={cn(tabLinksVariants({ band }), className)}
>
{items.map((item) => (
<FlexBox
key={item.href}
tag={NextLink}
href={item.href}
aria-current={item.isActive ? 'page' : undefined}
display="inline-flex"
alignItems="items-center"
justifyContent={fill ? 'justify-center' : undefined}
className={tabLinkVariants({ active: item.isActive, fill })}
>
<Typography tag="span" variant="inherit" color="inherit">
{item.label}
</Typography>
</FlexBox>
))}
</FlexBox>
);
}