From 52a28deb961432cd65926e6d88a1ff9dc734ef13 Mon Sep 17 00:00:00 2001 From: Ashis Kumar Naik Date: Wed, 2 Jul 2025 08:25:21 +0530 Subject: [PATCH] feat: create offline indicator UI components --- src/components/ui/offline-indicator.tsx | 53 +++++++++++++++++++++++++ src/components/ui/pending-indicator.tsx | 23 +++++++++++ 2 files changed, 76 insertions(+) create mode 100644 src/components/ui/offline-indicator.tsx create mode 100644 src/components/ui/pending-indicator.tsx diff --git a/src/components/ui/offline-indicator.tsx b/src/components/ui/offline-indicator.tsx new file mode 100644 index 0000000..b2d09f9 --- /dev/null +++ b/src/components/ui/offline-indicator.tsx @@ -0,0 +1,53 @@ +import { AlertCircle, Wifi, WifiOff, RefreshCw } from "lucide-react"; +import { cn } from "@/lib/utils"; + +interface OfflineIndicatorProps { + isNetworkConnected: boolean; + isSyncing: boolean; + outboxCount: number; + className?: string; +} + +export function OfflineIndicator({ + isNetworkConnected, + isSyncing, + outboxCount, + className +}: OfflineIndicatorProps) { + if (isNetworkConnected && !isSyncing && outboxCount === 0) { + return null; + } + + return ( +
+ {!isNetworkConnected && ( +
+ + Offline + {outboxCount > 0 && ( + + {outboxCount} pending + + )} +
+ )} + + {isNetworkConnected && isSyncing && outboxCount > 0 && ( +
+ + Syncing {outboxCount} items... +
+ )} + + {isNetworkConnected && !isSyncing && outboxCount > 0 && ( +
+ + {outboxCount} items pending sync +
+ )} +
+ ); +} \ No newline at end of file diff --git a/src/components/ui/pending-indicator.tsx b/src/components/ui/pending-indicator.tsx new file mode 100644 index 0000000..97a6744 --- /dev/null +++ b/src/components/ui/pending-indicator.tsx @@ -0,0 +1,23 @@ +import { Clock, Upload } from "lucide-react"; +import { cn } from "@/lib/utils"; + +interface PendingIndicatorProps { + size?: "sm" | "md"; + className?: string; +} + +export function PendingIndicator({ size = "sm", className }: PendingIndicatorProps) { + return ( +
+ + Pending +
+ ); +} \ No newline at end of file