tahamajs/IE / Projects /front /src /components /flow /OfflineSyncIndicator.tsx
tahamajs's picture
download
raw
1.45 kB
// src/components/flow/OfflineSyncIndicator.tsx
import { useNetworkQuality } from "@/hooks/useNetworkQuality";
import { useOfflineSync } from "@/hooks/useOfflineSync";
import { Wifi, WifiOff, CloudUpload, CloudDownload, Clock, AlertTriangle } from "lucide-react";
export function OfflineSyncIndicator() {
const network = useNetworkQuality();
const { status, queueCount } = useOfflineSync();
const isOffline = !navigator.onLine;
const tierLabel = isOffline ? "Offline" : network.effectiveType?.toUpperCase() ?? "4G";
const isPoor = isOffline || network.tier === "2g" || network.tier === "3g";
return (
<div className={`flex items-center gap-2 px-3 py-1.5 rounded-full text-xs transition ${
isPoor ? "bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-400" :
status === "syncing" ? "bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-400" :
"bg-gray-50 dark:bg-gray-800 text-gray-500"
}`}>
{isOffline ? (
<WifiOff className="w-3.5 h-3.5" />
) : (
<Wifi className="w-3.5 h-3.5" />
)}
<span className="font-medium">{tierLabel}</span>
{status === "syncing" && <CloudUpload className="w-3.5 h-3.5 animate-pulse" />}
{queueCount > 0 && (
<span className="bg-amber-200 dark:bg-amber-800 text-amber-800 dark:text-amber-200 px-1.5 py-0.5 rounded-full text-[10px] font-bold">
{queueCount}
</span>
)}
</div>
);
}

Xet Storage Details

Size:
1.45 kB
·
Xet hash:
cd108042cfbef5a7603543e1ff1c831391fce18b69422a9f20440ee570a99cdd

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.