{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"snap-scroll-bread-shelf-with-arrow-buttons","type":"registry:block","title":"Snap Scroll Bread Shelf with Arrow Buttons","description":"","dependencies":[],"files":[{"path":"components/we-inc/snap-scroll-bread-shelf-with-arrow-buttons.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\n\nconst loaves = [\n  {\n    \"img\": \"https://images.pexels.com/photos/32935771/pexels-photo-32935771.jpeg?auto=compress&cs=tinysrgb&w=700\",\n    \"alt\": \"Scored sourdough loaves with a deep golden crust, close up\",\n    \"name\": \"Country sourdough\",\n    \"price\": \"$9\",\n    \"note\": \"Three day ferment, dark bake, open crumb.\"\n  },\n  {\n    \"img\": \"https://images.pexels.com/photos/8599725/pexels-photo-8599725.jpeg?auto=compress&cs=tinysrgb&w=700\",\n    \"alt\": \"Thick slices of dark seeded rye bread on a white surface\",\n    \"name\": \"Seeded rye\",\n    \"price\": \"$8\",\n    \"note\": \"Dense and sour, best sliced thin with butter.\"\n  },\n  {\n    \"img\": \"https://images.pexels.com/photos/34936588/pexels-photo-34936588.jpeg?auto=compress&cs=tinysrgb&w=700\",\n    \"alt\": \"Golden baguettes stacked together on a bakery shelf\",\n    \"name\": \"Morning baguette\",\n    \"price\": \"$4\",\n    \"note\": \"Out of the oven at seven, gone by ten.\"\n  },\n  {\n    \"img\": \"https://images.pexels.com/photos/33657315/pexels-photo-33657315.jpeg?auto=compress&cs=tinysrgb&w=700\",\n    \"alt\": \"Squares of focaccia topped with cherry tomatoes and rosemary in a pan\",\n    \"name\": \"Tomato focaccia\",\n    \"price\": \"$7\",\n    \"note\": \"Olive oil, sea salt and roasted tomatoes.\"\n  },\n  {\n    \"img\": \"https://images.pexels.com/photos/30632209/pexels-photo-30632209.jpeg?auto=compress&cs=tinysrgb&w=700\",\n    \"alt\": \"A whole grain loaf covered in seeds held over a checked cloth\",\n    \"name\": \"Granary tin\",\n    \"price\": \"$7\",\n    \"note\": \"Malted flakes for a soft, nutty sandwich loaf.\"\n  },\n  {\n    \"img\": \"https://images.pexels.com/photos/31132628/pexels-photo-31132628.jpeg?auto=compress&cs=tinysrgb&w=700\",\n    \"alt\": \"Spiral morning buns on a tray in a bakery window behind a handwritten label\",\n    \"name\": \"Morning buns\",\n    \"price\": \"$4.75\",\n    \"note\": \"Orange zest and cinnamon, Saturdays only.\"\n  }\n];\n\nconst css = `\n.w5shf-root { --w5shf-flour: #f1e8d8; --w5shf-crust: #7a3c1b; --w5shf-card: 260px; --w5shf-max: 1160px; --w5shf-pad: max(20px, calc((100% - var(--w5shf-max)) / 2)); padding: 56px 0 48px; background: var(--w5shf-flour); color: #2d231a; font-family: ui-sans-serif, system-ui, sans-serif; overflow: hidden; }\n.w5shf-root *, .w5shf-root *::before { box-sizing: border-box; }\n.w5shf-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 0 var(--w5shf-pad); }\n.w5shf-label { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--w5shf-crust); }\n.w5shf-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.w5shf-lede { margin: 10px 0 0; max-width: 48ch; font-size: 15px; line-height: 1.6; color: #5b4a3a; }\n.w5shf-btns { display: flex; gap: 10px; flex: 0 0 auto; }\n.w5shf-btns button { display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 1px solid #cdbba1; border-radius: 50%; background: #fbf6ee; color: #2d231a; cursor: pointer; transition: background-color .2s ease, transform .2s ease; }\n.w5shf-btns button:hover { background: #fff; }\n.w5shf-btns button:active { transform: scale(.94); }\n.w5shf-btns button[aria-disabled=\"true\"] { opacity: .4; cursor: default; }\n.w5shf-btns button:focus-visible, .w5shf-row:focus-visible, .w5shf-add:focus-visible { outline: 3px solid var(--w5shf-crust); outline-offset: 3px; }\n.w5shf-row { display: flex; gap: 22px; margin: 28px 0 0; padding: 4px var(--w5shf-pad) 8px; list-style: none; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--w5shf-pad); scrollbar-width: none; overscroll-behavior-x: contain; }\n.w5shf-row::-webkit-scrollbar { display: none; }\n.w5shf-card { position: relative; flex: 0 0 var(--w5shf-card); scroll-snap-align: start; }\n.w5shf-photo { aspect-ratio: 4 / 5; overflow: hidden; border-radius: 14px; background: #e3d5bf; }\n.w5shf-photo img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2, .7, .2, 1); }\n.w5shf-card:hover img, .w5shf-card:focus-within img { transform: scale(1.04); }\n.w5shf-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 14px; }\n.w5shf-name { margin: 0; font-size: 16px; font-weight: 600; }\n.w5shf-price { font-size: 15px; font-variant-numeric: tabular-nums; color: #5b4a3a; }\n.w5shf-note { margin: 6px 0 0; font-size: 14px; line-height: 1.5; color: #5b4a3a; }\n.w5shf-add { display: inline-flex; align-items: center; min-height: 40px; margin-top: 4px; font-size: 14px; font-weight: 600; color: var(--w5shf-crust); text-decoration: underline; text-underline-offset: 4px; border-radius: 4px; }\n.w5shf-bar { height: 2px; margin: 18px var(--w5shf-pad) 0; background: #dccdb6; overflow: hidden; }\n.w5shf-fill { display: block; height: 100%; background: var(--w5shf-crust); transform: scaleX(.3); transform-origin: 0 50%; }\n.w5shf-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n@media (max-width: 639px) { .w5shf-head { flex-direction: column; align-items: flex-start; } .w5shf-root { --w5shf-card: 230px; } }\n@media (prefers-reduced-motion: reduce) { .w5shf-photo img, .w5shf-btns button { transition: none; } }\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 = $(\".w5shf-row\"), prev = $(\".w5shf-prev\"), next = $(\".w5shf-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\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    var seen = row.clientWidth / row.scrollWidth;\n    $(\".w5shf-fill\").style.transform = \"scaleX(\" + (seen + (1 - seen) * (max > 0 ? x / max : 1)) + \")\";\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\n  };\n}\n\nexport default function SnapScrollBreadShelfWithArrowButtons() {\n  const ref = useRef<HTMLElement>(null);\n  useEffect(() => (ref.current ? init(ref.current) : undefined), []);\n  return (\n    <section ref={ref} className=\"w5shf-root\" data-w5shf aria-labelledby=\"w5shf-title\">\n    <style>{css}</style>\n      <div className=\"w5shf-head\">\n        <div>\n          <p className=\"w5shf-label\">Fennick Bakehouse</p>\n          <h2 className=\"w5shf-title\" id=\"w5shf-title\">On the shelf this week</h2>\n          <p className=\"w5shf-lede\">Order by Thursday night and we hold your loaves at the counter until noon on Saturday.</p>\n        </div>\n        <div className=\"w5shf-btns\">\n          <button type=\"button\" className=\"w5shf-prev\" aria-controls=\"w5shf-row\" aria-label=\"Previous loaves\"><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=\"w5shf-next\" aria-controls=\"w5shf-row\" aria-label=\"Next loaves\"><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      </div>\n      <ul className=\"w5shf-row\" id=\"w5shf-row\" role=\"list\" tabIndex=\"0\" aria-label=\"Breads, scroll sideways\">\n        {loaves.map((it, i) => (\n    <li key={i} className=\"w5shf-card\">\n          <div className=\"w5shf-photo\"><img src={it.img} alt={it.alt} width=\"700\" height=\"875\" loading=\"eager\" /></div>\n          <div className=\"w5shf-line\"><h3 className=\"w5shf-name\">{it.name}</h3><span className=\"w5shf-price\">{it.price}</span></div>\n          <p className=\"w5shf-note\">{it.note}</p>\n          <a href=\"#\" className=\"w5shf-add\">Reserve<span className=\"w5shf-sr\"> {it.name}</span></a>\n        </li>\n    ))}\n      </ul>\n      <div className=\"w5shf-bar\" aria-hidden=\"true\"><span className=\"w5shf-fill\"></span></div>\n    </section>\n  );\n}\n"}]}
