{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"product-photo-scales-to-full-bleed-on-scroll","type":"registry:block","title":"Product Photo Scales to Full Bleed","description":"","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/product-photo-scales-to-full-bleed-on-scroll.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n// Same markup, styles and script as the plain HTML version. The CSS comments name the values to change.\nconst STYLES = `\n  /* Change these: --w7scl-from (starting scale), --w7scl-bg, --w7scl-ink, --w7scl-brass, and .w7scl-stage height. */\n  .w7scl { --w7scl-from: .42; --w7scl-bg: #1c1d20; --w7scl-ink: #ecebe7; --w7scl-brass: #d2ad74;\n    position: relative; height: 640px; overflow-y: auto; overflow-x: hidden; background: var(--w7scl-bg); color: var(--w7scl-ink);\n    font-family: ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif; scrollbar-color: #3a3c41 transparent; }\n  /* To run on page scroll: delete height and overflow above (view() then follows the page) and read the window in the fallback. */\n  .w7scl:focus-visible { outline: 3px solid var(--w7scl-brass); outline-offset: -3px; }\n  .w7scl-hint { position: sticky; top: 0; height: 0; z-index: 3; display: flex; justify-content: flex-end; pointer-events: none; }\n  .w7scl-hint span { margin: 14px 14px 0 0; padding: 5px 12px; border-radius: 999px; background: rgba(236,235,231,.12); font-size: 12px; transition: opacity .5s; }\n  .w7scl[data-touched] .w7scl-hint span { opacity: 0; }\n  .w7scl-wrap { max-width: 60rem; margin: 0 auto; padding: 52px 20px 36px; text-align: center; }\n  .w7scl-eye { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--w7scl-brass); }\n  .w7scl-h { margin: 12px 0 0; font-size: clamp(2.2rem, 5.6vw, 4rem); font-weight: 600; letter-spacing: -.035em; line-height: 1.02; }\n  .w7scl-p { margin: 16px auto 0; max-width: 32rem; font-size: 16px; line-height: 1.6; color: #b9b8b2; }\n  .w7scl-price { margin: 18px 0 0; font-size: 18px; font-weight: 600; }\n  .w7scl-price span { margin-left: 10px; font-size: 14px; font-weight: 400; color: #a9a8a2; }\n  .w7scl-stage { height: min(560px, 75vw); padding: 0; }\n  .w7scl-frame { position: relative; height: 100%; margin: 0; overflow: hidden; border-radius: 14px; transform: scale(var(--w7scl-from)); transform-origin: 50% 40%; background: #2a2b2f; box-shadow: 0 30px 60px -30px rgba(0,0,0,.6); }\n  .w7scl-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }\n  .w7scl-cap { position: absolute; left: 20px; bottom: 18px; max-width: 22rem; padding: 10px 14px; border-radius: 8px; background: rgba(28,29,32,.82); font-size: 14px; line-height: 1.45; opacity: 0; }\n  .w7scl-after { padding-top: 40px; padding-bottom: 72px; }\n  .w7scl-spec { display: grid; gap: 1px; margin: 0; background: rgba(236,235,231,.14); border: 1px solid rgba(236,235,231,.14); border-radius: 10px; overflow: hidden; text-align: left; }\n  .w7scl-spec div { padding: 16px 18px; background: var(--w7scl-bg); }\n  .w7scl-spec dt { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: #a9a8a2; }\n  .w7scl-spec dd { margin: 6px 0 0; font-size: 16px; }\n  .w7scl-btn { display: inline-flex; align-items: center; min-height: 48px; margin-top: 32px; padding: 0 26px; border-radius: 999px; background: var(--w7scl-ink); color: var(--w7scl-bg); font-weight: 600; font-size: 15px; text-decoration: none; }\n  .w7scl-btn:hover { background: #fff; }\n  .w7scl-btn:focus-visible { outline: 3px solid var(--w7scl-brass); outline-offset: 3px; }\n  @media (min-width: 720px) { .w7scl-spec { grid-template-columns: repeat(3, 1fr); } }\n  .w7scl[data-fb] .w7scl-cap { transition: opacity .4s ease; }\n  @keyframes w7scl-grow { to { transform: scale(1); } }\n  @keyframes w7scl-show { to { opacity: 1; } }\n  /* Full size when the frame is centred in the box (cover 50%). */\n  @supports (animation-timeline: view()) {\n    .w7scl:not([data-fb]) .w7scl-stage { view-timeline: --w7scl-v block; }\n    .w7scl:not([data-fb]) .w7scl-frame { animation: w7scl-grow linear both; animation-timeline: --w7scl-v; animation-range: cover 22% cover 50%; }\n    .w7scl:not([data-fb]) .w7scl-cap { animation: w7scl-show linear both; animation-timeline: --w7scl-v; animation-range: cover 46% cover 56%; }\n  }\n  @media (prefers-reduced-motion: reduce) {\n    .w7scl .w7scl-frame { animation: none !important; transform: none !important; }\n    .w7scl .w7scl-cap { animation: none !important; opacity: 1 !important; }\n  }\n`;\n\nexport default function ProductPhotoScalesToFullBleedOnScroll() {\n  const rootRef = useRef<any>(null);\n  const prefersReduced = useReducedMotion();\n\n  useEffect(() => {\n    const root: any = rootRef.current;\n    if (!root) return;\n    const off: Array<() => void> = [];\n    \n      var SPEED = 32; // px per second of demo scroll before anyone touches the box; 0 turns it off\n      var reduce = matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n      var frame = 0, last = 0, pos = 0, seen = true, done = reduce || !SPEED;\n      function step(t) {\n        var dt = last ? Math.min(t - last, 50) : 0;\n        last = t; pos += SPEED * dt / 1000;\n        if (pos >= root.scrollHeight - root.clientHeight) pos = 0;\n        root.scrollTop = pos;\n        frame = requestAnimationFrame(step);\n      }\n      function play() { if (!done && seen && !frame) { last = 0; frame = requestAnimationFrame(step); } }\n      function stop() { cancelAnimationFrame(frame); frame = 0; }\n      function hand() { done = true; stop(); root.setAttribute(\"data-touched\", \"\"); }\n      [\"wheel\", \"touchstart\", \"pointerdown\", \"keydown\"].forEach(function (n) {\n        root.addEventListener(n, hand, { passive: true });\n        off.push(function () { root.removeEventListener(n, hand); });\n      });\n      var vis = new IntersectionObserver(function (e) { seen = e[0].isIntersecting; if (seen) play(); else stop(); });\n      vis.observe(root);\n      off.push(stop, function () { vis.disconnect(); });\n      play();\n      // Fallback: the same scale curve worked out from the frame's position, once per frame while scrolling.\n      if (reduce || (window.CSS && CSS.supports(\"animation-timeline: view()\"))) return;\n      root.setAttribute(\"data-fb\", \"\");\n      var stage = root.querySelector(\".w7scl-stage\"), fig = root.querySelector(\".w7scl-frame\"), cap = root.querySelector(\".w7scl-cap\"), raf = 0;\n      var from = parseFloat(getComputedStyle(root).getPropertyValue(\"--w7scl-from\")) || .42;\n      function draw() {\n        raf = 0;\n        var r = stage.getBoundingClientRect(), b = root.getBoundingClientRect();\n        var p = Math.min(1, Math.max(0, ((b.bottom - r.top) / (b.height + r.height) - .22) / .28));\n        fig.style.transform = \"scale(\" + (from + (1 - from) * p).toFixed(4) + \")\";\n        cap.style.opacity = p > .95 ? 1 : 0;\n      }\n      function onScroll() { if (!raf) raf = requestAnimationFrame(draw); }\n      root.addEventListener(\"scroll\", onScroll, { passive: true });\n      draw();\n      off.push(function () { root.removeEventListener(\"scroll\", onScroll); cancelAnimationFrame(raf); fig.style.transform = \"\"; cap.style.opacity = \"\"; root.removeAttribute(\"data-fb\"); });\n    return () => off.forEach((f) => f());\n  }, [prefersReduced]);\n\n  return (\n    <section className=\"w7scl\" data-w7scl=\"\" ref={rootRef} tabIndex={0} aria-label=\"Orrin Lighting, the Orrin task lamp, scrollable\">\n      <style>{STYLES}</style>\n      <div className=\"w7scl-hint\" aria-hidden=\"true\"><span>Scroll inside</span></div>\n      <div className=\"w7scl-wrap\">\n        <p className=\"w7scl-eye\">Orrin Lighting</p>\n        <h2 className=\"w7scl-h\">The Orrin task lamp</h2>\n        <p className=\"w7scl-p\">A folded steel arm that holds any angle without a knob to tighten, and a shade shaped to keep light on the page and out of your eyes.</p>\n        <p className=\"w7scl-price\">£185 <span>Matte black or bone</span></p>\n      </div>\n      <div className=\"w7scl-stage\">\n        <figure className=\"w7scl-frame\">\n          <img src=\"https://images.pexels.com/photos/7439754/pexels-photo-7439754.jpeg?auto=compress&cs=tinysrgb&w=1600\" alt=\"Three matte black task lamps with angled arms lined up along a long white desk\" width=\"1600\" height=\"1067\" loading=\"eager\" />\n          <figcaption className=\"w7scl-cap\">Powder-coated steel, a linen cable and a dimmer in the base.</figcaption>\n        </figure>\n      </div>\n      <div className=\"w7scl-wrap w7scl-after\">\n        <dl className=\"w7scl-spec\">\n          <div><dt>Height</dt><dd>52 cm at full reach</dd></div>\n          <div><dt>Light</dt><dd>Warm LED, 2700 K</dd></div>\n          <div><dt>Cable</dt><dd>2 m, linen wrapped</dd></div>\n        </dl>\n        <a className=\"w7scl-btn\" href=\"#\">Reserve one from the next batch</a>\n      </div>\n    </section>\n  );\n}\n"}]}
