{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"navy-circle-that-grows-from-the-menu-button","type":"registry:block","title":"Navy Circle That Grows From the Menu Button","description":"","dependencies":[],"files":[{"path":"components/we-inc/navy-circle-that-grows-from-the-menu-button.tsx","type":"registry:component","content":"import { useEffect, useRef, type CSSProperties } from \"react\";\n\n// Same styles as the plain HTML version; the comment at the top names the values to change.\nconst STYLES = `\n  /* Change these: page colour, circle colour, text on the circle, accent, how long the circle takes. */\n  .w7cir { --w7cir-bg: #f2f5f8; --w7cir-ink: #10213a; --w7cir-sea: #0f2847; --w7cir-foam: #eef3f8; --w7cir-acc: #f2b25c; --w7cir-speed: .65s; --w7cir-out: .5s; }\n  .w7cir { position: relative; height: 600px; overflow: hidden; background: var(--w7cir-bg); color: var(--w7cir-ink); font-family: ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif; }\n  .w7cir *, .w7cir *::before, .w7cir *::after { box-sizing: border-box; }\n  .w7cir-bar { position: absolute; z-index: 30; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 14px clamp(16px, 4vw, 48px); pointer-events: none; }\n  .w7cir-bar > * { pointer-events: auto; }\n  .w7cir-brand { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .01em; }\n  .w7cir-btn { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 18px; border: 1px solid currentColor; border-radius: 999px; background: transparent; color: inherit; font: inherit; font-size: 14px; font-weight: 600; line-height: 1; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }\n  .w7cir-icon { position: relative; width: 18px; height: 10px; }\n  .w7cir-icon i { position: absolute; left: 0; right: 0; height: 2px; background: currentColor; transition: transform .35s ease; }\n  .w7cir-icon i:first-child { top: 0; } .w7cir-icon i:last-child { bottom: 0; }\n  .w7cir-open .w7cir-icon i:first-child { transform: translateY(4px) rotate(45deg); }\n  .w7cir-open .w7cir-icon i:last-child { transform: translateY(-4px) rotate(-45deg); }\n  .w7cir a:focus-visible, .w7cir-btn:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }\n  .w7cir-menu { visibility: hidden; transition: visibility 0s var(--w7cir-out, .5s); }\n  .w7cir-open .w7cir-menu { visibility: visible; transition: visibility 0s; }\n  .w7cir-nav ul { margin: 0; padding: 0; list-style: none; }\n  .w7cir-nav a { color: inherit; text-decoration: none; }\n\n  .w7cir-page { position: relative; height: 100%; }\n  .w7cir-pic { position: absolute; inset: 0; }\n  .w7cir-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }\n  .w7cir-pic::after { content: \"\"; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(8, 22, 42, .78), rgba(8, 22, 42, .2) 70%); }\n  .w7cir-copy { position: relative; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; padding: 84px clamp(16px, 4vw, 48px) 48px; color: var(--w7cir-foam); }\n  .w7cir-eye { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--w7cir-acc); }\n  .w7cir-title { margin: 12px 0 0; max-width: 14ch; font-size: clamp(32px, 5vw, 58px); font-weight: 700; line-height: 1.02; letter-spacing: -.03em; }\n  .w7cir-cta { align-self: flex-start; display: inline-flex; align-items: center; min-height: 44px; margin-top: 24px; padding: 0 22px; border-radius: 999px; background: var(--w7cir-foam); color: var(--w7cir-sea); font-size: 15px; font-weight: 700; text-decoration: none; }\n  .w7cir-bar { color: var(--w7cir-foam); }\n  .w7cir-btn { background: rgba(8, 22, 42, .35); }\n  .w7cir-menu { position: absolute; z-index: 20; inset: 0; color: var(--w7cir-foam); }\n  /* A circle sized to cover the whole box, centred on the button and scaled up from nothing. */\n  .w7cir-disc { position: absolute; width: 3400px; height: 3400px; top: calc(36px - 1700px); right: calc(clamp(16px, 4vw, 48px) + 52px - 1700px); border-radius: 50%; background: var(--w7cir-sea);\n    transform: scale(0); transition: transform var(--w7cir-out) cubic-bezier(.6, 0, .4, 1); }\n  .w7cir-open .w7cir-disc { transform: scale(1); transition: transform var(--w7cir-speed) cubic-bezier(.55, 0, .2, 1); }\n  .w7cir-in { position: relative; display: flex; flex-direction: column; justify-content: center; height: 100%; padding: 84px clamp(16px, 4vw, 48px) 32px; text-align: right; }\n  .w7cir-nav a { display: inline-flex; align-items: center; min-height: 48px; font-size: clamp(30px, 5vw, 56px); font-weight: 700; letter-spacing: -.03em; }\n  .w7cir-nav li { opacity: 0; transform: translate(20px, -12px) scale(.96); transform-origin: right top; transition: opacity .15s, transform .2s; }\n  .w7cir-open .w7cir-nav li { opacity: 1; transform: none; transition: opacity .4s, transform .6s cubic-bezier(.2, .8, .2, 1); transition-duration: .4s; transition-delay: calc(var(--w7cir-speed) * .4 + var(--i) * .04s); }\n  .w7cir-nav a[aria-current=\"page\"] span { border-bottom: 3px solid var(--w7cir-acc); }\n  @media (hover: hover) { .w7cir-nav a:hover { color: var(--w7cir-acc); } }\n  .w7cir-note { margin: 20px 0 0; font-size: 14px; color: #b8c6d8; opacity: 0; transition: opacity .2s; }\n  .w7cir-open .w7cir-note { opacity: 1; transition: opacity .3s calc(var(--w7cir-speed) * .8); }\n  @media (prefers-reduced-motion: reduce) { .w7cir-disc, .w7cir-nav li, .w7cir-note, .w7cir-icon i { transition: none !important; } }\n`; // end STYLES\n\n// When the demo opens the menu by itself (ms). Set 0 on a real site.\nconst AUTO_OPEN = 500;\n\nexport default function NavyCircleGrowMenu() {\n  const ref = useRef<HTMLDivElement>(null);\n\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    const btn = root.querySelector<HTMLButtonElement>(\".w7cir-btn\")!, word = root.querySelector<HTMLElement>(\".w7cir-word\")!;\n    const menu = root.querySelector<HTMLElement>(\".w7cir-menu\")!, page = root.querySelector<HTMLElement>(\".w7cir-page\")!;\n    let used = false;\n    const isOpen = () => root.classList.contains(\"w7cir-open\");\n    const set = (open: boolean, moveFocus: boolean) => {\n      root.classList.toggle(\"w7cir-open\", open);\n      btn.setAttribute(\"aria-expanded\", String(open));\n      word.textContent = open ? \"Close\" : \"Menu\";\n      menu.toggleAttribute(\"inert\", !open);\n      page.toggleAttribute(\"inert\", open); // on a real page, make main and footer inert instead\n      if (moveFocus) (open ? menu.querySelector<HTMLElement>(\"a\")! : btn).focus();\n    };\n    menu.toggleAttribute(\"inert\", true);\n    const touch = () => { used = true; };\n    const onClick = () => { touch(); set(!isOpen(), true); };\n    const onKey = (e: KeyboardEvent) => {\n      if (!isOpen()) return;\n      if (e.key === \"Escape\") { e.preventDefault(); set(false, true); return; }\n      if (e.key !== \"Tab\") return;\n      // focus trap: the button plus everything in the menu\n      const f: HTMLElement[] = [btn, ...Array.from(menu.querySelectorAll<HTMLElement>(\"a[href], button\"))];\n      const i = f.indexOf(document.activeElement as HTMLElement);\n      if (e.shiftKey && i <= 0) { e.preventDefault(); f[f.length - 1].focus(); }\n      else if (!e.shiftKey && i === f.length - 1) { e.preventDefault(); f[0].focus(); }\n    };\n    const onPick = (e: MouseEvent) => {\n      const a = (e.target as HTMLElement).closest(\"a\");\n      if (!a) return;\n      e.preventDefault(); // remove on a real site so the link navigates\n      if (a.closest(\"nav\")) { menu.querySelectorAll(\"[aria-current]\").forEach((x) => x.removeAttribute(\"aria-current\")); a.setAttribute(\"aria-current\", \"page\"); }\n      set(false, true);\n    };\n    btn.addEventListener(\"click\", onClick);\n    root.addEventListener(\"pointerdown\", touch);\n    root.addEventListener(\"focusin\", touch);\n    root.addEventListener(\"keydown\", onKey);\n    menu.addEventListener(\"click\", onPick);\n    const t = AUTO_OPEN ? window.setTimeout(() => { if (!used) set(true, false); }, AUTO_OPEN) : 0;\n    return () => {\n      window.clearTimeout(t);\n      btn.removeEventListener(\"click\", onClick);\n      root.removeEventListener(\"pointerdown\", touch);\n      root.removeEventListener(\"focusin\", touch);\n      root.removeEventListener(\"keydown\", onKey);\n      menu.removeEventListener(\"click\", onPick);\n    };\n  }, []);\n\n  return (\n    <div ref={ref} className=\"w7cir\">\n      <style>{STYLES}</style>\n      <header className=\"w7cir-bar\">\n        <p className=\"w7cir-brand\">Harbourline Sailing</p>\n        <button className=\"w7cir-btn\" type=\"button\" aria-expanded=\"false\" aria-controls=\"w7cir-menu\">\n          <span className=\"w7cir-word\">Menu</span><span className=\"w7cir-icon\" aria-hidden=\"true\"><i></i><i></i></span>\n        </button>\n      </header>\n      <div className=\"w7cir-page\">\n        <div className=\"w7cir-pic\"><img src=\"https://images.pexels.com/photos/15305793/pexels-photo-15305793.jpeg?auto=compress&cs=tinysrgb&w=1200\" alt=\"A single white sailboat far out on deep blue open water\" width=\"1200\" height=\"801\" loading=\"lazy\" /></div>\n        <div className=\"w7cir-copy\">\n          <p className=\"w7cir-eye\">Dinghy and keelboat courses</p>\n          <h2 className=\"w7cir-title\">Learn to sail in the shelter of the bay.</h2>\n          <a className=\"w7cir-cta\" href=\"#\">See summer courses</a>\n        </div>\n      </div>\n      <div className=\"w7cir-menu\" id=\"w7cir-menu\">\n        <span className=\"w7cir-disc\" aria-hidden=\"true\"></span>\n        <div className=\"w7cir-in\">\n          <nav className=\"w7cir-nav\" aria-label=\"Main\">\n            <ul>\n            <li style={{ \"--i\": 0 } as CSSProperties}><a href=\"#\" aria-current=\"page\"><span>Home</span></a></li>\n            <li style={{ \"--i\": 1 } as CSSProperties}><a href=\"#\"><span>Courses</span></a></li>\n            <li style={{ \"--i\": 2 } as CSSProperties}><a href=\"#\"><span>Boats and kit</span></a></li>\n            <li style={{ \"--i\": 3 } as CSSProperties}><a href=\"#\"><span>Tides and weather</span></a></li>\n            <li style={{ \"--i\": 4 } as CSSProperties}><a href=\"#\"><span>Contact the club</span></a></li>\n            </ul>\n          </nav>\n          <p className=\"w7cir-note\">Slipway open from 8 each morning, tide permitting.</p>\n        </div>\n      </div>\n    </div>\n  );\n}\n"}]}
