{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"slate-checklist-preloader-that-ticks-off-each-photo-by-name","type":"registry:block","title":"Slate Checklist Preloader","description":"","dependencies":[],"files":[{"path":"components/we-inc/slate-checklist-preloader-that-ticks-off-each-photo-by-name.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\n\nconst MIN = 1100; // shortest time the cover shows, in ms\nconst CAP = 1500; // longest the cover waits for images, in ms\nconst EXIT = 900; // length of the exit, in ms\n// On a real page: give the cover position: fixed; inset: 0 and put data-page on your <main>.\n\nconst CSS = `\n  .w2lst { --w2lst-slate: #2f3a45; --w2lst-white: #ffffff; --w2lst-accent: #3f6f8f; height: 600px; background: var(--w2lst-white); color: var(--w2lst-slate); font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif; }\n  .w2lst-page { height: 100%; display: flex; flex-direction: column; padding: 0 clamp(16px, 4vw, 48px) clamp(16px, 3vw, 36px); }\n  .w2lst-nav { display: flex; align-items: center; justify-content: space-between; height: 72px; }\n  .w2lst-brand { color: inherit; font-weight: 700; text-decoration: none; }\n  .w2lst-nav ul { display: flex; gap: 26px; margin: 0; padding: 0; list-style: none; }\n  .w2lst-nav ul a { color: #4f5b67; font-size: 14px; text-decoration: none; }\n  .w2lst-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 18px 0 26px; }\n  .w2lst-title { margin: 0; max-width: 40rem; font-size: clamp(30px, 4.6vw, 58px); line-height: 1.04; letter-spacing: -.03em; font-weight: 600; }\n  .w2lst-replay { flex: none; border: 1px solid #c9d1d9; background: #f5f7f9; color: var(--w2lst-slate); }\n  .w2lst-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 0; padding: 0; list-style: none; }\n  .w2lst-grid li { display: flex; flex-direction: column; min-height: 0; transform: translateY(26px); opacity: .001; transition: transform .9s cubic-bezier(.2,.75,.15,1) .25s, opacity .6s ease .25s; }\n  .w2lst-grid li:nth-child(2) { transition-delay: .35s; } .w2lst-grid li:nth-child(3) { transition-delay: .45s; }\n  .w2lst.is-out .w2lst-grid li { transform: none; opacity: 1; }\n  .w2lst-grid img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; display: block; border-radius: 6px; }\n  .w2lst-grid p { margin: 10px 0 0; font-size: 14px; color: #4f5b67; }\n  .w2lst-cover { position: absolute; inset: 0; z-index: 2; background: var(--w2lst-white); display: flex; align-items: center; justify-content: center; padding: 16px; transition: opacity .45s ease .35s; }\n  .w2lst.is-out .w2lst-cover { opacity: 0; }\n  .w2lst-box { width: min(100%, 380px); transition: transform .6s cubic-bezier(.6,0,.3,1), opacity .4s ease; }\n  .w2lst.is-out .w2lst-box { transform: translateY(-18px); opacity: 0; }\n  .w2lst-label { margin: 0 0 18px; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: #5d6875; }\n  .w2lst-list { margin: 0; padding: 0; list-style: none; }\n  .w2lst-list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid #e3e7eb; font-size: 15px; color: #6b7681; transition: color .3s ease; }\n  .w2lst-list li.is-on { color: var(--w2lst-slate); }\n  .w2lst-dot { position: relative; display: grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 50%; border: 1.5px solid #c3cbd3; color: #fff; }\n  .w2lst-dot::before { content: \"\"; position: absolute; inset: -1.5px; border-radius: 50%; background: var(--w2lst-accent); transform: scale(0); transition: transform .35s cubic-bezier(.3,1.4,.5,1); }\n  .w2lst-dot svg { position: relative; opacity: 0; transition: opacity .2s ease .1s; }\n  .w2lst-list li.is-on .w2lst-dot::before { transform: scale(1); }\n  .w2lst-list li.is-on .w2lst-dot svg { opacity: 1; }\n  .w2lst-meter { display: flex; align-items: center; gap: 14px; margin-top: 14px; }\n  .w2lst-bar { flex: 1; height: 3px; border-radius: 3px; background: #e3e7eb; overflow: hidden; }\n  .w2lst-bar span { display: block; height: 100%; background: var(--w2lst-accent); transform: scaleX(0); transform-origin: left; }\n  .w2lst-pct { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }\n  @media (max-width: 767px) {\n    .w2lst-nav ul li:not(:last-child) { display: none; }\n    .w2lst-head { flex-direction: column; align-items: flex-start; margin: 10px 0 18px; }\n    .w2lst-grid { grid-template-columns: 1fr 1fr; }\n    .w2lst-grid li:nth-child(3) { display: none; }\n    .w2lst-grid p { font-size: 13px; }\n  }\n\n  .w2lst { position: relative; overflow: hidden; }\n  .w2lst-cover[hidden] { display: none; }\n  .w2lst.is-snap, .w2lst.is-snap * { transition: none !important; }\n  .w2lst[data-paused] * { animation-play-state: paused !important; }\n  .w2lst-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n  .w2lst-replay { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 999px; font: 600 13px/1 ui-sans-serif, system-ui, sans-serif; cursor: pointer; }\n  .w2lst-replay:focus-visible, .w2lst a:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }\n  @media (prefers-reduced-motion: reduce) {\n    .w2lst *, .w2lst *::before, .w2lst *::after { animation: none !important; transition-duration: 0s !important; transition-delay: 0s !important; }\n    .w2lst .w2lst-cover { transition: opacity .45s ease !important; }\n    .w2lst.is-out .w2lst-cover { opacity: 0; }\n    .w2lst-cover *:not([data-bar]), .w2lst-page * { transform: none !important; opacity: 1; }\n  }\n`;\n\nexport default function SlateChecklistPreloader() {\n  const ref = useRef<HTMLElement>(null);\n\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    const page = root.querySelector<HTMLElement>(\"[data-page]\")!;\n    const cover = root.querySelector<HTMLElement>(\"[data-cover]\")!;\n    const live = root.querySelector<HTMLElement>(\"[data-live]\")!;\n    const again = root.querySelector<HTMLButtonElement>(\"[data-replay]\")!;\n    const nums = root.querySelectorAll<HTMLElement>(\"[data-num]\");\n    const bars = root.querySelectorAll<HTMLElement>(\"[data-bar]\");\n    const ticks = root.querySelectorAll<HTMLElement>(\"[data-tick]\");\n    const rm = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n    let run = 0, frame = 0, seen = true, timer = 0;\n    let step: ((now: number) => void) | null = null;\n    const draw = (v: number) => {\n      const t = String(Math.round(v * 100));\n      nums.forEach((n) => { n.textContent = t; });\n      bars.forEach((b) => { b.style.transform = `scaleX(${v})`; });\n    };\n    const start = (refocus: boolean) => {\n      const id = ++run, t0 = performance.now(), imgs = page.querySelectorAll(\"img\"), total = imgs.length;\n      let done = 0, shown = 0;\n      cancelAnimationFrame(frame);\n      window.clearTimeout(timer);\n      root.classList.add(\"is-snap\");\n      root.classList.remove(\"is-out\");\n      cover.hidden = false;\n      void root.offsetWidth;\n      root.classList.remove(\"is-snap\");\n      page.inert = true;\n      page.setAttribute(\"aria-busy\", \"true\");\n      live.textContent = \"Loading\";\n      ticks.forEach((k) => k.classList.remove(\"is-on\"));\n      // Real progress: one step per image that fires load or error.\n      imgs.forEach((img, i) => {\n        const hit = () => { if (id !== run) return; done++; ticks[i]?.classList.add(\"is-on\"); };\n        if (img.complete) hit();\n        else { img.addEventListener(\"load\", hit, { once: true }); img.addEventListener(\"error\", hit, { once: true }); }\n      });\n      step = (now: number) => {\n        let real = total ? done / total : 1;\n        const t = now - t0;\n        if (t > CAP) real = 1;\n        shown += (real - shown) * (rm.matches ? 1 : 0.2);\n        if (real - shown < 0.004) shown = real;\n        draw(shown);\n        if (shown === 1 && t >= MIN) {\n          step = null;\n          frame = 0;\n          root.classList.add(\"is-out\");\n          live.textContent = \"Page ready\";\n          page.inert = false;\n          page.removeAttribute(\"aria-busy\");\n          timer = window.setTimeout(() => { cover.hidden = true; if (refocus) again.focus(); }, rm.matches ? 500 : EXIT);\n          return;\n        }\n        frame = seen ? requestAnimationFrame(step) : 0;\n      };\n      frame = requestAnimationFrame(step);\n    };\n    // Off screen: stop the frame loop and pause CSS loops.\n    const io = new IntersectionObserver(([e]) => {\n      seen = e.isIntersecting;\n      root.toggleAttribute(\"data-paused\", !seen);\n      if (seen && step && !frame) frame = requestAnimationFrame(step);\n    });\n    io.observe(root);\n    const onReplay = () => start(true);\n    again.addEventListener(\"click\", onReplay);\n    start(false);\n    return () => {\n      run++;\n      cancelAnimationFrame(frame);\n      window.clearTimeout(timer);\n      io.disconnect();\n      again.removeEventListener(\"click\", onReplay);\n    };\n  }, []);\n\n  return (\n    <section ref={ref} className=\"w2lst\">\n      <style>{CSS}</style>\n      <div className=\"w2lst-page\" data-page=\"\" aria-busy={true}>\n        <header className=\"w2lst-nav\">\n          <a href=\"#\" className=\"w2lst-brand\">Northlight Interiors</a>\n          <nav aria-label=\"Main\"><ul><li><a href=\"#\">Projects</a></li><li><a href=\"#\">Studio</a></li><li><a href=\"#\">Enquire</a></li></ul></nav>\n        </header>\n        <div className=\"w2lst-head\">\n          <h2 className=\"w2lst-title\">Calm rooms for busy households.</h2>\n          <button type=\"button\" className=\"w2lst-replay\" data-replay=\"\">\n              <svg viewBox=\"0 0 20 20\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M4 10a6 6 0 1 0 1.8-4.3\" /><path d=\"M4 3.5v3.2h3.2\" /></svg>\n              Replay intro\n            </button>\n        </div>\n        <ul className=\"w2lst-grid\">\n          <li><img src=\"https://images.pexels.com/photos/12277014/pexels-photo-12277014.jpeg?auto=compress&cs=tinysrgb&w=1200\" alt=\"Beige sofa beside a low wooden console with a potted plant against a white wall\" width=\"1200\" height=\"675\" /><p>Living room, oak console</p></li>\n          <li><img src=\"https://images.pexels.com/photos/7195900/pexels-photo-7195900.jpeg?auto=compress&cs=tinysrgb&w=1200\" alt=\"Long wooden dining table with black chairs next to a bright white kitchen\" width=\"1200\" height=\"800\" /><p>Dining room, walnut table</p></li>\n          <li><img src=\"https://images.pexels.com/photos/7031622/pexels-photo-7031622.jpeg?auto=compress&cs=tinysrgb&w=1200\" alt=\"Open plan room with a concrete floor and tall windows looking out over a lake\" width=\"1200\" height=\"800\" /><p>Lake house, open plan</p></li>\n        </ul>\n      </div>\n      <div className=\"w2lst-cover\" data-cover=\"\" aria-hidden=\"true\">\n        <div className=\"w2lst-box\">\n          <p className=\"w2lst-label\">Northlight Interiors</p>\n          <ul className=\"w2lst-list\">\n            <li data-tick=\"\"><span className=\"w2lst-dot\"><svg viewBox=\"0 0 16 16\" width=\"12\" height=\"12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M3.5 8.5l3 3 6-7\" /></svg></span>Living room, oak console</li>\n            <li data-tick=\"\"><span className=\"w2lst-dot\"><svg viewBox=\"0 0 16 16\" width=\"12\" height=\"12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M3.5 8.5l3 3 6-7\" /></svg></span>Dining room, walnut table</li>\n            <li data-tick=\"\"><span className=\"w2lst-dot\"><svg viewBox=\"0 0 16 16\" width=\"12\" height=\"12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M3.5 8.5l3 3 6-7\" /></svg></span>Lake house, open plan</li>\n          </ul>\n          <div className=\"w2lst-meter\"><span className=\"w2lst-bar\"><span data-bar=\"\"></span></span><span className=\"w2lst-pct\"><span data-num=\"\">0</span>%</span></div>\n        </div>\n      </div>\n      <p className=\"w2lst-sr\" data-live=\"\" aria-live=\"polite\"></p>\n    </section>\n  );\n}\n"}]}
