ar-test/app/components/admin/sidebar/sidebar-link.tsx
2026-10-27 16:28:53 +05:30

44 lines
1.3 KiB
TypeScript

import type { ReactNode } from 'react';
import { Link } from 'react-router';
import { cva } from 'class-variance-authority';
import { Text } from '~/components/ui/text';
const linkVariants = cva('flex items-center rounded-item text-sm transition-colors duration-150', {
variants: {
size: {
nav: 'h-[34px] gap-2.5 px-2.5 font-medium',
client: 'h-9 gap-2.5 px-2',
},
active: {
true: 'bg-surface-hover text-text-primary',
false: 'text-text-secondary hover:bg-surface-hover-subtle hover:text-text-primary',
},
},
});
interface SidebarLinkProps {
to: string;
label: string;
active: boolean;
size: 'nav' | 'client';
leading?: ReactNode;
count?: number;
onNavigate?: () => void;
}
export function SidebarLink({ to, label, active, size, leading, count, onNavigate }: SidebarLinkProps) {
return (
<Link to={to} onClick={onNavigate} aria-current={active ? 'page' : undefined} className={linkVariants({ size, active })}>
{leading}
<Text as='span' variant='inherit' truncate className='flex-1'>
{label}
</Text>
{count !== undefined && (
<Text as='span' variant='meta' tone='faint' numeric>
{count}
</Text>
)}
</Link>
);
}