{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "contact-channels",
  "type": "registry:ui",
  "title": "Contact Channels",
  "description": "A hairline grid of contact cells with copy-to-clipboard actions, single-key shortcuts, tooltips, and blueprint hover styling.",
  "author": "Aditya Ojha <https://akoder.xyz>",
  "categories": [
    "contact",
    "social",
    "copy",
    "grid"
  ],
  "dependencies": [
    "lucide-react",
    "motion",
    "radix-ui"
  ],
  "registryDependencies": [
    "tooltip"
  ],
  "meta": {
    "docs": "https://akoder.xyz/components/contact-channels",
    "source": "https://github.com/AdityaKodez/adityaojha/blob/main/components/ui/contact-channels.tsx"
  },
  "files": [
    {
      "path": "components/ui/contact-channels.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { ArrowRightIcon, Check, Copy } from \"lucide-react\";\nimport { motion } from \"motion/react\";\nimport {\n  useCallback,\n  useEffect,\n  useMemo,\n  useState,\n  type ReactNode,\n} from \"react\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"./tooltip\";\n\nexport type ContactChannelAction = \"copy\" | \"external\";\n\nexport interface ContactChannelItem {\n  id: string;\n  platform: string;\n  handle?: string;\n  href?: string;\n  action?: ContactChannelAction;\n  /** Text placed on the clipboard when `action` is `\"copy\"`. */\n  copyValue?: string;\n  /** Tooltip label. Falls back to `\"Copy\"` / the platform name. */\n  tooltip?: string;\n  /** Single keyboard key that triggers the copy action. */\n  shortcutKey?: string;\n  icon?: ReactNode;\n}\n\nexport interface ContactChannelsProps {\n  items: ContactChannelItem[];\n  /** Grid column count (collapses to one column on small screens). */\n  columns?: 1 | 2 | 3;\n  /** Optional public URL for a sound played after a successful copy. */\n  copySoundSrc?: string;\n  className?: string;\n}\n\nconst COLUMN_CLASSES: Record<1 | 2 | 3, string> = {\n  1: \"grid-cols-1\",\n  2: \"grid-cols-2 max-sm:grid-cols-1\",\n  3: \"grid-cols-3 max-sm:grid-cols-1\",\n};\n\n/** Inline kbd, styled for use inside a tooltip. */\nfunction Kbd({ children }: { children: ReactNode }) {\n  return (\n    <kbd className=\"pointer-events-none ml-1 inline-flex h-5 min-w-5 select-none items-center justify-center rounded-sm bg-background/20 px-1 font-sans text-xs font-medium text-background\">\n      {children}\n    </kbd>\n  );\n}\n\nfunction playCopySound(src?: string) {\n  if (!src || typeof window === \"undefined\") return;\n\n  try {\n    const audio = new Audio(src);\n    audio.volume = 0.35;\n    void audio.play().catch(() => {});\n  } catch {\n    // Audio is optional feedback; clipboard success must not depend on it.\n  }\n}\n\nexport function ContactChannels({\n  items,\n  columns = 2,\n  copySoundSrc,\n  className,\n}: ContactChannelsProps) {\n  const [copied, setCopied] = useState<Record<string, boolean>>({});\n\n  const copyItems = useMemo(\n    () => items.filter((item) => item.action === \"copy\" && item.copyValue),\n    [items],\n  );\n\n  const handleCopy = useCallback((item: ContactChannelItem) => {\n    if (!item.copyValue) {\n      return;\n    }\n    navigator.clipboard\n      .writeText(item.copyValue)\n      .then(() => playCopySound(copySoundSrc))\n      .catch(() => {});\n    setCopied((prev) => ({ ...prev, [item.id]: true }));\n    window.setTimeout(\n      () => setCopied((prev) => ({ ...prev, [item.id]: false })),\n      2000,\n    );\n  }, [copySoundSrc]);\n\n  // Single-key copy shortcuts. Ignored while typing in editable targets.\n  useEffect(() => {\n    const handleKeyDown = (e: KeyboardEvent) => {\n      if (\n        e.target instanceof HTMLInputElement ||\n        e.target instanceof HTMLTextAreaElement ||\n        (e.target as HTMLElement).isContentEditable\n      ) {\n        return;\n      }\n\n      const target = copyItems.find(\n        (item) => item.shortcutKey?.toLowerCase() === e.key.toLowerCase(),\n      );\n      if (!target) {\n        return;\n      }\n\n      e.preventDefault();\n      handleCopy(target);\n    };\n\n    window.addEventListener(\"keydown\", handleKeyDown);\n    return () => window.removeEventListener(\"keydown\", handleKeyDown);\n  }, [copyItems, handleCopy]);\n\n  return (\n    <div\n      className={cn(\n        \"grid w-full overflow-hidden border-t border-l border-dashed\",\n        COLUMN_CLASSES[columns],\n        className,\n      )}\n    >\n      {items.map((item, idx) => {\n        const isCopyAction = item.action === \"copy\";\n        const isCopied = Boolean(copied[item.id]);\n\n        const cellContent = (\n          <motion.div\n            initial={{ opacity: 0, y: 10 }}\n            whileInView={{ opacity: 1, y: 0 }}\n            viewport={{ once: true }}\n            transition={{\n              duration: 0.22,\n              delay: idx * 0.045,\n              ease: [0.22, 1, 0.36, 1],\n            }}\n            className=\"relative flex h-full items-center gap-3 overflow-hidden p-4 text-left transition-colors group-hover:bg-muted/10 group-focus-visible:bg-muted/10\"\n          >\n            <div className=\"blueprint-bg pointer-events-none absolute inset-0 opacity-45 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100\" />\n\n            <div className=\"pointer-events-none absolute inset-0 ring-1 ring-inset ring-muted-foreground/5 transition-colors group-hover:ring-muted-foreground/10 group-focus-visible:ring-muted-foreground/10\" />\n\n            <div className=\"relative z-10 flex w-full items-center gap-3\">\n              {item.icon ? (\n                <div className=\"relative flex h-9 w-9 shrink-0 items-center justify-center rounded-sm bg-background text-muted-foreground transition-all group-hover:-translate-y-0.5 group-focus-visible:-translate-y-0.5 group-hover:text-foreground group-focus-visible:text-foreground\">\n                  {item.icon}\n                  <div className=\"pointer-events-none absolute inset-0 rounded-sm ring-1 ring-inset ring-muted-foreground/5\" />\n                </div>\n              ) : null}\n\n              <div className=\"flex min-w-0 flex-col\">\n                <span className=\"text-sm font-medium leading-none\">\n                  {item.platform}\n                </span>\n                {item.handle ? (\n                  <span className=\"mt-1 truncate font-mono text-xs text-muted-foreground\">\n                    {item.handle}\n                  </span>\n                ) : null}\n              </div>\n\n              {isCopyAction ? (\n                <div className=\"ml-auto\">\n                  {isCopied ? (\n                    <Check className=\"h-3.5 w-3.5 text-green-500\" />\n                  ) : (\n                    <Copy className=\"h-3.5 w-3.5 text-muted-foreground transition-colors group-hover:text-foreground group-focus-visible:text-foreground\" />\n                  )}\n                </div>\n              ) : (\n                <ArrowRightIcon className=\"ml-auto size-3.5 text-muted-foreground/30 transition-transform group-hover:translate-x-0.5 group-hover:-rotate-45 group-hover:text-primary group-focus-visible:translate-x-0.5 group-focus-visible:-rotate-45 group-focus-visible:text-primary\" />\n              )}\n            </div>\n          </motion.div>\n        );\n\n        if (isCopyAction) {\n          return (\n            <Tooltip key={item.id}>\n              <TooltipTrigger asChild>\n                <button\n                  type=\"button\"\n                  onClick={() => handleCopy(item)}\n                  className=\"group block w-full border-b border-r border-dashed text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground/20 focus-visible:ring-offset-0\"\n                >\n                  {cellContent}\n                </button>\n              </TooltipTrigger>\n              <TooltipContent>\n                <p>\n                  {isCopied ? \"Copied!\" : item.tooltip ?? \"Copy\"}\n                  {item.shortcutKey ? <Kbd>{item.shortcutKey}</Kbd> : null}\n                </p>\n              </TooltipContent>\n            </Tooltip>\n          );\n        }\n\n        return (\n          <Tooltip key={item.id}>\n            <TooltipTrigger asChild>\n              <a\n                href={item.href ?? \"#\"}\n                target=\"_blank\"\n                rel=\"noopener noreferrer\"\n                className=\"group block border-b border-r border-dashed focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground/20 focus-visible:ring-offset-0\"\n              >\n                {cellContent}\n              </a>\n            </TooltipTrigger>\n            <TooltipContent>\n              <p>{item.tooltip ?? item.platform}</p>\n            </TooltipContent>\n          </Tooltip>\n        );\n      })}\n    </div>\n  );\n}\n",
      "type": "registry:ui"
    }
  ],
  "docs": "## Installation\n\n```bash\nnpx shadcn@latest add @akoder/contact-channels\n```\n\n## Usage\n\n```tsx\nimport { ContactChannels } from \"@/components/ui/contact-channels\";\nimport { Github, Mail } from \"lucide-react\";\n\nconst channels = [\n  { id: \"github\", platform: \"github\", handle: \"@octocat\", href: \"https://github.com\", action: \"external\", icon: <Github className=\"size-4\" /> },\n  { id: \"email\", platform: \"email\", handle: \"hi@example.com\", action: \"copy\", copyValue: \"hi@example.com\", shortcutKey: \"e\", icon: <Mail className=\"size-4\" /> },\n];\n\nexport function Contact() {\n  return <ContactChannels items={channels} columns={2} />;\n}\n```"
}