WFDASHDRIVER-APP/components/OfflineIndicator.tsx
SJCoetz db10eb95c7 Add PWA support and UI redesign
Add full PWA support (icons, manifest, service worker, pwa lib and bridge) and introduce install/offline UI. Generate app icons via a new scripts/generate-icons.js and include multiple icon sizes in public/icons; update manifest and layout head meta/preconnect. Revamp global styles (globals.css) with new utilities, animations, spacing for bottom nav, card shadows, skeletons and accessibility tweaks. Polish major screens (login, collections, map, settings) with improved headers, loading states, touch/press feedback, and layout adjustments; add new components (InstallPrompt, OfflineIndicator, PWABridge) and update various components to match new visual/UX patterns. Update Dockerfile to generate icons and use Next.js static export output (/out) for nginx, and bump package setup to support icon generation.
2026-05-27 00:34:50 +02:00

58 lines
No EOL
1.5 KiB
TypeScript

'use client';
import { useOnlineStatus } from '@/lib/pwa';
import { WifiOff, Wifi } from 'lucide-react';
import { cn } from '@/lib/utils';
import { useState, useEffect } from 'react';
export default function OfflineIndicator() {
const isOnline = useOnlineStatus();
const [showBanner, setShowBanner] = useState(false);
const [wasOffline, setWasOffline] = useState(false);
useEffect(() => {
if (!isOnline) {
setShowBanner(true);
setWasOffline(true);
} else if (wasOffline) {
setShowBanner(true);
const timer = setTimeout(() => {
setShowBanner(false);
setWasOffline(false);
}, 3000);
return () => clearTimeout(timer);
}
}, [isOnline, wasOffline]);
if (!showBanner) return null;
return (
<div
className={cn(
'fixed top-0 left-0 right-0 z-[80] transition-transform duration-300 ease-out safe-top',
showBanner ? 'translate-y-0' : '-translate-y-full'
)}
>
<div
className={cn(
'px-4 py-2 text-center text-sm font-medium flex items-center justify-center gap-2',
isOnline
? 'bg-green-500 text-white'
: 'bg-red-500 text-white'
)}
>
{isOnline ? (
<>
<Wifi size={14} />
Back online
</>
) : (
<>
<WifiOff size={14} />
You&apos;re offline — changes will sync when reconnected
</>
)}
</div>
</div>
);
}