{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"pinned-pottery-gallery-row-sliding-sideways-on-scroll","type":"registry:block","title":"Pinned Pottery Gallery Row Sliding Sideways","description":"","dependencies":[],"files":[{"path":"components/we-inc/pinned-pottery-gallery-row-sliding-sideways-on-scroll.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\n\nconst pieces = [\n  {\n    \"img\": \"https://images.pexels.com/photos/9736720/pexels-photo-9736720.jpeg?auto=compress&cs=tinysrgb&w=900\",\n    \"alt\": \"Small round pots with a deep red-brown glaze arranged on a worn wooden board\",\n    \"shape\": \"wide\",\n    \"name\": \"Ember jars\",\n    \"glaze\": \"Iron red over raw clay\",\n    \"price\": \"$38 each\"\n  },\n  {\n    \"img\": \"https://images.pexels.com/photos/15122643/pexels-photo-15122643.jpeg?auto=compress&cs=tinysrgb&w=900\",\n    \"alt\": \"A shelf of tall white ceramic vases in rounded and tapered shapes\",\n    \"shape\": \"tall\",\n    \"name\": \"Chalk vases\",\n    \"glaze\": \"Satin white, five shapes\",\n    \"price\": \"$64 to $120\"\n  },\n  {\n    \"img\": \"https://images.pexels.com/photos/8063803/pexels-photo-8063803.jpeg?auto=compress&cs=tinysrgb&w=900\",\n    \"alt\": \"Rows of unglazed white mugs with handles waiting on a studio shelf\",\n    \"shape\": \"wide\",\n    \"name\": \"Morning mugs\",\n    \"glaze\": \"Pick your glaze before firing\",\n    \"price\": \"$32\"\n  },\n  {\n    \"img\": \"https://images.pexels.com/photos/29282184/pexels-photo-29282184.jpeg?auto=compress&cs=tinysrgb&w=900\",\n    \"alt\": \"Handmade bowls in teal with a wave pattern and in burnt orange, close up in soft light\",\n    \"shape\": \"wide\",\n    \"name\": \"Tide bowls\",\n    \"glaze\": \"Teal slip, carved by hand\",\n    \"price\": \"$46\"\n  },\n  {\n    \"img\": \"https://images.pexels.com/photos/37472728/pexels-photo-37472728.jpeg?auto=compress&cs=tinysrgb&w=900\",\n    \"alt\": \"Black and white photo of a potter shaping a tall bottle at the wheel among rows of unfired pots\",\n    \"shape\": \"tall\",\n    \"name\": \"Made to order\",\n    \"glaze\": \"Commissions open in March\",\n    \"price\": \"From $90\"\n  }\n];\n\nconst css = `\n.w5pgr-root { --w5pgr-h: 600px; --w5pgr-run: 1400px; position: relative; height: var(--w5pgr-h); overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; }\n.w5pgr-root *, .w5pgr-root *::before, .w5pgr-root *::after { box-sizing: border-box; }\n.w5pgr-track { height: calc(var(--w5pgr-h) + var(--w5pgr-run)); }\n.w5pgr-stage { position: sticky; top: 0; height: var(--w5pgr-h); overflow: hidden; container-type: inline-size; }\n.w5pgr-row { position: relative; display: flex; width: max-content; will-change: transform; }\n.w5pgr-hint { position: absolute; top: 12px; left: 0; right: 0; z-index: 5; display: flex; justify-content: center; pointer-events: none; transition: opacity .4s ease; }\n.w5pgr-hint span { padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .04em; }\n.w5pgr-root[data-scrolled] .w5pgr-hint { opacity: 0; }\n@keyframes w5pgr-slide { to { transform: translateX(calc(-100% + 100cqi)); } }\n@supports (animation-timeline: view()) {\n  @media (min-width: 640px) and (prefers-reduced-motion: no-preference) {\n    .w5pgr-track { view-timeline: --w5pgr-tl block; }\n    .w5pgr-row { animation: w5pgr-slide linear both; animation-timeline: --w5pgr-tl; animation-range: contain 0% contain 100%; }\n  }\n}\n@media (max-width: 639px), (prefers-reduced-motion: reduce) {\n  .w5pgr-track { height: auto; }\n  .w5pgr-stage { position: static; height: auto; min-height: var(--w5pgr-h); overflow: visible; }\n  .w5pgr-hint { display: none; }\n  .w5pgr-row { width: auto; overflow-x: auto; scroll-snap-type: x mandatory; transform: none !important; animation: none !important; scrollbar-width: thin; scroll-padding-inline: clamp(20px, 5cqi, 64px); }\n  .w5pgr-panel { scroll-snap-align: start; }\n}\n.w5pgr-root { --w5pgr-paper: #f2ebe0; --w5pgr-rust: #9a4424; --w5pgr-img: 290px; background: var(--w5pgr-paper); color: #2b211a; font-family: ui-sans-serif, system-ui, sans-serif; scrollbar-color: #c9b9a3 transparent; }\n.w5pgr-root:focus-visible { outline: 3px solid var(--w5pgr-rust); outline-offset: -3px; }\n.w5pgr-hint span { background: #2b211a; color: #f2ebe0; }\n.w5pgr-stage { display: flex; flex-direction: column; justify-content: center; gap: 28px; }\n.w5pgr-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 0 clamp(20px, 5cqi, 64px); }\n.w5pgr-label { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--w5pgr-rust); }\n.w5pgr-title { margin: 8px 0 0; font-family: Georgia, \"Times New Roman\", serif; font-weight: 400; font-size: clamp(28px, 4.2cqi, 44px); line-height: 1.1; }\n.w5pgr-lede { margin: 10px 0 0; max-width: 46ch; font-size: 15px; line-height: 1.6; color: #5a4a3c; }\n.w5pgr-meter { display: grid; justify-items: end; gap: 10px; flex: 0 0 auto; }\n.w5pgr-count { font-size: 13px; font-weight: 600; letter-spacing: .08em; font-variant-numeric: tabular-nums; }\n.w5pgr-rule { display: block; width: 160px; height: 2px; background: #d9ccba; overflow: hidden; }\n.w5pgr-fill { display: block; height: 100%; background: var(--w5pgr-rust); transform: scaleX(0); transform-origin: 0 50%; }\n.w5pgr-row { margin: 0; padding: 0 clamp(20px, 5cqi, 64px); list-style: none; gap: 28px; align-items: flex-start; }\n.w5pgr-panel { flex: 0 0 auto; }\n.w5pgr-card { display: block; color: inherit; text-decoration: none; border-radius: 6px; }\n.w5pgr-card:focus-visible { outline: 3px solid var(--w5pgr-rust); outline-offset: 6px; }\n.w5pgr-frame { display: block; height: var(--w5pgr-img); overflow: hidden; border-radius: 4px; background: #e2d6c4; box-shadow: 0 18px 40px -28px rgba(60, 35, 15, .55); }\n.w5pgr-wide .w5pgr-frame { width: calc(var(--w5pgr-img) * 4 / 3); }\n.w5pgr-tall .w5pgr-frame { width: calc(var(--w5pgr-img) * 3 / 4); }\n.w5pgr-frame img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2, .7, .2, 1); }\n.w5pgr-card:hover img, .w5pgr-card:focus-visible img { transform: scale(1.04); }\n.w5pgr-cap { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 15px; }\n.w5pgr-name { font-weight: 600; }\n.w5pgr-price { color: #5a4a3c; font-variant-numeric: tabular-nums; }\n.w5pgr-glaze { display: block; margin-top: 4px; font-size: 13px; color: #6b5a4a; }\n.w5pgr-end { align-self: stretch; width: 260px; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 0 8px; border-left: 1px solid #d9ccba; padding-left: 28px; height: var(--w5pgr-img); }\n.w5pgr-endtext { margin: 0; font-family: Georgia, \"Times New Roman\", serif; font-size: 20px; line-height: 1.4; }\n.w5pgr-btn { align-self: flex-start; display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px; border-radius: 999px; background: #2b211a; color: #f2ebe0; font-size: 14px; font-weight: 600; text-decoration: none; }\n.w5pgr-btn:hover { background: var(--w5pgr-rust); }\n.w5pgr-btn:focus-visible { outline: 3px solid var(--w5pgr-rust); outline-offset: 3px; }\n@keyframes w5pgr-grow { to { transform: scaleX(1); } }\n@supports (animation-timeline: view()) {\n  @media (min-width: 640px) and (prefers-reduced-motion: no-preference) {\n    .w5pgr-fill { animation: w5pgr-grow linear both; animation-timeline: --w5pgr-tl; animation-range: contain 0% contain 100%; }\n  }\n}\n@media (max-width: 639px), (prefers-reduced-motion: reduce) {\n  .w5pgr-root { --w5pgr-img: 250px; }\n  .w5pgr-stage { justify-content: center; padding: 32px 0; }\n  .w5pgr-meter { display: none; }\n  .w5pgr-row { padding-bottom: 12px; }\n  .w5pgr-frame img { transition: none; }\n}\n@media (max-width: 639px) { .w5pgr-wide .w5pgr-frame { width: min(calc(var(--w5pgr-img) * 4 / 3), 78vw); } }\n`;\n\n// Same script as the HTML version. It also checks prefers-reduced-motion itself.\nfunction init(root: HTMLElement): () => void {\n  // The box scrolls itself. For page scroll: remove height and overflow from .w5pgr-root, set --w5pgr-h to 100vh,\n  // then use window scroll events and (scrollY minus the track's page top) instead of root.scrollTop.\n  var AUTO = 80; // demo scroll speed in px per second until someone scrolls; 0 turns it off\n  var $ = function (s: string): any { return root.querySelector(s); };\n  var track = $(\".w5pgr-track\"), stage = $(\".w5pgr-stage\"), row = $(\".w5pgr-row\");\n  var still = matchMedia(\"(prefers-reduced-motion: reduce), (max-width: 639px)\");\n  var css = window.CSS && CSS.supports(\"animation-timeline: view()\"); // CSS moves the row itself there\n  var af = requestAnimationFrame, caf = cancelAnimationFrame, raf = 0, demo = 0, last = 0, pos = 0, seen = true, done = !AUTO;\n  var fill = $(\".w5pgr-fill\"), count = $(\".w5pgr-count\"), n = row.querySelectorAll(\"img\").length;\n  function cl(x: number) { return Math.min(1, Math.max(0, x)) || 0; }\n  function span() { return track.offsetHeight - root.clientHeight; }\n  function shift(el: any, p: number, flat: boolean) {\n    if (!css) el.style.transform = flat ? \"\" : \"translateX(\" + -p * Math.max(0, el.offsetWidth - stage.clientWidth) + \"px)\";\n  }\n  function paint() {\n    raf = 0;\n    var p = cl((root.scrollTop - track.offsetTop) / span()), flat = still.matches;\n    root.toggleAttribute(\"data-scrolled\", root.scrollTop > 160);\n    shift(row, p, flat);\n    if (!css) fill.style.transform = flat ? \"\" : \"scaleX(\" + p + \")\";\n    count.textContent = \"0\" + (Math.round(p * (n - 1)) + 1) + \" / 0\" + n;\n  }\n  function queue() { if (!raf) raf = af(paint); }\n  function step(now: number) {\n    var dt = last ? Math.min(now - last, 50) : 0;\n    last = now;\n    pos += (AUTO * dt) / 1000;\n    if (pos >= root.scrollHeight - root.clientHeight) { done = true; demo = 0; return; }\n    root.scrollTop = pos;\n    demo = af(step);\n  }\n  function start() { if (!done && seen && !demo && !still.matches) { last = 0; pos = root.scrollTop; demo = af(step); } }\n  function stop() { caf(demo); demo = 0; }\n  function hand() { done = true; stop(); }\n  // Tabbing to a card off to the side scrolls the box to the point where that card is in view.\n  function focusIn(e: any) {\n    var card = e.target.closest(\".w5pgr-panel\");\n    stage.scrollLeft = 0;\n    if (!card || still.matches) return;\n    hand();\n    var w = stage.clientWidth;\n    root.scrollTop = track.offsetTop + span() * cl((card.offsetLeft - (w - card.offsetWidth) / 2) / (row.offsetWidth - w));\n  }\n  var ac = new AbortController(), o = { passive: true, signal: ac.signal };\n  var io = new IntersectionObserver(function (e) { seen = e[0].isIntersecting; seen ? start() : stop(); });\n  io.observe(root);\n  [\"wheel\", \"touchstart\", \"pointerdown\", \"keydown\"].forEach(function (ev) { root.addEventListener(ev, hand, o); });\n  root.addEventListener(\"scroll\", queue, o);\n  row.addEventListener(\"focusin\", focusIn, o);\n  row.addEventListener(\"scroll\", queue, o);\n  window.addEventListener(\"resize\", queue, o);\n  paint();\n  start();\n  return function () {\n    stop();\n    caf(raf);\n    io.disconnect();\n    ac.abort();\n\n  };\n}\n\nexport default function PinnedPotteryGalleryRowSlidingSidewaysOnScroll() {\n  const ref = useRef<HTMLElement>(null);\n  useEffect(() => (ref.current ? init(ref.current) : undefined), []);\n  return (\n    <section ref={ref} className=\"w5pgr-root\" data-w5pgr tabIndex=\"0\" aria-label=\"Ember series gallery, scroll to move sideways\">\n    <style>{css}</style>\n      <div className=\"w5pgr-track\">\n        <div className=\"w5pgr-stage\">\n          <div className=\"w5pgr-hint\" aria-hidden=\"true\"><span>Scroll inside</span></div>\n          <div className=\"w5pgr-head\">\n            <div>\n              <p className=\"w5pgr-label\">Halden Clay Works</p>\n              <h2 className=\"w5pgr-title\">The Ember series</h2>\n              <p className=\"w5pgr-lede\">Thrown, trimmed and fired in our back room kiln. Each piece is a little different from the photo.</p>\n            </div>\n            <div className=\"w5pgr-meter\" aria-hidden=\"true\">\n              <span className=\"w5pgr-count\">01 / 05</span>\n              <span className=\"w5pgr-rule\"><span className=\"w5pgr-fill\"></span></span>\n            </div>\n          </div>\n          <ul className=\"w5pgr-row\" role=\"list\">\n            {pieces.map((it, i) => (\n    <li key={i} className={`w5pgr-panel w5pgr-${it.shape}`}>\n              <a href=\"#\" className=\"w5pgr-card\">\n                <span className=\"w5pgr-frame\"><img src={it.img} alt={it.alt} width=\"900\" height=\"675\" loading=\"eager\" /></span>\n                <span className=\"w5pgr-cap\"><span className=\"w5pgr-name\">{it.name}</span><span className=\"w5pgr-price\">{it.price}</span></span>\n                <span className=\"w5pgr-glaze\">{it.glaze}</span>\n              </a>\n            </li>\n    ))}\n            <li className=\"w5pgr-panel w5pgr-end\">\n              <p className=\"w5pgr-endtext\">Open studio every Saturday, 10 to 4. Pick pieces off the shelf and see the next firing.</p>\n              <a href=\"#\" className=\"w5pgr-btn\">Plan a visit</a>\n            </li>\n          </ul>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
