{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"snap-photo-strip-with-centre-card-growing","type":"registry:block","title":"Snap Photo Strip with Centre Card Growing","description":"","dependencies":[],"files":[{"path":"components/we-inc/snap-photo-strip-with-centre-card-growing.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\n\nconst homes = [\n  {\n    \"img\": \"https://images.pexels.com/photos/27390890/pexels-photo-27390890.jpeg?auto=compress&cs=tinysrgb&w=700\",\n    \"alt\": \"A small stone cottage with a turf roof above a rocky shore under an evening sky\",\n    \"name\": \"The Bothy\",\n    \"place\": \"Carrick Point\",\n    \"sleeps\": \"Sleeps 2\",\n    \"price\": \"from $140 a night\"\n  },\n  {\n    \"img\": \"https://images.pexels.com/photos/38235551/pexels-photo-38235551.jpeg?auto=compress&cs=tinysrgb&w=700\",\n    \"alt\": \"A white house on a grassy dune above a pebble beach and grey sea\",\n    \"name\": \"Dune House\",\n    \"place\": \"Hessel Bay\",\n    \"sleeps\": \"Sleeps 6\",\n    \"price\": \"from $260 a night\"\n  },\n  {\n    \"img\": \"https://images.pexels.com/photos/5823211/pexels-photo-5823211.jpeg?auto=compress&cs=tinysrgb&w=700\",\n    \"alt\": \"A lone house on top of a dark green hill above a quiet shore\",\n    \"name\": \"Hill End\",\n    \"place\": \"Morrow Head\",\n    \"sleeps\": \"Sleeps 4\",\n    \"price\": \"from $190 a night\"\n  },\n  {\n    \"img\": \"https://images.pexels.com/photos/6916146/pexels-photo-6916146.jpeg?auto=compress&cs=tinysrgb&w=700\",\n    \"alt\": \"A pale yellow house with a red roof on rocks, lit by a pink sunset\",\n    \"name\": \"Signal Cottage\",\n    \"place\": \"Ness Harbour\",\n    \"sleeps\": \"Sleeps 4\",\n    \"price\": \"from $210 a night\"\n  },\n  {\n    \"img\": \"https://images.pexels.com/photos/36707272/pexels-photo-36707272.jpeg?auto=compress&cs=tinysrgb&w=700\",\n    \"alt\": \"A red wooden boathouse at the edge of a still lake below misty green hills\",\n    \"name\": \"The Boathouse\",\n    \"place\": \"Lake Ferrin\",\n    \"sleeps\": \"Sleeps 2\",\n    \"price\": \"from $150 a night\"\n  },\n  {\n    \"img\": \"https://images.pexels.com/photos/19680864/pexels-photo-19680864.jpeg?auto=compress&cs=tinysrgb&w=700\",\n    \"alt\": \"A farmhouse among cypress trees on rolling green fields in morning mist\",\n    \"name\": \"Upper Fold Farm\",\n    \"place\": \"Calder Vale\",\n    \"sleeps\": \"Sleeps 8\",\n    \"price\": \"from $320 a night\"\n  }\n];\n\nconst css = `\n.w5ctr-root { --w5ctr-clay: #7b3421; --w5ctr-card: 280px; --w5ctr-small: .84; padding: 52px 0 40px; background: var(--w5ctr-clay); color: #fbefe4; font-family: ui-sans-serif, system-ui, sans-serif; overflow: hidden; }\n.w5ctr-root *, .w5ctr-root *::before { box-sizing: border-box; }\n.w5ctr-head { padding: 0 20px; text-align: center; }\n.w5ctr-label { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #f4c8a8; }\n.w5ctr-title { margin: 8px 0 0; font-family: Georgia, \"Times New Roman\", serif; font-weight: 400; font-size: clamp(28px, 4vw, 40px); line-height: 1.12; }\n.w5ctr-row { display: flex; gap: 8px; margin: 26px 0 0; padding: 10px calc(50% - var(--w5ctr-card) / 2) 14px; list-style: none; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }\n.w5ctr-row::-webkit-scrollbar { display: none; }\n.w5ctr-row:focus-visible { outline: 3px solid #f4c8a8; outline-offset: -3px; }\n.w5ctr-card { flex: 0 0 var(--w5ctr-card); scroll-snap-align: center; view-timeline: --w5ctr-card inline; }\n.w5ctr-in { display: block; color: inherit; text-decoration: none; text-align: center; border-radius: 16px; transform: scale(var(--w5ctr-small)); will-change: transform; }\n.w5ctr-in:focus-visible { outline: 3px solid #f4c8a8; outline-offset: 6px; }\n.w5ctr-photo { position: relative; display: block; aspect-ratio: 4 / 5; overflow: hidden; border-radius: 16px; background: #5e2718; box-shadow: 0 26px 50px -30px rgba(20, 5, 0, .8); }\n.w5ctr-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }\n.w5ctr-dim { position: absolute; inset: 0; background: #3a150b; opacity: .45; }\n.w5ctr-name { display: block; margin-top: 16px; font-family: Georgia, \"Times New Roman\", serif; font-size: 22px; }\n.w5ctr-meta { display: block; margin-top: 4px; font-size: 14px; color: #f1d8c6; }\n.w5ctr-price { display: block; margin-top: 4px; font-size: 14px; font-weight: 600; }\n.w5ctr-btns { display: flex; justify-content: center; gap: 12px; margin-top: 18px; }\n.w5ctr-btns button { display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 1px solid rgba(251, 239, 228, .4); border-radius: 50%; background: transparent; color: #fbefe4; cursor: pointer; transition: background-color .2s ease; }\n.w5ctr-btns button:hover { background: rgba(251, 239, 228, .12); }\n.w5ctr-btns button[aria-disabled=\"true\"] { opacity: .35; cursor: default; }\n.w5ctr-btns button:focus-visible { outline: 3px solid #f4c8a8; outline-offset: 3px; }\n@keyframes w5ctr-grow { 0%, 100% { transform: scale(var(--w5ctr-small)); } 50% { transform: scale(1); } }\n@keyframes w5ctr-lift { 0%, 100% { opacity: .45; } 50% { opacity: 0; } }\n@supports (animation-timeline: view()) {\n  @media (prefers-reduced-motion: no-preference) {\n    .w5ctr-in { animation: w5ctr-grow linear both; animation-timeline: --w5ctr-card; }\n    .w5ctr-dim { animation: w5ctr-lift linear both; animation-timeline: --w5ctr-card; }\n  }\n}\n@media (prefers-reduced-motion: reduce) {\n  .w5ctr-in { transform: none; }\n  .w5ctr-dim { opacity: 0; }\n  .w5ctr-row { gap: 20px; }\n  .w5ctr-btns button { transition: none; }\n}\n@media (max-width: 639px) { .w5ctr-root { --w5ctr-card: 240px; } }\n`;\n\n// Same script as the HTML version. It also checks prefers-reduced-motion itself.\nfunction init(root: HTMLElement): () => void {\n  var $ = function (s: string): any { return root.querySelector(s); };\n  var row = $(\".w5ctr-row\"), prev = $(\".w5ctr-prev\"), next = $(\".w5ctr-next\");\n  var rm = matchMedia(\"(prefers-reduced-motion: reduce)\");\n  var ac = new AbortController(), o = { passive: true, signal: ac.signal };\n  var go = function (d: number) { row.scrollBy({ left: d * row.clientWidth * 0.8, behavior: rm.matches ? \"auto\" : \"smooth\" }); };\n  var START = 1, SMALL = 0.84; // card centred on load, and side card scale\n  var cards = [].slice.call(row.children), css = window.CSS && CSS.supports(\"animation-timeline: view()\");\n  var seen = true, raf = 0;\n  var io = new IntersectionObserver(function (e) { seen = e[0].isIntersecting; });\n  io.observe(root);\n  // Fallback for browsers without view timelines: scale each card by its distance from the centre.\n  function grow() {\n    raf = 0;\n    var mid = row.scrollLeft + row.clientWidth / 2;\n    cards.forEach(function (c: any) {\n      var d = Math.min(1, Math.abs(c.offsetLeft - row.offsetLeft + c.offsetWidth / 2 - mid) / (c.offsetWidth + 8));\n      c.firstElementChild.style.transform = \"scale(\" + (1 - (1 - SMALL) * d) + \")\";\n      c.querySelector(\".w5ctr-dim\").style.opacity = 0.45 * d;\n    });\n  }\n  var c0 = cards[START];\n  row.scrollLeft = c0.offsetLeft - row.offsetLeft - (row.clientWidth - c0.offsetWidth) / 2;\n  function paint() {\n    var max = row.scrollWidth - row.clientWidth, x = row.scrollLeft;\n    prev.setAttribute(\"aria-disabled\", String(x < 4));\n    next.setAttribute(\"aria-disabled\", String(x > max - 4));\n    if (!css && !rm.matches && seen && !raf) raf = requestAnimationFrame(grow);\n  }\n  prev.addEventListener(\"click\", function () { go(-1); }, o);\n  next.addEventListener(\"click\", function () { go(1); }, o);\n  row.addEventListener(\"scroll\", paint, o);\n  window.addEventListener(\"resize\", paint, o);\n  paint();\n  return function () {\n    ac.abort();\n    io.disconnect();\n    cancelAnimationFrame(raf);\n  };\n}\n\nexport default function SnapPhotoStripWithCentreCardGrowing() {\n  const ref = useRef<HTMLElement>(null);\n  useEffect(() => (ref.current ? init(ref.current) : undefined), []);\n  return (\n    <section ref={ref} className=\"w5ctr-root\" data-w5ctr aria-labelledby=\"w5ctr-title\">\n    <style>{css}</style>\n      <div className=\"w5ctr-head\">\n        <p className=\"w5ctr-label\">Saltmarsh Stays</p>\n        <h2 className=\"w5ctr-title\" id=\"w5ctr-title\">Six houses at the edge of the map</h2>\n      </div>\n      <ul className=\"w5ctr-row\" id=\"w5ctr-row\" role=\"list\" tabIndex=\"0\" aria-label=\"Holiday houses, scroll sideways\">\n        {homes.map((it, i) => (\n    <li key={i} className=\"w5ctr-card\">\n          <a href=\"#\" className=\"w5ctr-in\">\n            <span className=\"w5ctr-photo\"><img src={it.img} alt={it.alt} width=\"700\" height=\"875\" loading=\"eager\" /><span className=\"w5ctr-dim\" aria-hidden=\"true\"></span></span>\n            <span className=\"w5ctr-name\">{it.name}</span>\n            <span className=\"w5ctr-meta\">{it.place} &middot; {it.sleeps}</span>\n            <span className=\"w5ctr-price\">{it.price}</span>\n          </a>\n        </li>\n    ))}\n      </ul>\n      <div className=\"w5ctr-btns\">\n        <button type=\"button\" className=\"w5ctr-prev\" aria-controls=\"w5ctr-row\" aria-label=\"Previous house\"><svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" aria-hidden=\"true\"><path d=\"M12.5 4.5 7 10l5.5 5.5\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\"/></svg></button>\n        <button type=\"button\" className=\"w5ctr-next\" aria-controls=\"w5ctr-row\" aria-label=\"Next house\"><svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" aria-hidden=\"true\"><path d=\"M7.5 4.5 13 10l-5.5 5.5\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\"/></svg></button>\n      </div>\n    </section>\n  );\n}\n"}]}
