{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"rich-toggletip-with-heading-and-link","type":"registry:component","title":"Rich Toggletip With Heading And Link","description":"","dependencies":[],"files":[{"path":"components/we-inc/rich-toggletip-with-heading-and-link.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\n\n// A rich tooltip that opens on click (a toggletip): holds a heading, text and a link, closes on Escape or a click outside.\nexport default function RichToggletipWithHeadingAndLink() {\n  const [open, setOpen] = useState(true);\n  const wrap = useRef<HTMLDivElement>(null);\n  const btn = useRef<HTMLButtonElement>(null);\n\n  useEffect(() => {\n    if (!open) return;\n    const onDown = (e: PointerEvent) => { if (!wrap.current?.contains(e.target as Node)) setOpen(false); };\n    const onKey = (e: KeyboardEvent) => { if (e.key === \"Escape\") { setOpen(false); btn.current?.focus(); } };\n    document.addEventListener(\"pointerdown\", onDown);\n    document.addEventListener(\"keydown\", onKey);\n    return () => { document.removeEventListener(\"pointerdown\", onDown); document.removeEventListener(\"keydown\", onKey); };\n  }, [open]);\n\n  return (\n    <section className=\"bg-rose-50 px-5 pb-12 pt-10\">\n      <div className=\"mx-auto max-w-md rounded-2xl border border-rose-100 bg-white p-6\">\n        <p className=\"text-sm text-slate-600\">14 Larch Close, two bedrooms</p>\n        <div className=\"relative mt-2 flex items-center gap-2\" ref={wrap}>\n          <h2 className=\"text-lg font-semibold text-slate-900\">Energy rating: B (84)</h2>\n          <div>\n            <button\n              ref={btn}\n              type=\"button\"\n              aria-expanded={open}\n              aria-controls=\"tt3-panel\"\n              aria-label=\"About energy ratings\"\n              onClick={() => setOpen(!open)}\n              className=\"grid h-10 w-10 place-items-center rounded-full text-rose-700 hover:bg-rose-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-600\"\n            >\n              <svg viewBox=\"0 0 20 20\" width=\"20\" height=\"20\" aria-hidden=\"true\" className=\"fill-current\"><path d=\"M10 1.5a8.5 8.5 0 1 1 0 17 8.5 8.5 0 0 1 0-17zm0 12a1.1 1.1 0 1 0 0 2.2 1.1 1.1 0 0 0 0-2.2zm0-9a3.2 3.2 0 0 0-3.2 3.2h2a1.2 1.2 0 1 1 1.7 1.1c-.9.4-1.5 1.2-1.5 2.2v.6h2v-.5c0-.3.2-.5.4-.6A3.2 3.2 0 0 0 10 4.5z\" /></svg>\n            </button>\n            <div\n              id=\"tt3-panel\"\n              role=\"region\"\n              aria-label=\"About energy ratings\"\n              hidden={!open}\n              className=\"absolute left-0 top-full z-10 mt-2 w-full max-w-xs rounded-xl border border-slate-200 bg-white p-4 shadow-xl\"\n            >\n              <h3 className=\"text-sm font-semibold text-slate-900\">What the B rating means</h3>\n              <p className=\"mt-1.5 text-sm leading-relaxed text-slate-600\">Ratings run from A, the most efficient, to G. A B home typically has wall and loft insulation and a modern boiler.</p>\n              <a href=\"#\" className=\"mt-3 inline-flex min-h-[40px] items-center text-sm font-semibold text-rose-700 underline underline-offset-4 hover:text-rose-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-600\">\n                Read the full certificate\n              </a>\n            </div>\n          </div>\n        </div>\n        <p className=\"mt-2 text-sm text-slate-600\">Estimated heating cost £610 a year.</p>\n        <div className=\"h-48\" aria-hidden=\"true\" />\n      </div>\n    </section>\n  );\n}\n"}]}
