{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"rolling-word-rotator-in-a-fixed-width-slot","type":"registry:component","title":"Rolling Word Rotator in a Fixed Slot","description":"","dependencies":[],"files":[{"path":"components/we-inc/rolling-word-rotator-in-a-fixed-width-slot.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\n\nconst BUSINESS = \"Spokewell Cycle Repair\";\nconst WORDS = [\n  \"flat tyres\",\n  \"loose chains\",\n  \"worn brakes\",\n  \"wobbly wheels\"\n];\nconst COPY = \"Leave your bike at the Mill Lane workshop before nine and ride it home after five, with the parts list taped to the bars.\";\n\nconst CSS = `\n/* Edit these first: colours, and how long one full cycle takes. */\n.wr-root {\n  --wr-bg: #13241c;\n  --wr-ink: #eef2e8;\n  --wr-muted: #a9b9a5;\n  --wr-accent: #bfe08f;\n  --wr-speed: 10s;\n  position: relative;\n  overflow: hidden;\n  box-sizing: border-box;\n  min-height: 480px;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  padding: 72px 20px;\n  background: var(--wr-bg);\n  color: var(--wr-ink);\n  font-family: \"Inter Tight\", Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif;\n  -webkit-font-smoothing: antialiased;\n}\n.wr-root *, .wr-root *::before, .wr-root *::after { box-sizing: border-box; }\n.wr-inner { position: relative; z-index: 1; width: 100%; max-width: 1040px; }\n.wr-eyebrow { margin: 0 0 22px; font-family: \"Inter Tight\", Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif; font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--wr-muted); }\n.wr-h { margin: 0; font-size: clamp(40px, 7.6vw, 96px); font-weight: 800; line-height: 1.08; letter-spacing: -.035em; }\n.wr-copy { margin: 28px 0 0; max-width: 34em; font-family: \"Inter Tight\", Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif; font-size: clamp(16px, 1.5vw, 19px); line-height: 1.6; color: var(--wr-muted); }\n.wr-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n.wr-w { display: inline-block; white-space: nowrap; }\n.wr-l { display: inline-block; }\n/* Paused while scrolled out of view (the script sets data-paused). */\n.wr-root[data-paused=\"true\"] *, .wr-root[data-paused=\"true\"] *::before, .wr-root[data-paused=\"true\"] *::after { animation-play-state: paused !important; }\n@media (prefers-reduced-motion: reduce) {\n  .wr-root *, .wr-root *::before, .wr-root *::after { animation: none !important; }\n}\n\n.wr-root { background: radial-gradient(ellipse at 80% 0%, #1f3a2c 0%, var(--wr-bg) 60%); }\n.wr-lead { display: block; }\n.wr-slot { position: relative; display: inline-grid; height: 1.08em; overflow: hidden; vertical-align: top; color: var(--wr-accent); }\n.wr-reserve { grid-area: 1 / 1; visibility: hidden; white-space: nowrap; }\n.wr-reel { position: absolute; left: 0; top: 0; animation: wr-roll var(--wr-speed) infinite; }\n.wr-reel span { display: block; height: 1.08em; white-space: nowrap; }\n.wr-rule { display: block; width: 100%; height: 3px; margin-top: 10px; border-radius: 2px; background: var(--wr-accent); opacity: .35; }\n/* Five stops: four words plus the first again, so the loop never jumps. */\n@keyframes wr-roll {\n  0%, 20% { transform: translateY(0); animation-timing-function: cubic-bezier(.7, 0, .2, 1); }\n  25%, 45% { transform: translateY(-1.08em); animation-timing-function: cubic-bezier(.7, 0, .2, 1); }\n  50%, 70% { transform: translateY(-2.16em); animation-timing-function: cubic-bezier(.7, 0, .2, 1); }\n  75%, 95% { transform: translateY(-3.24em); animation-timing-function: cubic-bezier(.7, 0, .2, 1); }\n  100% { transform: translateY(-4.32em); }\n}\n`;\n\nexport default function RollingWordRotator() {\n  const rootRef = useRef<HTMLElement>(null);\n\n  // Pause the CSS animation while the section is off screen.\n  useEffect(() => {\n    const el = rootRef.current;\n    if (!el || typeof IntersectionObserver === \"undefined\") return;\n    const io = new IntersectionObserver(([entry]) => {\n      el.dataset.paused = entry.isIntersecting ? \"false\" : \"true\";\n    });\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  return (\n    <section ref={rootRef} data-paused=\"false\" className=\"wr-root w-full\">\n      <style>{CSS}</style>\n      <div className=\"wr-inner\">\n        <p className=\"wr-eyebrow\">{BUSINESS}</p>\n        <h2 className=\"wr-h\">\n          <span className=\"wr-sr\">{`We fix ${WORDS.slice(0, -1).join(\", \")} and ${WORDS[WORDS.length - 1]}.`}</span>\n          <span aria-hidden=\"true\">\n            <span className=\"wr-lead\">We fix</span>\n            <span className=\"wr-slot\">\n              {WORDS.map((w) => (\n                <span key={w} className=\"wr-reserve\">{w}</span>\n              ))}\n              <span className=\"wr-reel\">\n                {[...WORDS, WORDS[0]].map((w, i) => (\n                  <span key={i}>{w}</span>\n                ))}\n              </span>\n            </span>\n            <span className=\"wr-rule\" />\n          </span>\n        </h2>\n        <p className=\"wr-copy\">{COPY}</p>\n      </div>\n    </section>\n  );\n}\n"}]}
