{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"bakery-menu-rows-with-photo-rising-through-a-mask","type":"registry:block","title":"Bakery Menu Rows With Rising Photo","description":"","dependencies":[],"files":[{"path":"components/we-inc/bakery-menu-rows-with-photo-rising-through-a-mask.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\n\nconst DELAY = 1800; // ms between idle reveals while nobody is pointing or tabbing\n\nconst loaves = [\n  { name: \"Country sourdough\", note: \"Two-day ferment, dark crust, open crumb\", price: \"$9\", img: \"https://images.pexels.com/photos/28354523/pexels-photo-28354523.jpeg?auto=compress&cs=tinysrgb&w=400\", alt: \"A floured sourdough loaf on a board beside a scoop of wheat grains\" },\n  { name: \"Butter croissants\", note: \"Laminated by hand, baked at six\", price: \"$4\", img: \"https://images.pexels.com/photos/20002837/pexels-photo-20002837.jpeg?auto=compress&cs=tinysrgb&w=400\", alt: \"Golden croissants cooling on a wire rack\" },\n  { name: \"Cinnamon rolls\", note: \"Rolled with brown butter, sugared at nine\", price: \"$5\", img: \"https://images.pexels.com/photos/8651023/pexels-photo-8651023.jpeg?auto=compress&cs=tinysrgb&w=400\", alt: \"Cinnamon rolls dusted with sugar on a wooden tray\" },\n  { name: \"Long baguettes\", note: \"Thin crackling crust, out twice a day\", price: \"$4\", img: \"https://images.pexels.com/photos/30826793/pexels-photo-30826793.jpeg?auto=compress&cs=tinysrgb&w=400\", alt: \"Baguettes standing in paper sleeves in a bakery basket\" },\n];\n\nconst css = `\n.w8bak { --w8bak-win: 188px; }\n.w8bak-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px 4px; border-top: 1px solid #d9ccb6; color: inherit; text-decoration: none; outline: none; }\n.w8bak-list li:last-child .w8bak-row { border-bottom: 1px solid #d9ccb6; }\n.w8bak-text { transition: transform .5s cubic-bezier(.2,.8,.2,1); }\n.w8bak-win { position: absolute; z-index: 2; right: 64px; top: 50%; margin-top: calc(var(--w8bak-win) / -3); width: var(--w8bak-win); aspect-ratio: 3 / 2; border-radius: 10px; overflow: hidden; background: #e4d8c3; opacity: 0; transform: translateX(24px) rotate(3deg); transition: opacity .35s ease, transform .6s cubic-bezier(.2,.8,.2,1); pointer-events: none; box-shadow: 0 18px 34px -16px rgba(60,40,20,.6); }\n.w8bak-img { display: block; width: 100%; height: 100%; object-fit: cover; transform: translateY(100%) scale(1.25); transition: transform .7s cubic-bezier(.2,.8,.2,1); }\n.w8bak-arrow { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; border: 1px solid #cdbda3; color: #7a3e1d; transition: transform .5s cubic-bezier(.2,.8,.2,1); }\n.w8bak-row[data-on] .w8bak-win, .w8bak-row:hover .w8bak-win, .w8bak-row:focus-visible .w8bak-win { opacity: 1; transform: rotate(-2deg); }\n.w8bak-row[data-on] .w8bak-img, .w8bak-row:hover .w8bak-img, .w8bak-row:focus-visible .w8bak-img { transform: none; }\n.w8bak-row[data-on] .w8bak-text, .w8bak-row:hover .w8bak-text, .w8bak-row:focus-visible .w8bak-text { transform: translateX(10px); }\n.w8bak-row[data-on] .w8bak-arrow, .w8bak-row:hover .w8bak-arrow, .w8bak-row:focus-visible .w8bak-arrow { transform: rotate(-45deg); }\n.w8bak-row:focus-visible { box-shadow: 0 0 0 2px #f4ede1, 0 0 0 4px #7a3e1d; border-radius: 6px; }\n@media (max-width: 640px) {\n  .w8bak-row { gap: 16px; padding: 16px 0; }\n  .w8bak-name { font-size: 20px; }\n}\n@media (max-width: 640px), (prefers-reduced-motion: reduce) {\n  .w8bak-win { position: relative; right: auto; top: auto; margin: 0; flex: none; width: 112px; opacity: 1; transform: none; transition: none; box-shadow: none; }\n  .w8bak-img { transform: none; transition: none; }\n  .w8bak-row .w8bak-text { transform: none; transition: none; }\n  .w8bak-arrow { display: none; }\n}\n`;\n\nexport default function BakeryMenuRowsWithPhotoRisingThroughAMask() {\n  const root = useRef<HTMLElement>(null);\n  const [on, setOn] = useState(0);\n\n  useEffect(() => {\n    const el = root.current;\n    if (!el || window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    let timer = 0, visible = true, live = true;\n    const run = () => {\n      window.clearInterval(timer);\n      timer = 0;\n      if (live && visible) timer = window.setInterval(() => setOn((n) => (n + 1) % loaves.length), DELAY);\n    };\n    // a real mouse or keyboard takes over from the idle demo\n    const stop = () => { live = false; setOn(-1); run(); };\n    const enter = (e: PointerEvent) => { if (e.pointerType === \"mouse\") stop(); };\n    const io = new IntersectionObserver(([en]) => { visible = en.isIntersecting; run(); });\n    io.observe(el);\n    el.addEventListener(\"pointerenter\", enter);\n    el.addEventListener(\"focusin\", stop);\n    run();\n    return () => {\n      window.clearInterval(timer);\n      io.disconnect();\n      el.removeEventListener(\"pointerenter\", enter);\n      el.removeEventListener(\"focusin\", stop);\n    };\n  }, []);\n\n  return (\n    <section ref={root} className=\"w8bak bg-[#f4ede1] px-5 py-16 text-[#2b1d12] sm:py-20\">\n      <style>{css}</style>\n      <div className=\"mx-auto max-w-3xl\">\n        <p className=\"text-xs font-semibold uppercase tracking-[0.28em] text-[#7a3e1d]\">Fernhill Bakehouse</p>\n        <h2 className=\"mt-3 font-serif text-3xl leading-tight sm:text-4xl\">Out of the oven this morning</h2>\n        <p className=\"mt-3 max-w-md text-base text-[#5c4632]\">Point at a loaf to see it. Each row opens the full counter list for that bake.</p>\n        <ul className=\"w8bak-list mt-10\">\n          {loaves.map((l, i) => (\n            <li key={l.name}>\n              <a href=\"#\" className=\"w8bak-row\" data-on={on === i ? \"\" : undefined}>\n                <span className=\"w8bak-text block\">\n                  <span className=\"flex items-baseline gap-3\">\n                    <span className=\"w8bak-name font-serif text-2xl\">{l.name}</span>\n                    <span className=\"text-sm font-semibold text-[#7a3e1d]\">{l.price}</span>\n                  </span>\n                  <span className=\"mt-1 block text-sm text-[#5c4632]\">{l.note}</span>\n                </span>\n                <span className=\"w8bak-win\">\n                  <img className=\"w8bak-img\" src={l.img} alt={l.alt} width={400} height={267} loading=\"lazy\" decoding=\"async\" />\n                </span>\n                <span className=\"w8bak-arrow\" aria-hidden=\"true\">\n                  <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"M5 12h14M13 6l6 6-6 6\" /></svg>\n                </span>\n              </a>\n            </li>\n          ))}\n        </ul>\n      </div>\n    </section>\n  );\n}\n"}]}
