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,10 +1,10 @@
import { useNavigate } from '@tanstack/react-router'
import type { GroupDto, GroupRiskLevel } from '@gruperly/shared'
import { useNavigate } from '@tanstack/react-router'
import { CalendarClock, Users } from 'lucide-react'
import { Badge, Button } from '../../components/ui'
import { Badge, Button, Tooltip } from '../../components/ui'
import { BILLING_LABELS, formatPrice, formatSchedule } from '../../lib/format'
import { cn } from '../../lib/utils'
import { RISK_LABELS } from './constants'
import { RISK_HINT, RISK_LABELS } from './constants'
export function GroupCard({
group,
@@ -28,16 +28,20 @@ export function GroupCard({
</div>
<div className="flex flex-col items-end gap-1.5">
{hasRisk ? (
<Badge variant={riskLevel === 'HIGH' ? 'danger' : 'warning'} className="gap-1.5">
<span
className={cn(
'size-2 rounded-full',
riskLevel === 'HIGH' ? 'bg-danger' : 'bg-warning',
)}
aria-hidden="true"
/>
{RISK_LABELS[riskLevel]}
</Badge>
// Mismo tooltip que en el detalle: el badge es corto y la
// explicación (abandono, no cobranza) la da el tooltip.
<Tooltip content={RISK_HINT} tooltipClassName="left-auto right-0">
<Badge variant={riskLevel === 'HIGH' ? 'danger' : 'warning'} className="gap-1.5">
<span
className={cn(
'size-2 rounded-full',
riskLevel === 'HIGH' ? 'bg-danger' : 'bg-warning',
)}
aria-hidden="true"
/>
{RISK_LABELS[riskLevel]}
</Badge>
</Tooltip>
) : null}
<Badge variant="success">Activo</Badge>
</div>