{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "share-row",
  "type": "registry:component",
  "title": "Share Row",
  "description": "A row of share pills with monochrome glyphs that pick up each platform's accent on hover, a copy-link pill and a native share button.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "social",
    "share",
    "social",
    "links",
    "copy",
    "clipboard",
    "buttons"
  ],
  "docs": "https://hyperblur.dev/effects/share-row",
  "files": [
    {
      "path": "registry/hyperblur/share-row.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/share-row.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type ShareId = \"x\" | \"linkedin\" | \"facebook\" | \"whatsapp\" | \"email\" | \"copy\" | \"link\";\n\nexport interface ShareLink {\n  id: ShareId;\n  href?: string;\n  label?: string;\n}\n\nexport interface ShareRowProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n  links?: ShareLink[];\n  title?: string;\n  url?: string;\n  text?: string;\n  iconOnly?: boolean;\n}\n\nconst css = `\n.hb-sh {\n  position: relative;\n  display: flex;\n  flex-wrap: wrap;\n  align-items: center;\n  gap: 8px;\n  font-family: inherit;\n}\n.hb-sh-p {\n  display: inline-flex;\n  align-items: center;\n  gap: 8px;\n  height: 36px;\n  margin: 0;\n  padding: 0 14px 0 11px;\n  border: 1px solid #262626;\n  border-radius: 999px;\n  background: #171717;\n  color: #ededed;\n  font: inherit;\n  font-size: 13px;\n  font-weight: 500;\n  line-height: 1;\n  text-decoration: none;\n  white-space: nowrap;\n  cursor: pointer;\n  user-select: none;\n  touch-action: manipulation;\n  -webkit-tap-highlight-color: transparent;\n  transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.12s ease;\n}\n.hb-sh-p[data-icon=\"true\"] { padding: 0 11px; }\n.hb-sh-p:hover, .hb-sh-p:focus-visible {\n  border-color: color-mix(in srgb, var(--hb-a) 50%, #262626);\n  background: color-mix(in srgb, var(--hb-a) 8%, #171717);\n}\n.hb-sh-p:active { transform: scale(0.96); }\n.hb-sh-p:focus-visible { outline: 2px solid var(--hb-a); outline-offset: 2px; }\n.hb-sh-g {\n  display: inline-flex;\n  width: 18px;\n  height: 18px;\n  flex: none;\n  color: #8f8f8f;\n  transition: color 0.18s ease;\n}\n.hb-sh-p:hover .hb-sh-g, .hb-sh-p:focus-visible .hb-sh-g, .hb-sh-p[data-done=\"true\"] .hb-sh-g { color: var(--hb-a); }\n.hb-sh-g svg {\n  width: 100%;\n  height: 100%;\n  fill: none;\n  stroke: currentColor;\n  stroke-width: 1.8;\n  stroke-linecap: round;\n  stroke-linejoin: round;\n}\n.hb-sh-l[data-done=\"true\"] { color: #7ee787; }\n.hb-sh-sr {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  margin: -1px;\n  overflow: hidden;\n  clip-path: inset(50%);\n  white-space: nowrap;\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-sh-p, .hb-sh-g { transition: none; }\n  .hb-sh-p:active { transform: none; }\n}\n`;\n\nconst defaultLinks: ShareLink[] = [{ id: \"x\" }, { id: \"linkedin\" }, { id: \"email\" }, { id: \"copy\" }];\n\nconst accents: Record<ShareId | \"share\", string> = {\n  x: \"#ffffff\",\n  linkedin: \"#4a9eff\",\n  facebook: \"#4c8dff\",\n  whatsapp: \"#25d366\",\n  email: \"#ffb454\",\n  copy: \"#7ee787\",\n  link: \"#a5b4ff\",\n  share: \"#ededed\",\n};\n\nconst labels: Record<ShareId | \"share\", string> = {\n  x: \"Share on X\",\n  linkedin: \"Share on LinkedIn\",\n  facebook: \"Share on Facebook\",\n  whatsapp: \"Share on WhatsApp\",\n  email: \"Share by email\",\n  copy: \"Copy link\",\n  link: \"Open link\",\n  share: \"Share\",\n};\n\nconst noop = () => () => {};\n\nfunction build(id: ShareId, title: string, url: string, text: string) {\n  const u = encodeURIComponent(url);\n  const message = text || title;\n  switch (id) {\n    case \"x\":\n      return `https://x.com/intent/post?url=${u}&text=${encodeURIComponent(message)}`;\n    case \"linkedin\":\n      return `https://www.linkedin.com/sharing/share-offsite/?url=${u}`;\n    case \"facebook\":\n      return `https://www.facebook.com/sharer/sharer.php?u=${u}`;\n    case \"whatsapp\":\n      return `https://wa.me/?text=${encodeURIComponent([message, url].filter(Boolean).join(\" \"))}`;\n    case \"email\":\n      return `mailto:?subject=${encodeURIComponent(title)}&body=${encodeURIComponent(\n        [text, url].filter(Boolean).join(\"\\n\\n\"),\n      )}`;\n    default:\n      return url;\n  }\n}\n\nfunction Glyph({ id }: { id: ShareId | \"share\" | \"done\" }) {\n  let body: React.ReactNode;\n  switch (id) {\n    case \"x\":\n      body = <path d=\"M5 4l14 16M19 4L5 20\" />;\n      break;\n    case \"linkedin\":\n      body = (\n        <>\n          <rect x=\"3\" y=\"7\" width=\"18\" height=\"13\" rx=\"2\" />\n          <path d=\"M9 7V5a1 1 0 011-1h4a1 1 0 011 1v2M3 13h18\" />\n        </>\n      );\n      break;\n    case \"facebook\":\n      body = (\n        <>\n          <circle cx=\"9\" cy=\"8\" r=\"3.2\" />\n          <path d=\"M3 20c0-3.3 2.7-5.5 6-5.5s6 2.2 6 5.5\" />\n          <path d=\"M16 5.2a3.2 3.2 0 010 5.6M18 14.8c1.8.7 3 2.4 3 5.2\" />\n        </>\n      );\n      break;\n    case \"whatsapp\":\n      body = <path d=\"M5 4h14a1 1 0 011 1v10a1 1 0 01-1 1h-8l-4 4v-4H5a1 1 0 01-1-1V5a1 1 0 011-1z\" />;\n      break;\n    case \"email\":\n      body = (\n        <>\n          <rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2\" />\n          <path d=\"M3 7l9 6 9-6\" />\n        </>\n      );\n      break;\n    case \"copy\":\n      body = (\n        <>\n          <rect x=\"8\" y=\"8\" width=\"12\" height=\"12\" rx=\"2\" />\n          <path d=\"M16 8V6a2 2 0 00-2-2H6a2 2 0 00-2 2v8a2 2 0 002 2h2\" />\n        </>\n      );\n      break;\n    case \"link\":\n      body = (\n        <>\n          <path d=\"M10 14a4 4 0 005.7 0l3-3a4 4 0 00-5.7-5.7l-1 1\" />\n          <path d=\"M14 10a4 4 0 00-5.7 0l-3 3a4 4 0 005.7 5.7l1-1\" />\n        </>\n      );\n      break;\n    case \"share\":\n      body = (\n        <>\n          <path d=\"M12 15V3M7.5 7.5L12 3l4.5 4.5\" />\n          <path d=\"M5 12v6a2 2 0 002 2h10a2 2 0 002-2v-6\" />\n        </>\n      );\n      break;\n    default:\n      body = <path d=\"M5 12.5l4.5 4.5L19 7.5\" />;\n  }\n  return (\n    <span className=\"hb-sh-g\" aria-hidden=\"true\">\n      <svg viewBox=\"0 0 24 24\">{body}</svg>\n    </span>\n  );\n}\n\nexport function ShareRow({\n  links = defaultLinks,\n  title = \"\",\n  url = \"\",\n  text = \"\",\n  iconOnly = false,\n  className = \"\",\n  ...rest\n}: ShareRowProps) {\n  const [copied, setCopied] = React.useState(false);\n  const timer = React.useRef<number | undefined>(undefined);\n\n  const canShare = React.useSyncExternalStore(\n    noop,\n    () => typeof navigator !== \"undefined\" && typeof navigator.share === \"function\",\n    () => false,\n  );\n\n  React.useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  async function copy() {\n    const value = url || window.location.href;\n    try {\n      await navigator.clipboard.writeText(value);\n    } catch {\n      const area = document.createElement(\"textarea\");\n      area.value = value;\n      area.setAttribute(\"readonly\", \"\");\n      area.style.position = \"fixed\";\n      area.style.opacity = \"0\";\n      document.body.appendChild(area);\n      area.select();\n      document.execCommand(\"copy\");\n      area.remove();\n    }\n    setCopied(true);\n    window.clearTimeout(timer.current);\n    timer.current = window.setTimeout(() => setCopied(false), 1600);\n  }\n\n  async function nativeShare() {\n    try {\n      await navigator.share({\n        title: title || undefined,\n        text: text || undefined,\n        url: url || window.location.href,\n      });\n    } catch {\n      return;\n    }\n  }\n\n  function pill(id: ShareId | \"share\", label: string, glyph: ShareId | \"share\" | \"done\", done = false) {\n    return {\n      className: \"hb-sh-p\",\n      \"data-icon\": iconOnly && !done ? \"true\" : \"false\",\n      \"data-done\": done ? \"true\" : \"false\",\n      style: { \"--hb-a\": accents[id] } as React.CSSProperties,\n      \"aria-label\": label,\n      title: iconOnly ? label : undefined,\n      children: (\n        <>\n          <Glyph id={glyph} />\n          {(!iconOnly || done) && (\n            <span className=\"hb-sh-l\" data-done={done ? \"true\" : \"false\"}>\n              {done ? \"Copied\" : label}\n            </span>\n          )}\n        </>\n      ),\n    };\n  }\n\n  return (\n    <div role=\"group\" aria-label=\"Share\" className={`hb-sh ${className}`} {...rest}>\n      <style href=\"hb-share-row\" precedence=\"default\">{css}</style>\n      {links.map((link, i) => {\n        const label = link.label ?? labels[link.id];\n        if (link.id === \"copy\") {\n          return (\n            <button key={`${link.id}-${i}`} type=\"button\" onClick={copy} {...pill(\"copy\", label, copied ? \"done\" : \"copy\", copied)} />\n          );\n        }\n        const base = link.href ?? (build(link.id, title, url, text) || \"#\");\n        const mail = link.id === \"email\" && !link.href;\n        return (\n          <a\n            key={`${link.id}-${i}`}\n            href={base}\n            target={mail ? undefined : \"_blank\"}\n            rel={mail ? undefined : \"noopener noreferrer\"}\n            onClick={(e) => {\n              if (!link.href && !url) {\n                e.currentTarget.href = build(link.id, title, window.location.href, text) || \"#\";\n              }\n            }}\n            {...pill(link.id, label, link.id)}\n          />\n        );\n      })}\n      {canShare && (\n        <button type=\"button\" onClick={nativeShare} {...pill(\"share\", labels.share, \"share\")} />\n      )}\n      <span className=\"hb-sh-sr\" role=\"status\" aria-live=\"polite\">\n        {copied ? \"Link copied\" : \"\"}\n      </span>\n    </div>\n  );\n}\n"
    }
  ]
}