forked from rajun/ar-test
44 lines
1.3 KiB
TypeScript
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>
|
|
);
|
|
}
|