{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"terracotta-curtain-menu-that-drops-with-rising-links","type":"registry:block","title":"Terracotta Curtain Menu That Drops With Rising Links","description":"","dependencies":[],"files":[{"path":"components/we-inc/terracotta-curtain-menu-that-drops-with-rising-links.tsx","type":"registry:component","content":"import { useEffect, useRef, useState, type CSSProperties, type KeyboardEvent, type MouseEvent } 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, curtain colour, text on the curtain, accent, curtain speed. */\n  .w7cur { --w7cur-paper: #f4ece2; --w7cur-curtain: #9a4426; --w7cur-cream: #fbf3ea; --w7cur-ink: #2b1d16; --w7cur-speed: .6s; }\n  .w7cur { position: relative; height: 600px; overflow: hidden; background: var(--w7cur-paper); color: var(--w7cur-ink); font-family: ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif; }\n  .w7cur *, .w7cur *::before, .w7cur *::after { box-sizing: border-box; }\n  .w7cur-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); }\n  .w7cur-brand { margin: 0; font-family: ui-serif, Georgia, \"Times New Roman\", serif; font-size: 20px; letter-spacing: .01em; }\n  .w7cur-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  .w7cur-icon { position: relative; width: 18px; height: 10px; }\n  .w7cur-icon i { position: absolute; left: 0; right: 0; height: 2px; background: currentColor; transition: transform .35s ease; }\n  .w7cur-icon i:first-child { top: 0; } .w7cur-icon i:last-child { bottom: 0; }\n  .w7cur-open .w7cur-icon i:first-child { transform: translateY(4px) rotate(45deg); }\n  .w7cur-open .w7cur-icon i:last-child { transform: translateY(-4px) rotate(-45deg); }\n  .w7cur-open .w7cur-bar { color: var(--w7cur-cream); }\n  .w7cur a:focus-visible, .w7cur-btn:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }\n  .w7cur-page { display: grid; gap: 24px; height: 100%; padding: 84px clamp(16px, 4vw, 48px) 28px; align-content: center; }\n  .w7cur-eye { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #8a3a1f; }\n  .w7cur-title { margin: 12px 0 0; max-width: 14ch; font: 400 clamp(32px, 5vw, 56px)/1.05 ui-serif, Georgia, \"Times New Roman\", serif; letter-spacing: -.01em; }\n  .w7cur-text { margin: 16px 0 0; max-width: 34ch; font-size: 16px; line-height: 1.6; color: #5b4537; }\n  .w7cur-cta { display: inline-flex; align-items: center; min-height: 44px; margin-top: 22px; padding: 0 22px; border-radius: 999px; background: var(--w7cur-curtain); color: var(--w7cur-cream); font-size: 15px; font-weight: 600; text-decoration: none; }\n  .w7cur-pic { overflow: hidden; border-radius: 6px; aspect-ratio: 16 / 9; box-shadow: 0 24px 50px -28px rgba(60, 30, 15, .55); }\n  .w7cur-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }\n  @media (min-width: 760px) { .w7cur-page { grid-template-columns: 1fr 1.05fr; align-items: center; gap: 48px; } .w7cur-pic { aspect-ratio: 4 / 5; max-height: 440px; } }\n  @media (max-width: 759px) { .w7cur-text { display: none; } .w7cur-pic { max-height: 170px; } }\n\n  /* The curtain: a full-size layer that drops from above with transform only. */\n  .w7cur-menu { position: absolute; z-index: 20; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 92px clamp(16px, 4vw, 48px) 32px; background: var(--w7cur-curtain); color: var(--w7cur-cream);\n    visibility: hidden; transform: translateY(-100%); transition: transform calc(var(--w7cur-speed) * .8) cubic-bezier(.7, 0, .3, 1), visibility 0s calc(var(--w7cur-speed) * .8); }\n  .w7cur-menu::after { content: \"\"; position: absolute; left: 0; right: 0; bottom: -1px; height: 10px; background: linear-gradient(rgba(0, 0, 0, .18), transparent); transform: translateY(100%); }\n  .w7cur-open .w7cur-menu { visibility: visible; transform: none; transition: transform var(--w7cur-speed) cubic-bezier(.7, 0, .2, 1), visibility 0s; }\n  .w7cur-nav ul { margin: 0; padding: 0; list-style: none; }\n  .w7cur-nav a { display: block; overflow: hidden; padding: 2px 4px; margin-left: -4px; color: inherit; text-decoration: none; font: 400 clamp(34px, 6.4vw, 64px)/1.12 ui-serif, Georgia, \"Times New Roman\", serif; letter-spacing: -.01em; }\n  .w7cur-nav a span { display: inline-block; transform: translateY(110%); transition: transform .25s ease-in; }\n  .w7cur-open .w7cur-nav a span { transform: none; transition: transform .45s cubic-bezier(.2, .8, .2, 1) calc(var(--w7cur-speed) * .4 + var(--i) * .04s); }\n  .w7cur-nav a[aria-current=\"page\"] span::before { content: \"\"; display: inline-block; width: .3em; height: .3em; margin: 0 .3em .18em 0; border-radius: 50%; background: #f0b892; }\n  @media (hover: hover) { .w7cur-nav a:hover span { font-style: italic; } }\n  .w7cur-side { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 32px; border-top: 1px solid rgba(251, 243, 234, .35); padding-top: 16px; font-size: 14px; line-height: 1.55; opacity: 0; transition: opacity .2s; }\n  .w7cur-open .w7cur-side { opacity: 1; transition: opacity .3s ease calc(var(--w7cur-speed) * .9); }\n  .w7cur-side p { margin: 0; } .w7cur-side a { display: inline-flex; align-items: center; min-height: 40px; color: inherit; }\n  @media (prefers-reduced-motion: reduce) {\n    .w7cur-menu, .w7cur-open .w7cur-menu, .w7cur-nav a span, .w7cur-side, .w7cur-icon i { transition: none !important; }\n  }\n`; // end STYLES\n\n// When the demo opens the menu by itself (ms). Set 0 on a real site.\nconst AUTO_OPEN = 500;\nconst LINKS = [\"Home\", \"Dinner menu\", \"Wine list\", \"Private room\", \"Find us\"];\n\nexport default function TerracottaCurtainMenu() {\n  const [open, setOpen] = useState(false);\n  const [current, setCurrent] = useState(0);\n  const rootRef = useRef<HTMLDivElement>(null);\n  const btnRef = useRef<HTMLButtonElement>(null);\n  const menuRef = useRef<HTMLDivElement>(null);\n  const pageRef = useRef<HTMLDivElement>(null);\n  const used = useRef(false);\n  const focusNext = useRef<\"menu\" | \"button\" | null>(null);\n\n  useEffect(() => {\n    if (!AUTO_OPEN) return;\n    const t = window.setTimeout(() => { if (!used.current) setOpen(true); }, AUTO_OPEN);\n    return () => window.clearTimeout(t);\n  }, []);\n\n  useEffect(() => {\n    menuRef.current?.toggleAttribute(\"inert\", !open);\n    pageRef.current?.toggleAttribute(\"inert\", open); // on a real page, make main and footer inert instead\n    const target = focusNext.current;\n    focusNext.current = null;\n    if (target === \"button\") btnRef.current?.focus();\n    if (target === \"menu\") menuRef.current?.querySelector<HTMLElement>(\"a\")?.focus();\n  }, [open]);\n\n  const set = (next: boolean) => { used.current = true; focusNext.current = next ? \"menu\" : \"button\"; setOpen(next); };\n\n  const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n    if (!open) return;\n    if (e.key === \"Escape\") { e.preventDefault(); set(false); return; }\n    if (e.key !== \"Tab\" || !btnRef.current || !menuRef.current) return;\n    // focus trap: the button plus everything in the menu\n    const f = [btnRef.current, ...Array.from(menuRef.current.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\n  const choose = (e: MouseEvent<HTMLAnchorElement>, i?: number) => {\n    e.preventDefault(); // remove on a real site so the link navigates\n    if (i !== undefined) setCurrent(i);\n    set(false);\n  };\n\n  return (\n    <div\n      ref={rootRef}\n      className={`w7cur${open ? \" w7cur-open\" : \"\"}`}\n      onKeyDown={onKeyDown}\n      onPointerDown={() => { used.current = true; }}\n      onFocus={() => { used.current = true; }}\n    >\n      <style>{STYLES}</style>\n      <header className=\"w7cur-bar\">\n        <p className=\"w7cur-brand\">Osteria Calce</p>\n        <button ref={btnRef} className=\"w7cur-btn\" type=\"button\" aria-expanded={open} aria-controls=\"w7cur-menu\" onClick={() => set(!open)}>\n          <span className=\"w7cur-word\">{open ? \"Close\" : \"Menu\"}</span>\n          <span className=\"w7cur-icon\" aria-hidden=\"true\"><i /><i /></span>\n        </button>\n      </header>\n      <div ref={pageRef} className=\"w7cur-page\">\n        <div className=\"w7cur-copy\">\n          <p className=\"w7cur-eye\">Trattoria in the old bakery</p>\n          <h2 className=\"w7cur-title\">Pasta rolled by hand every morning.</h2>\n          <p className=\"w7cur-text\">Forty seats, one wood oven and a short list that follows the market. Lunch from noon, dinner until the last plate.</p>\n          <a className=\"w7cur-cta\" href=\"#\">Book a table</a>\n        </div>\n        <div className=\"w7cur-pic\">\n          <img\n            src=\"https://images.pexels.com/photos/3184191/pexels-photo-3184191.jpeg?auto=compress&cs=tinysrgb&w=1200\"\n            alt=\"A long wooden table seen from above, set with plates of pasta, bread and salads\"\n            width={1200}\n            height={801}\n            loading=\"lazy\"\n          />\n        </div>\n      </div>\n      <div ref={menuRef} className=\"w7cur-menu\" id=\"w7cur-menu\">\n        <nav className=\"w7cur-nav\" aria-label=\"Main\">\n          <ul>\n            {LINKS.map((label, i) => (\n              <li key={label} style={{ \"--i\": i } as CSSProperties}>\n                <a href=\"#\" aria-current={current === i ? \"page\" : undefined} onClick={(e) => choose(e, i)}><span>{label}</span></a>\n              </li>\n            ))}\n          </ul>\n        </nav>\n        <div className=\"w7cur-side\">\n          <p>Via del Forno 14<br />Open Tuesday to Sunday</p>\n          <p><a href=\"#\" onClick={(e) => choose(e)}>Call the restaurant</a></p>\n        </div>\n      </div>\n    </div>\n  );\n}\n"}]}
