feat: add accessible Tooltip component with hover, focus, and tap support

This commit is contained in:
Jose Selesan
2026-09-29 20:12:06 -03:00
parent 9520763ec3
commit 8ccff20473
22 changed files with 1317 additions and 126 deletions

View File

@@ -1,5 +1,6 @@
import type { GroupWaitlistEntryDto } from '@gruperly/shared'
import { ChevronRight } from 'lucide-react'
import { formatPhoneDisplay } from '../../../lib/format'
import { useGroupDetail } from './GroupDetailProvider'
export function WaitlistTable({ entries }: { entries: GroupWaitlistEntryDto[] }) {
@@ -9,9 +10,9 @@ export function WaitlistTable({ entries }: { entries: GroupWaitlistEntryDto[] })
<table className="w-full table-fixed text-left text-sm">
<thead>
<tr className="border-b border-border/70 text-xs font-semibold text-foreground/80">
<th scope="col" className="w-[48%] px-3 pb-2">Nombre</th>
<th scope="col" className="px-3 pb-2">Teléfono</th>
<th scope="col" className="w-9 px-1 pb-2">
<th scope="col" className="w-[47%] px-2 pb-1.5">Nombre</th>
<th scope="col" className="px-2 pb-1.5">Teléfono</th>
<th scope="col" className="w-8 px-1 pb-1.5">
<span className="sr-only">Detalle</span>
</th>
</tr>
@@ -20,16 +21,23 @@ export function WaitlistTable({ entries }: { entries: GroupWaitlistEntryDto[] })
{entries.map((entry) => (
<tr
key={entry.id}
className="group cursor-pointer border-b border-border/70 transition-colors last:border-b-0 hover:bg-primary-soft/60"
tabIndex={0}
className="group cursor-pointer border-b border-border/70 transition-colors last:border-b-0 hover:bg-primary-soft/60 focus-visible:bg-primary-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent"
onClick={() => setSelectedWaitlistEntry(entry)}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault()
setSelectedWaitlistEntry(entry)
}
}}
>
<td className="px-3 py-2.5">
<div className="flex min-w-0 items-center gap-2.5">
<div className="flex size-9 shrink-0 items-center justify-center rounded-full bg-accent/10 text-xs font-semibold text-accent">
<td className="px-2 py-2">
<div className="flex min-w-0 items-center gap-2">
<div className="flex size-8 shrink-0 items-center justify-center rounded-full bg-accent/10 text-xs font-semibold text-accent">
{entry.fullName.charAt(0).toUpperCase()}
</div>
<div className="min-w-0">
<p className="truncate font-medium text-primary" title={entry.fullName}>
<p className="truncate font-semibold text-primary" title={entry.fullName}>
{entry.fullName}
</p>
{entry.notes ? (
@@ -40,16 +48,16 @@ export function WaitlistTable({ entries }: { entries: GroupWaitlistEntryDto[] })
</div>
</div>
</td>
<td className="min-w-0 px-3 py-2.5 text-foreground/80">
<td className="min-w-0 px-2 py-2 text-xs text-foreground/70">
{entry.phone ? (
<span className="block truncate tabular-nums" title={entry.phone}>
{entry.phone}
{formatPhoneDisplay(entry.phone)}
</span>
) : (
<span className="text-foreground/60">—</span>
)}
</td>
<td className="w-9 px-1 py-2.5 text-foreground/50">
<td className="w-8 px-1 py-2 text-foreground/50">
<ChevronRight className="ml-auto size-4 transition-colors group-hover:text-accent" />
</td>
</tr>