{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tooltip-status-dot",
  "title": "Tooltip Status Dot",
  "description": "A presence or status dot that is never only a colour: a focusable image named with the status in words, plus a tooltip with optional detail.",
  "registryDependencies": [
    "tooltip"
  ],
  "files": [
    {
      "path": "registry/patterns/tooltip-status-dot/tooltip-status-dot.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\nimport {\n  Tooltip,\n  TooltipContent,\n  TooltipTrigger,\n} from \"@/components/ui/tooltip\"\n\nexport type Status = \"online\" | \"away\" | \"busy\" | \"offline\"\n\nconst DETAILS: Record<Status, { label: string; dot: string }> = {\n  online: { label: \"Online\", dot: \"bg-emerald-500\" },\n  away: { label: \"Away\", dot: \"bg-amber-500\" },\n  busy: { label: \"Do not disturb\", dot: \"bg-red-500\" },\n  offline: { label: \"Offline\", dot: \"bg-zinc-400\" },\n}\n\nexport interface TooltipStatusDotProps {\n  status: Status\n  /** Extra detail for the tooltip, e.g. \"Back at 14:00\". */\n  detail?: string\n  /** Who the status belongs to, used in the accessible name. */\n  name: string\n}\n\n/**\n * A status dot that is never only a colour. The dot is a focusable image with\n * the status written as its name (\"Maya: Away. Back at 14:00\"), the tooltip\n * repeats it for mouse users, and each status has its own text, so colour\n * blindness does not hide it.\n */\nexport function TooltipStatusDot({\n  status,\n  detail,\n  name,\n}: TooltipStatusDotProps) {\n  const info = DETAILS[status]\n  const text = `${name}: ${info.label}${detail ? `. ${detail}` : \"\"}`\n  return (\n    <Tooltip>\n      <TooltipTrigger asChild>\n        <span\n          role=\"img\"\n          aria-label={text}\n          // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- the dot is focusable so keyboard users can read its status\n          tabIndex={0}\n          className=\"focus-visible:ring-ring inline-flex size-4 items-center justify-center rounded-full outline-none focus-visible:ring-2\"\n        >\n          <span className={cn(\"size-2.5 rounded-full\", info.dot)} />\n        </span>\n      </TooltipTrigger>\n      <TooltipContent>\n        {info.label}\n        {detail ? ` · ${detail}` : \"\"}\n      </TooltipContent>\n    </Tooltip>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}