SPB Git

Repository Public

Banners.tsx 1.8 KB 34 lines tsx

1"use client";2import { useSyncExternalStore } from "react";3import { Icon } from "@/components/ui/Icon";45/** Shown on every page of a preview build. Not dismissible: nobody should mistake a preview for the public site. */6export function PreviewBanner() {7  return (8    <div role="region" aria-label="Mode aperçu" data-testid="preview-banner" className="no-print bg-violet text-on-accent">9      <div className="shell flex min-h-9 items-center gap-2 py-1.5 text-sm font-medium">10        <span aria-hidden="true">◆</span>11        <span><strong>Aperçu — contenu non publié.</strong><span className="max-sm:hidden"> Cette version montre du matériel en cours de révision et une vidéo de test technique. Elle n’est pas le site public.</span></span>12      </div>13    </div>14  );15}1617const subscribe = (cb: () => void) => { window.addEventListener("online", cb); window.addEventListener("offline", cb); return () => { window.removeEventListener("online", cb); window.removeEventListener("offline", cb); }; };1819export function useOnline(): boolean {20  return useSyncExternalStore(subscribe, () => navigator.onLine, () => true);21}2223/** Tells the visitor the connection dropped, and what still works. */24export function OfflineBanner() {25  const online = useOnline();26  if (online) return null;27  return (28    <div role="status" data-testid="offline-banner" className="no-print fixed inset-x-3 bottom-3 z-50 mx-auto flex max-w-xl items-start gap-3 rounded-2xl border border-amber bg-amber-soft p-4 text-sm shadow-card">29      <Icon name="wifiOff" className="mt-0.5 shrink-0 text-amber" />30      <p><strong>Vous êtes hors ligne.</strong> Les pages déjà ouvertes, vos notes et votre progression restent accessibles. Les vidéos et les nouvelles pages reprendront au retour de la connexion.</p>31    </div>32  );33}34
Files main
Menu

Theme