57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import { Link, useLocation } from '@tanstack/react-router'
|
|
import { ChevronRight } from 'lucide-react'
|
|
|
|
type Crumb = { label: string; to?: string }
|
|
|
|
const BREADCRUMBS: Record<string, Crumb[]> = {
|
|
'/': [{ label: 'Inicio' }],
|
|
'/groups': [
|
|
{ label: 'Inicio', to: '/' },
|
|
{ label: 'Grupos' },
|
|
],
|
|
'/payments': [
|
|
{ label: 'Inicio', to: '/' },
|
|
{ label: 'Cobros' },
|
|
],
|
|
'/settings': [
|
|
{ label: 'Inicio', to: '/' },
|
|
{ label: 'Ajustes' },
|
|
],
|
|
'/security': [
|
|
{ label: 'Inicio', to: '/' },
|
|
{ label: 'Ajustes', to: '/settings' },
|
|
{ label: 'Seguridad' },
|
|
],
|
|
'/profile': [
|
|
{ label: 'Inicio', to: '/' },
|
|
{ label: 'Mi perfil' },
|
|
],
|
|
}
|
|
|
|
export function Breadcrumb() {
|
|
const location = useLocation()
|
|
const crumbs = BREADCRUMBS[location.pathname] ?? [{ label: 'Inicio' }]
|
|
|
|
return (
|
|
<nav aria-label="Breadcrumb" className="hidden items-center gap-1.5 text-sm lg:flex">
|
|
{crumbs.map((crumb, i) => {
|
|
const isLast = i === crumbs.length - 1
|
|
return (
|
|
<span key={crumb.label} className="flex items-center gap-1.5">
|
|
{i > 0 ? <ChevronRight className="size-3.5 text-foreground/40" /> : null}
|
|
{isLast ? (
|
|
<span className="font-medium text-primary">{crumb.label}</span>
|
|
) : (
|
|
<Link
|
|
to={crumb.to!}
|
|
className="text-foreground/50 transition-colors hover:text-primary"
|
|
>
|
|
{crumb.label}
|
|
</Link>
|
|
)}
|
|
</span>
|
|
)
|
|
})}
|
|
</nav>
|
|
)
|
|
} |