forked from rajun/ar-test
feat: add sidebar link
This commit is contained in:
parent
269b3a8bb0
commit
14bc5047fb
43
app/components/admin/sidebar/sidebar-link.tsx
Normal file
43
app/components/admin/sidebar/sidebar-link.tsx
Normal file
@ -0,0 +1,43 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user