feat: add accessible Tooltip component with hover, focus, and tap support
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { AttendeeDto } from '@gruperly/shared'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { ChevronRight } from 'lucide-react'
|
||||
import { formatPhoneDisplay } from '../../../lib/format'
|
||||
import { useGroupDetail } from './GroupDetailProvider'
|
||||
|
||||
export function MembersTable({ attendees }: { attendees: AttendeeDto[] }) {
|
||||
@@ -15,9 +16,9 @@ export function MembersTable({ attendees }: { attendees: AttendeeDto[] }) {
|
||||
<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>
|
||||
@@ -26,31 +27,43 @@ export function MembersTable({ attendees }: { attendees: AttendeeDto[] }) {
|
||||
{attendees.map((attendee) => (
|
||||
<tr
|
||||
key={attendee.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={() => openAttendee(attendee.id)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault()
|
||||
openAttendee(attendee.id)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<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">
|
||||
{attendee.fullName.charAt(0).toUpperCase()}
|
||||
</div>
|
||||
{/* `truncate` solo recorta lo pintado: el texto completo sigue en
|
||||
el DOM para lectores de pantalla, y `title` lo muestra al hover. */}
|
||||
<span className="min-w-0 truncate font-medium text-primary" title={attendee.fullName}>
|
||||
<span
|
||||
className="min-w-0 truncate font-semibold text-primary"
|
||||
title={attendee.fullName}
|
||||
>
|
||||
{attendee.fullName}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td className="min-w-0 px-3 py-2.5 text-foreground/80">
|
||||
{/* El nombre manda; el teléfono es un dato secundario: un nivel
|
||||
más abajo en la escala de color, en un tamaño menor. */}
|
||||
<td className="min-w-0 px-2 py-2 text-xs text-foreground/70">
|
||||
{attendee.phone ? (
|
||||
<span className="block truncate tabular-nums" title={attendee.phone}>
|
||||
{attendee.phone}
|
||||
{formatPhoneDisplay(attendee.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>
|
||||
|
||||
Reference in New Issue
Block a user