{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"flower-words-in-a-sentence-opening-photo-windows","type":"registry:block","title":"Flower Words Opening Photo Windows","description":"","dependencies":[],"files":[{"path":"components/we-inc/flower-words-in-a-sentence-opening-photo-windows.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\n\nconst DELAY = 1900; // ms between idle reveals while nobody is pointing or tabbing\n\nconst stems = [\n  { word: \"peonies\", img: \"https://images.pexels.com/photos/36399727/pexels-photo-36399727.jpeg?auto=compress&cs=tinysrgb&w=400\", alt: \"A bunch of pink peonies wrapped in black paper\" },\n  { word: \"eucalyptus\", img: \"https://images.pexels.com/photos/1026237/pexels-photo-1026237.jpeg?auto=compress&cs=tinysrgb&w=400\", alt: \"Round silver-green eucalyptus leaves on their branches\" },\n  { word: \"ranunculus\", img: \"https://images.pexels.com/photos/7409746/pexels-photo-7409746.jpeg?auto=compress&cs=tinysrgb&w=400\", alt: \"Pale pink ranunculus gathered in a grey metal pail\" },\n];\n\nconst css = `\n.w8flo-hold { position: relative; display: inline-block; }\n.w8flo-word { color: #f3ead7; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; text-decoration-color: #c9a96a; font-style: italic; border-radius: 4px; outline: none; }\n.w8flo-word:focus-visible { outline: 2px solid #c9a96a; outline-offset: 4px; }\n.w8flo-pop { position: absolute; z-index: 3; left: 50%; bottom: calc(100% + 12px); width: 176px; margin-left: -88px; padding: 6px; border-radius: 12px; background: #f3ead7; opacity: 0; transform: translateY(14px) scale(.94); transform-origin: 50% 100%; transition: opacity .3s ease, transform .55s cubic-bezier(.2,.9,.25,1.15); pointer-events: none; box-shadow: 0 24px 40px -18px rgba(0,0,0,.6); }\n.w8flo-mask { display: block; overflow: hidden; aspect-ratio: 4 / 3; border-radius: 8px; background: #2c4236; }\n.w8flo-img { display: block; width: 100%; height: 100%; object-fit: cover; transform: translateY(100%) scale(1.2); transition: transform .7s cubic-bezier(.2,.8,.2,1); }\n.w8flo-hold[data-on] .w8flo-pop, .w8flo-hold:hover .w8flo-pop, .w8flo-hold:focus-within .w8flo-pop { opacity: 1; transform: none; }\n.w8flo-hold[data-on] .w8flo-img, .w8flo-hold:hover .w8flo-img, .w8flo-hold:focus-within .w8flo-img { transform: none; }\n.w8flo-strip { display: none; }\n@media (max-width: 767px) {\n  .w8flo-pop { display: none; }\n  .w8flo-strip { display: grid; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .w8flo-pop { display: none; }\n  .w8flo-strip { display: grid; }\n}\n`;\n\nexport default function FlowerWordsInASentenceOpeningPhotoWindows() {\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) % stems.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  const word = (i: number) => (\n    <span className=\"w8flo-hold\" data-on={on === i ? \"\" : undefined}>\n      <a href=\"#\" className=\"w8flo-word\">{stems[i].word}</a>\n      <span className=\"w8flo-pop\" aria-hidden=\"true\">\n        <span className=\"w8flo-mask\">\n          <img className=\"w8flo-img\" src={stems[i].img} alt=\"\" width={400} height={300} loading=\"lazy\" decoding=\"async\" />\n        </span>\n      </span>\n    </span>\n  );\n\n  return (\n    <section ref={root} className=\"bg-[#1f2f27] px-5 pb-16 pt-16 text-[#e6dcc6] md:pt-48\">\n      <style>{css}</style>\n      <div className=\"mx-auto max-w-3xl\">\n        <p className=\"text-xs font-semibold uppercase tracking-[0.3em] text-[#c9a96a]\">Mossgate Flowers, Tuesday stock</p>\n        <h2 className=\"mt-5 font-serif text-3xl leading-snug sm:text-5xl sm:leading-tight\">\n          This week the counter holds {word(0)} wrapped in black paper, {word(1)} cut by the bunch, and {word(2)} in tin pails.\n        </h2>\n        <div className=\"w8flo-strip mt-8 grid-cols-3 gap-3\">\n          {stems.map((s) => (\n            <figure key={s.word}>\n              <img className=\"aspect-[4/3] w-full rounded-lg object-cover\" src={s.img} alt={s.alt} width={400} height={300} loading=\"lazy\" decoding=\"async\" />\n              <figcaption className=\"mt-2 text-sm text-[#cfc4ab]\">{s.word}</figcaption>\n            </figure>\n          ))}\n        </div>\n        <p className=\"mt-10 max-w-md text-base text-[#cfc4ab]\">Each name links to the stems on the counter and the colours they come in.</p>\n      </div>\n    </section>\n  );\n}\n"}]}
