({
children,
lang,
})
| 3 | import { isApiAccessible } from "~/helpers/stackApi"; |
| 4 | import { useTranslations, type Lang } from "~/i18n"; |
| 5 | |
| 6 | /** |
| 7 | * "The desktop app is reachable" indicator. |
| 8 | * |
| 9 | * Was a hand-built fixed bar with its own `@keyframes gradientShift` and a |
| 10 | * hazard-stripe background. StickyBanner is the library's announcement bar and |
| 11 | * StatusDot is its live indicator, so the only thing left to own is the |
| 12 | * slide-in/out transform — the banner is absent, not just invisible, when the |
| 13 | * app is not running. |
| 14 | */ |
| 15 | export const Debug: React.FC<{ children?: any; lang: Lang }> = ({ |
| 16 | children, |
| 17 | lang, |
| 18 | }) => { |
| 19 | const [connected, setConnected] = useState(false); |
| 20 | |
| 21 | const t = useTranslations(lang); |
| 22 | |
| 23 | useEffect(() => { |
| 24 | const check = async () => { |
| 25 | const reachable = await isApiAccessible(); |
| 26 | setConnected(reachable); |
| 27 | // Several pages hide or reveal CTAs off this attribute. |
| 28 | document.body.setAttribute("data-connected", reachable.toString()); |
| 29 | }; |
| 30 | |
| 31 | check(); |
| 32 | const timer = setInterval(check, 2000); |
| 33 | return () => clearInterval(timer); |
| 34 | }, []); |
| 35 | |
| 36 | return ( |
| 37 | <> |
| 38 | {children} |
| 39 | <div |
| 40 | id="debug" |
| 41 | className="fixed top-0 inset-x-0 z-50 select-none" |
| 42 | style={{ |
| 43 | transform: `translateY(${connected ? "0" : "-100%"})`, |
| 44 | transition: "transform 0.3s var(--pui-ease)", |
| 45 | }} |
| 46 | > |
| 47 | <StickyBanner hideSparkle> |
| 48 | {/* StickyBanner wraps its children in one span, so the dot and the |
| 49 | label need their own row. */} |
| 50 | <span className="inline-flex items-center gap-2"> |
| 51 | <StatusDot /> |
| 52 | <span |
| 53 | dangerouslySetInnerHTML={{ __html: t("Service is running…") }} |
| 54 | /> |
| 55 | </span> |
| 56 | </StickyBanner> |
| 57 | </div> |
| 58 | </> |
| 59 | ); |
| 60 | }; |
nothing calls this directly
no test coverage detected