File size: 1,123 Bytes
af1bee9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import { forwardRef, type ReactNode } from 'react';
import { Link } from 'react-router-dom';
export interface NavTab { to: string; label: ReactNode; active: boolean }
/**
* Views of one thing that each have their own address (a run's Scenarios, Failures, Team, Report): links in a named
* navigation bar, the current one marked with aria-current="page", styled as a segmented pill bar. Use this instead of
* Tabs when a "tab" changes the URL: a tablist promises panels on the same page that screen readers can jump to.
* `extra` sits at the end of the bar (a "More" menu).
*/
export const NavTabs = forwardRef<HTMLElement, { label: string; items: NavTab[]; extra?: ReactNode; className?: string }>(
function NavTabs({ label, items, extra, className }, ref) {
return (
<nav ref={ref} aria-label={label} className={`fpt-navtabs fpt-fade-x${className ? ` ${className}` : ''}`}>
{items.map((t) => (
<Link key={t.to} to={t.to} className="fpt-navtab" aria-current={t.active ? 'page' : undefined}>{t.label}</Link>
))}
{extra}
</nav>
);
},
);
|