{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"file-sync-status-icons-uploading-synced-offline-and-error","type":"registry:component","title":"File Sync Status Icons With Retry","description":"","dependencies":[],"files":[{"path":"components/we-inc/file-sync-status-icons-uploading-synced-offline-and-error.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\n\n/* Styles shared with the HTML version; class and keyframe names are prefixed so several pieces can share a page. */\nconst css = `\n  /* Change these: page, card, and the four state colours. */\n  .m3sts { --m3sts-bg: #e9edf1; --m3sts-card: #ffffff; --m3sts-up: #2f5f93; --m3sts-ok: #2b7350; --m3sts-off: #5d6672; --m3sts-err: #b4432c; }\n  .m3sts { background: var(--m3sts-bg); padding: 64px 16px; font-family: \"Inter Tight\", \"Inter\", ui-sans-serif, system-ui, sans-serif; color: #1c2430; }\n  .m3sts-card { max-width: 620px; margin: 0 auto; background: var(--m3sts-card); border: 1px solid #dde3ea; border-radius: 20px; padding: 26px; box-shadow: 0 1px 2px rgba(28,36,48,.05), 0 22px 44px -28px rgba(28,36,48,.35); }\n  .m3sts-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }\n  .m3sts-kicker { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: #4f5a68; }\n  .m3sts-title { margin: 6px 0 0; font-size: 21px; font-weight: 600; letter-spacing: -.01em; }\n  .m3sts-replay { min-height: 40px; padding: 0 14px; border: 1px solid #d3dae2; border-radius: 999px; background: #fff; color: #3a4552; font: inherit; font-size: 13px; cursor: pointer; }\n  .m3sts-list { list-style: none; margin: 20px 0 0; padding: 0; }\n  .m3sts-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid #edf0f4; }\n  .m3sts-ic { flex: none; width: 40px; height: 40px; padding: 8px; box-sizing: border-box; border-radius: 12px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }\n  .m3sts-ic g, .m3sts-ic path { transform-box: fill-box; transform-origin: 50% 50%; }\n  .m3sts-row[data-s=\"up\"] .m3sts-ic { color: var(--m3sts-up); background: #e8eff7; }\n  .m3sts-row[data-s=\"done\"] .m3sts-ic, .m3sts-row[data-s=\"ok\"] .m3sts-ic { color: var(--m3sts-ok); background: #e6f2eb; }\n  .m3sts-row[data-s=\"off\"] .m3sts-ic { color: var(--m3sts-off); background: #eef0f3; }\n  .m3sts-row[data-s=\"err\"] .m3sts-ic { color: var(--m3sts-err); background: #f8e9e5; }\n  .m3sts-row[data-s=\"sync\"] .m3sts-ic { color: var(--m3sts-up); background: #e8eff7; }\n  .m3sts-ic { transition: color .3s ease, background-color .3s ease; }\n  .m3sts-text { flex: 1; min-width: 0; }\n  .m3sts-name { margin: 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }\n  .m3sts-txt { margin: 3px 0 0; font-size: 13.5px; color: #4f5a68; }\n  .m3sts-retry { flex: none; min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: #1c2430; color: #fff; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: opacity .25s ease; }\n  .m3sts-row:not([data-s=\"err\"]) .m3sts-retry { opacity: 0; pointer-events: none; }\n  .m3sts-retry:focus-visible, .m3sts-replay:focus-visible { outline: 2px solid var(--m3sts-up); outline-offset: 3px; }\n  .m3sts-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n  /* Crossfade between the three icons of the retry row. */\n  .m3sts-g { opacity: 0; transition: opacity .3s ease; }\n  .m3sts-row[data-s=\"err\"] .m3sts-g-err, .m3sts-row[data-s=\"sync\"] .m3sts-g-sync, .m3sts-row[data-s=\"ok\"] .m3sts-g-done { opacity: 1; }\n  .m3sts-draw, .m3sts-tick { stroke-dasharray: 1; stroke-dashoffset: 0; }\n  /* Motion: the arrow loops only while uploading; the sync arrows turn only while syncing; checks draw once. */\n  .m3sts-arrow { animation: m3sts-rise 1.8s ease-in-out infinite; }\n  .m3sts-row[data-s=\"sync\"] .m3sts-spin { animation: m3sts-turn 1.1s linear infinite; }\n  .m3sts-row[data-s=\"ok\"] .m3sts-tick { animation: m3sts-draw .5s .15s ease-out both; }\n  .m3sts[data-in] .m3sts-draw { animation: m3sts-draw .6s .2s ease-out both; }\n  .m3sts[data-in] .m3sts-late { animation-delay: .45s; }\n  .m3sts[data-in] .m3sts-row[data-s=\"err\"] .m3sts-g-err { animation: m3sts-nudge .5s .7s ease-in-out both; }\n  @keyframes m3sts-rise { 0% { transform: translateY(2px); opacity: 0; } 30%,70% { opacity: 1; } 100% { transform: translateY(-2.5px); opacity: 0; } }\n  @keyframes m3sts-turn { to { transform: rotate(360deg); } }\n  @keyframes m3sts-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }\n  @keyframes m3sts-nudge { 0%,100% { transform: none; } 25% { transform: translateX(-1.5px); } 50% { transform: translateX(1.5px); } 75% { transform: translateX(-.8px); } }\n  .m3sts[data-off] * { animation-play-state: paused !important; }\n  @media (prefers-reduced-motion: reduce) { .m3sts * { animation: none !important; transition: none !important; } }\n`;\n\nexport default function FileSyncStatusIconsWithRetry() {\n  const ref = useRef<HTMLElement>(null);\n\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    const SPIN = 1800; // how long the retry spins before it reports success\n    const DONE = \"Uploaded just now\";\n    const WAIT = \"Uploading again\";\n    const row = root.querySelector<HTMLElement>('[data-s=\"err\"]')!;\n    const txt = row.querySelector<HTMLElement>(\".m3sts-txt\")!;\n    const live = root.querySelector<HTMLElement>(\".m3sts-live\")!;\n    const first = txt.textContent ?? \"\";\n    const name = row.querySelector(\".m3sts-name\")!.textContent;\n    let t = 0;\n    const set = (s: string, msg: string, say: boolean) => {\n      row.setAttribute(\"data-s\", s);\n      txt.textContent = msg;\n      if (say) live.textContent = `${name}: ${msg}`;\n    };\n    const retry = (say: boolean) => {\n      set(\"sync\", WAIT, say);\n      window.clearTimeout(t);\n      t = window.setTimeout(() => set(\"ok\", DONE, say), SPIN);\n    };\n    // Preview: one quiet retry shortly after load (not announced); remove for real use.\n    let demo = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches ? 0 : window.setTimeout(() => retry(false), 900);\n    const stopDemo = () => window.clearTimeout(demo);\n    const onRetry = () => { stopDemo(); retry(true); };\n    const onReplay = () => {\n      window.clearTimeout(t); stopDemo();\n      set(\"err\", first, false);\n      live.textContent = \"\";\n      root.removeAttribute(\"data-in\");\n      void root.offsetWidth;\n      root.setAttribute(\"data-in\", \"\");\n    };\n    const retryBtn = row.querySelector(\".m3sts-retry\")!;\n    const replayBtn = root.querySelector(\".m3sts-replay\")!;\n    retryBtn.addEventListener(\"click\", onRetry);\n    replayBtn.addEventListener(\"click\", onReplay);\n    root.addEventListener(\"focusin\", stopDemo);\n    // Draws the checks the first time the card is seen, and pauses loops off screen.\n    const io = new IntersectionObserver(([en]) => {\n      if (en.isIntersecting) { root.setAttribute(\"data-in\", \"\"); root.removeAttribute(\"data-off\"); }\n      else root.setAttribute(\"data-off\", \"\");\n    });\n    io.observe(root);\n    return () => {\n      window.clearTimeout(t); stopDemo(); demo = 0;\n      io.disconnect();\n      retryBtn.removeEventListener(\"click\", onRetry);\n      replayBtn.removeEventListener(\"click\", onReplay);\n      root.removeEventListener(\"focusin\", stopDemo);\n    };\n  }, []);\n\n  return (\n    <>\n      <style>{css}</style>\n      <section ref={ref} className=\"m3sts\" aria-labelledby=\"m3sts-h\">\n        <div className=\"m3sts-card\">\n          <div className=\"m3sts-head\">\n            <div>\n              <p className=\"m3sts-kicker\">Juniper Lane Bakery</p>\n              <h2 className=\"m3sts-title\" id=\"m3sts-h\">Shared folder: autumn menu</h2>\n            </div>\n            <button className=\"m3sts-replay\" type=\"button\">Replay</button>\n          </div>\n          <ul className=\"m3sts-list\">\n            <li className=\"m3sts-row\" data-s=\"up\">\n              <svg className=\"m3sts-ic\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M5 14.5v4h14v-4\"/><g className=\"m3sts-arrow\"><path d=\"M12 14V5\"/><path d=\"M8.5 8.5L12 5l3.5 3.5\"/></g></svg>\n              <div className=\"m3sts-text\"><p className=\"m3sts-name\">menu-photos (8 files)</p><p className=\"m3sts-txt\">Uploading, 3 of 8 done</p></div>\n            </li>\n            <li className=\"m3sts-row\" data-s=\"done\">\n              <svg className=\"m3sts-ic\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M7.5 19h9a4 4 0 0 0 .6-7.95A5.5 5.5 0 0 0 6.6 12.1 3.5 3.5 0 0 0 7.5 19z\"/><path className=\"m3sts-draw\" pathLength={1} d=\"M9.4 14.6l1.9 1.9 3.4-3.6\"/></svg>\n              <div className=\"m3sts-text\"><p className=\"m3sts-name\">price-cards.pdf</p><p className=\"m3sts-txt\">Synced just now</p></div>\n            </li>\n            <li className=\"m3sts-row\" data-s=\"off\">\n              <svg className=\"m3sts-ic\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M7.5 19h9a4 4 0 0 0 .6-7.95A5.5 5.5 0 0 0 6.6 12.1 3.5 3.5 0 0 0 7.5 19z\"/><path className=\"m3sts-draw m3sts-late\" pathLength={1} d=\"M4 4.5l16 16\"/></svg>\n              <div className=\"m3sts-text\"><p className=\"m3sts-name\">counter-sign.png</p><p className=\"m3sts-txt\">Offline, syncs when you reconnect</p></div>\n            </li>\n            <li className=\"m3sts-row\" data-s=\"err\">\n              <svg className=\"m3sts-ic\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n                <g className=\"m3sts-g m3sts-g-err\"><path d=\"M10.6 5.2a1.6 1.6 0 0 1 2.8 0l7 12.2a1.6 1.6 0 0 1-1.4 2.4H5a1.6 1.6 0 0 1-1.4-2.4z\"/><path d=\"M12 10v3.6\"/><path d=\"M12 16.6v.1\"/></g>\n                <g className=\"m3sts-g m3sts-g-sync\"><g className=\"m3sts-spin\"><path d=\"M19 12a7 7 0 0 1-12.5 4.3\"/><path d=\"M5 12a7 7 0 0 1 12.5-4.3\"/><path d=\"M17.9 4.4v3.6h-3.6\"/><path d=\"M6.1 19.6V16h3.6\"/></g></g>\n                <g className=\"m3sts-g m3sts-g-done\"><path d=\"M7.5 19h9a4 4 0 0 0 .6-7.95A5.5 5.5 0 0 0 6.6 12.1 3.5 3.5 0 0 0 7.5 19z\"/><path className=\"m3sts-tick\" pathLength={1} d=\"M9.4 14.6l1.9 1.9 3.4-3.6\"/></g>\n              </svg>\n              <div className=\"m3sts-text\"><p className=\"m3sts-name\">supplier-list.csv</p><p className=\"m3sts-txt\">Could not upload: the file is open elsewhere</p></div>\n              <button className=\"m3sts-retry\" type=\"button\">Retry</button>\n            </li>\n          </ul>\n          <p className=\"m3sts-live\" role=\"status\"></p>\n        </div>\n      </section>\n    </>\n  );\n}\n"}]}
