{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"tea-cards-with-a-circle-opening-to-the-cup","type":"registry:block","title":"Tea Cards With A Circle Opening To The Cup","description":"","dependencies":[],"files":[{"path":"components/we-inc/tea-cards-with-a-circle-opening-to-the-cup.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\n\nconst DELAY = 2100; // ms between idle swaps while nobody is pointing or tabbing\n\nconst teas = [\n  { name: \"Sencha\", origin: \"Steamed green, light and grassy\", price: \"$14 / 50 g\",\n    leaf: { src: \"https://images.pexels.com/photos/8329977/pexels-photo-8329977.jpeg?auto=compress&cs=tinysrgb&w=600\", alt: \"Dark twisted green tea leaves in a glass jar with a wooden scoop\" },\n    cup: { src: \"https://images.pexels.com/photos/5946681/pexels-photo-5946681.jpeg?auto=compress&cs=tinysrgb&w=600\", alt: \"Green tea poured into a small celadon cup on a saucer\" } },\n  { name: \"Highland black\", origin: \"Malty, dark, good with milk\", price: \"$12 / 50 g\",\n    leaf: { src: \"https://images.pexels.com/photos/8329983/pexels-photo-8329983.jpeg?auto=compress&cs=tinysrgb&w=600\", alt: \"Loose black tea leaves spilling from a tipped glass jar\" },\n    cup: { src: \"https://images.pexels.com/photos/1493080/pexels-photo-1493080.jpeg?auto=compress&cs=tinysrgb&w=600\", alt: \"Deep red black tea steaming in a tulip glass on a saucer\" } },\n  { name: \"Jasmine green\", origin: \"Green leaf layered with blossom\", price: \"$16 / 50 g\",\n    leaf: { src: \"https://images.pexels.com/photos/8330328/pexels-photo-8330328.jpeg?auto=compress&cs=tinysrgb&w=600\", alt: \"A scattered pile of curled green tea leaves on linen\" },\n    cup: { src: \"https://images.pexels.com/photos/7138780/pexels-photo-7138780.jpeg?auto=compress&cs=tinysrgb&w=600\", alt: \"Golden tea in a glass cup beside fresh white jasmine flowers\" } },\n];\n\nconst css = `\n.w8tea-frame { position: relative; overflow: hidden; aspect-ratio: 1 / 1; border-radius: 18px; background: #d9ccb4; }\n.w8tea-base { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }\n.w8tea-lens { position: absolute; left: -25%; top: -25%; width: 150%; height: 150%; border-radius: 50%; overflow: hidden; opacity: 0; transform: scale(.08); transition: transform .8s cubic-bezier(.65,0,.25,1), opacity .25s ease; }\n.w8tea-lens img { position: absolute; left: 16.667%; top: 16.667%; width: 66.667%; height: 66.667%; max-width: none; object-fit: cover; transform: scale(12.5); transition: transform .8s cubic-bezier(.65,0,.25,1); }\n.w8tea-tag { position: absolute; right: 12px; top: 12px; height: 28px; overflow: hidden; border-radius: 999px; background: rgba(250,246,238,.92); color: #2f2a22; font-size: 12px; font-weight: 600; letter-spacing: .04em; }\n.w8tea-tag span { display: block; height: 28px; line-height: 28px; padding: 0 11px; transition: transform .5s cubic-bezier(.65,0,.25,1); }\n.w8tea-card[data-on] .w8tea-lens { opacity: 1; transform: none; }\n.w8tea-card[data-on] .w8tea-lens img { transform: none; }\n.w8tea-card[data-on] .w8tea-tag span { transform: translateY(-100%); }\n@media (hover: hover) and (pointer: fine) {\n  .w8tea-card:hover .w8tea-lens { opacity: 1; transform: none; }\n  .w8tea-card:hover .w8tea-lens img { transform: none; }\n  .w8tea-card:hover .w8tea-tag span { transform: translateY(-100%); }\n}\n.w8tea-btn:focus-visible, .w8tea-link:focus-visible { outline: 2px solid #2f2a22; outline-offset: 3px; }\n@media (prefers-reduced-motion: reduce) { .w8tea-lens, .w8tea-lens img, .w8tea-tag span { transition: none; } }\n`;\n\nexport default function TeaCardsWithACircleOpeningToTheCup() {\n  const root = useRef<HTMLElement>(null);\n  const [on, setOn] = useState<boolean[]>([true, false, false]);\n  const live = useRef(true);\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, step = 0;\n    const run = () => {\n      window.clearInterval(timer);\n      timer = 0;\n      if (live.current && visible) timer = window.setInterval(() => { step = (step + 1) % 6; setOn(teas.map((_, k) => step === k * 2)); }, DELAY);\n    };\n    // a real mouse or the keyboard takes over from the idle demo\n    const stop = () => { if (!live.current) return; live.current = false; setOn(teas.map(() => false)); 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 toggle = (i: number) => {\n    live.current = false;\n    setOn((cur) => cur.map((v, k) => (k === i ? !v : v)));\n  };\n\n  return (\n    <section ref={root} className=\"bg-[#ece3d3] px-5 py-16 text-[#2f2a22] sm:py-20\">\n      <style>{css}</style>\n      <div className=\"mx-auto max-w-5xl\">\n        <p className=\"text-xs font-semibold uppercase tracking-[0.3em] text-[#7d5b2e]\">Oldmill Tea Room</p>\n        <h2 className=\"mt-3 font-serif text-3xl sm:text-4xl\">From the tin to the cup</h2>\n        <p className=\"mt-3 max-w-md text-base text-[#5a5042]\">Each card shows the dry leaf. Hover it, or press the cup button, to see how it pours.</p>\n        <div className=\"mt-10 grid gap-8 sm:grid-cols-3\">\n          {teas.map((t, i) => (\n            <article key={t.name} className=\"w8tea-card\" data-on={on[i] ? \"\" : undefined}>\n              <div className=\"w8tea-frame\">\n                <img className=\"w8tea-base\" src={t.leaf.src} alt={t.leaf.alt} width={600} height={600} loading=\"lazy\" decoding=\"async\" />\n                <span className=\"w8tea-lens\"><img src={t.cup.src} alt={t.cup.alt} width={600} height={600} loading=\"lazy\" decoding=\"async\" /></span>\n                <span className=\"w8tea-tag\" aria-hidden=\"true\"><span>Dry leaf</span><span>In the cup</span></span>\n              </div>\n              <div className=\"mt-4 flex items-start justify-between gap-3\">\n                <div>\n                  <h3 className=\"font-serif text-xl\"><a href=\"#\" className=\"w8tea-link rounded\">{t.name}</a></h3>\n                  <p className=\"mt-1 text-sm text-[#5a5042]\">{t.origin}</p>\n                  <p className=\"mt-1 text-sm font-medium\">{t.price}</p>\n                </div>\n                <button type=\"button\" className=\"w8tea-btn h-10 shrink-0 rounded-full bg-[#2f2a22] px-4 text-sm font-medium text-[#f6efe2] hover:bg-[#463e33]\" aria-pressed={on[i]} onClick={() => toggle(i)}>\n                  {on[i] ? \"Show leaf\" : \"Show cup\"}\n                </button>\n              </div>\n            </article>\n          ))}\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
