Files
sendou.ink/app/features/user-page/components/UserPageIconNav.tsx
Kalle e3bfd23dc2
Some checks failed
E2E Tests / e2e (push) Has been cancelled
Tests and checks on push / run-checks-and-tests (push) Has been cancelled
Updates translation progress / update-translation-progress-issue (push) Has been cancelled
Set up prefetch intent
2026-09-09 20:21:49 +03:00

52 lines
1.1 KiB
TypeScript

import clsx from "clsx";
import { NavLink } from "react-router";
import { Image } from "~/components/Image";
import { navIconUrl } from "~/utils/urls";
import styles from "./UserPageIconNav.module.css";
export interface UserPageNavItem {
to: string;
iconName: string;
label: string;
count?: number;
isVisible: boolean;
testId?: string;
end?: boolean;
}
export function UserPageIconNav({ items }: { items: UserPageNavItem[] }) {
const visibleItems = items.filter((item) => item.isVisible);
return (
<nav className={styles.iconNav}>
{visibleItems.map((item) => (
<NavLink
key={item.to}
to={item.to}
end={item.end ?? true}
prefetch="intent"
data-testid={item.testId}
className={(state) =>
clsx(styles.iconNavItem, {
[styles.active]: state.isActive,
})
}
aria-label={
item.count !== undefined
? `${item.label} (${item.count})`
: undefined
}
>
<Image
path={navIconUrl(item.iconName)}
width={24}
height={24}
alt=""
/>
<span className={styles.label}>{item.label}</span>
</NavLink>
))}
</nav>
);
}