{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"split-colour-button-second-colour-slides-in","type":"registry:block","title":"Split Colour Button With a Sliding Second Colour","description":"","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/split-colour-button-second-colour-slides-in.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: --w7spl-ink, --w7spl-wine (second colour), --w7spl-bone (page), --w7spl-dur (slide time). */\n  .w7spl { --w7spl-ink: #1c1a17; --w7spl-wine: #8c2f39; --w7spl-bone: #f1ebe1; --w7spl-dur: .55s;\n    padding: 56px 20px; background: var(--w7spl-bone); color: var(--w7spl-ink); font-family: ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif; }\n  .w7spl-card { max-width: 46rem; margin: 0 auto; text-align: center; }\n  .w7spl-eye { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; color: var(--w7spl-wine); }\n  .w7spl-h { margin: 14px 0 0; font-family: Georgia, \"Iowan Old Style\", serif; font-weight: 400; font-size: clamp(1.7rem, 4vw, 2.6rem); line-height: 1.15; letter-spacing: -.01em; }\n  .w7spl-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 34px; }\n  .w7spl-b { position: relative; display: inline-grid; min-height: 52px; padding: 0 28px; place-items: center; overflow: hidden; border-radius: 4px; font-size: 15px; font-weight: 600; letter-spacing: .01em; text-decoration: none; isolation: isolate; }\n  .w7spl-a { background: var(--w7spl-ink); color: var(--w7spl-bone); }\n  .w7spl-o { box-shadow: inset 0 0 0 1.5px var(--w7spl-ink); color: var(--w7spl-ink); }\n  .w7spl-u { background: #e3d7c5; color: var(--w7spl-ink); }\n  /* The mask carries the second colour; its label moves the opposite way, so the text stays still and changes colour at the edge. */\n  .w7spl-m { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; background: var(--w7spl-wine); color: #fbf3ea; transform: translateX(-101%); transition: transform var(--w7spl-dur) cubic-bezier(.7,0,.2,1); }\n  .w7spl-m .w7spl-t { transform: translateX(101%); transition: transform var(--w7spl-dur) cubic-bezier(.7,0,.2,1); }\n  .w7spl-o .w7spl-m { transform: translateY(101%); } .w7spl-o .w7spl-m .w7spl-t { transform: translateY(-101%); }\n  .w7spl-u .w7spl-m { transform: translateX(101%); background: var(--w7spl-ink); } .w7spl-u .w7spl-m .w7spl-t { transform: translateX(-101%); }\n  .w7spl-b:hover .w7spl-m, .w7spl-b:focus-visible .w7spl-m, .w7spl-b[data-demo] .w7spl-m,\n  .w7spl-b:hover .w7spl-m .w7spl-t, .w7spl-b:focus-visible .w7spl-m .w7spl-t, .w7spl-b[data-demo] .w7spl-m .w7spl-t { transform: none; }\n  .w7spl-b:focus-visible { outline: 3px solid var(--w7spl-wine); outline-offset: 3px; }\n  .w7spl-note { margin: 22px 0 0; font-size: 14px; color: #5e564c; }\n  @media (prefers-reduced-motion: reduce) { .w7spl-m, .w7spl-m .w7spl-t { transition: none; } }\n`;\n\nexport default function SplitColourButtonSecondColourSlidesIn() {\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 STEP = 1500; // ms each button shows its second colour during the demo\n      if (matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n      // Demo only: buttons take turns until someone points at, taps or tabs into the section.\n      var btns = root.querySelectorAll(\".w7spl-b\"), i = 0, timer = 0, seen = true, done = false;\n      function clear() { btns.forEach(function (b) { b.removeAttribute(\"data-demo\"); }); }\n      function step() { clear(); btns[i++ % btns.length].setAttribute(\"data-demo\", \"\"); timer = setTimeout(step, STEP); }\n      function play() { if (!done && seen && !timer) step(); }\n      function stop() { clearTimeout(timer); timer = 0; clear(); }\n      function hand() { done = true; stop(); }\n      [\"pointerenter\", \"focusin\", \"touchstart\"].forEach(function (n) { root.addEventListener(n, hand, { passive: true }); off.push(function () { root.removeEventListener(n, hand); }); });\n      var io = new IntersectionObserver(function (e) { seen = e[0].isIntersecting; if (seen) play(); else stop(); });\n      io.observe(root);\n      off.push(stop, function () { io.disconnect(); });\n      play();\n    return () => off.forEach((f) => f());\n  }, [prefersReduced]);\n\n  return (\n    <section className=\"w7spl\" data-w7spl=\"\" ref={rootRef} aria-label=\"Lowtide Wine Bar bookings\">\n      <style>{STYLES}</style>\n      <div className=\"w7spl-card\">\n        <p className=\"w7spl-eye\">Lowtide Wine Bar</p>\n        <h2 className=\"w7spl-h\">Thirty bottles open by the glass, and a short menu to go with them</h2>\n        <div className=\"w7spl-row\">\n          <a className=\"w7spl-b w7spl-a\" href=\"#\"><span className=\"w7spl-t\">Book a table</span><span className=\"w7spl-m\" aria-hidden=\"true\"><span className=\"w7spl-t\">Book a table</span></span></a>\n          <a className=\"w7spl-b w7spl-o\" href=\"#\"><span className=\"w7spl-t\">Tasting Thursdays</span><span className=\"w7spl-m\" aria-hidden=\"true\"><span className=\"w7spl-t\">Tasting Thursdays</span></span></a>\n          <a className=\"w7spl-b w7spl-u\" href=\"#\"><span className=\"w7spl-t\">Gift a bottle</span><span className=\"w7spl-m\" aria-hidden=\"true\"><span className=\"w7spl-t\">Gift a bottle</span></span></a>\n        </div>\n        <p className=\"w7spl-note\">Walk-ins welcome at the bar until nine.</p>\n      </div>\n    </section>\n  );\n}\n"}]}
