feat: add SectionChips component for improved navigation between members, pre-registrations, and waitlist
This commit is contained in:
73
apps/web/src/features/groups/detail/SectionChips.tsx
Normal file
73
apps/web/src/features/groups/detail/SectionChips.tsx
Normal file
@@ -0,0 +1,73 @@
|
||||
import { Clock, UserCheck, Users } from 'lucide-react'
|
||||
import { cn } from '../../../lib/utils'
|
||||
import { type ListSection, useGroupDetail } from './GroupDetailProvider'
|
||||
|
||||
const SECTIONS = [
|
||||
{ id: 'members', label: 'Miembros', icon: Users, attention: false },
|
||||
{ id: 'preregistrations', label: 'Pre-inscripciones', icon: UserCheck, attention: true },
|
||||
{ id: 'waitlist', label: 'Lista de espera', icon: Clock, attention: false },
|
||||
] as const satisfies ReadonlyArray<{
|
||||
id: ListSection
|
||||
label: string
|
||||
icon: typeof Users
|
||||
attention: boolean
|
||||
}>
|
||||
|
||||
export function SectionChips() {
|
||||
const { listSection, setListSection, attendeesTotal, preRegistrationsTotal, waitlistTotal } =
|
||||
useGroupDetail()
|
||||
|
||||
const counts: Record<ListSection, number> = {
|
||||
members: attendeesTotal,
|
||||
preregistrations: preRegistrationsTotal,
|
||||
waitlist: waitlistTotal,
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
role="group"
|
||||
aria-label="Listado del grupo"
|
||||
className="flex w-full flex-wrap items-center gap-2"
|
||||
>
|
||||
{SECTIONS.map((section) => {
|
||||
const isActive = listSection === section.id
|
||||
const count = counts[section.id]
|
||||
const Icon = section.icon
|
||||
|
||||
return (
|
||||
<button
|
||||
key={section.id}
|
||||
type="button"
|
||||
aria-pressed={isActive}
|
||||
onClick={() => setListSection(section.id)}
|
||||
className={cn(
|
||||
'inline-flex min-h-10 items-center gap-1.5 rounded-full border px-3 text-xs font-semibold',
|
||||
'transition-[background-color,color,border-color,box-shadow] duration-150',
|
||||
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-primary-soft',
|
||||
isActive
|
||||
? 'border-transparent bg-accent text-on-accent shadow-xs'
|
||||
: 'border-border bg-surface text-foreground/80 hover:border-accent/40 hover:bg-primary-soft hover:text-primary',
|
||||
)}
|
||||
>
|
||||
<Icon className="size-3.5 shrink-0" />
|
||||
<span className="whitespace-nowrap">{section.label}</span>
|
||||
{count > 0 ? (
|
||||
<span
|
||||
className={cn(
|
||||
'inline-flex items-center justify-center rounded-full px-1.5 py-0.5 text-[10px] font-bold leading-none tabular-nums',
|
||||
isActive
|
||||
? 'bg-on-accent/25 text-on-accent'
|
||||
: section.attention
|
||||
? 'bg-warning-soft text-warning'
|
||||
: 'bg-primary-soft text-foreground/60',
|
||||
)}
|
||||
>
|
||||
{count}
|
||||
</span>
|
||||
) : null}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user