-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus-indicator.tsx
More file actions
142 lines (127 loc) · 5.13 KB
/
status-indicator.tsx
File metadata and controls
142 lines (127 loc) · 5.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
"use client"
import { useState, useEffect } from "react"
import { Sparkles, Wifi, WifiOff } from "lucide-react"
export default function Component() {
const [isOnline, setIsOnline] = useState(true)
const [sparkles, setSparkles] = useState<Array<{ id: number; x: number; y: number; delay: number }>>([])
// Generate random sparkles
useEffect(() => {
const generateSparkles = () => {
const newSparkles = Array.from({ length: 8 }, (_, i) => ({
id: i,
x: Math.random() * 200 - 100, // Random position around center
y: Math.random() * 200 - 100,
delay: Math.random() * 2, // Random animation delay
}))
setSparkles(newSparkles)
}
generateSparkles()
const interval = setInterval(generateSparkles, 3000) // Regenerate sparkles every 3 seconds
return () => clearInterval(interval)
}, [])
return (
<div className="flex items-center justify-center min-h-screen bg-gradient-to-br from-slate-900 via-purple-900 to-slate-900">
<div className="relative">
{/* Sparkle animations */}
{sparkles.map((sparkle) => (
<div
key={sparkle.id}
className="absolute pointer-events-none"
style={{
left: `${sparkle.x}px`,
top: `${sparkle.y}px`,
animationDelay: `${sparkle.delay}s`,
}}
>
<Sparkles
className={`w-4 h-4 animate-ping ${isOnline ? "text-emerald-400" : "text-red-400"}`}
style={{
animationDuration: "2s",
animationIterationCount: "infinite",
}}
/>
</div>
))}
{/* Main status container */}
<div className="relative bg-white/10 backdrop-blur-lg rounded-3xl p-8 border border-white/20 shadow-2xl">
{/* Status light with glow effect */}
<div className="relative flex items-center justify-center mb-6">
<div
className={`w-12 h-12 rounded-full relative transition-all duration-500 ${
isOnline ? "bg-emerald-500 shadow-emerald-500/50" : "bg-red-500 shadow-red-500/50"
} shadow-2xl`}
>
{/* Pulsing ring */}
<div
className={`absolute inset-0 rounded-full animate-ping ${isOnline ? "bg-emerald-400" : "bg-red-400"}`}
style={{ animationDuration: "2s" }}
/>
{/* Inner glow */}
<div
className={`absolute inset-2 rounded-full ${isOnline ? "bg-emerald-300" : "bg-red-300"} opacity-60`}
/>
{/* Center highlight */}
<div className="absolute inset-4 rounded-full bg-white/40" />
</div>
</div>
{/* Status text and icon */}
<div className="text-center space-y-4">
<div className="flex items-center justify-center space-x-2">
{isOnline ? <Wifi className="w-6 h-6 text-emerald-400" /> : <WifiOff className="w-6 h-6 text-red-400" />}
<span
className={`text-2xl font-bold transition-colors duration-500 ${
isOnline ? "text-emerald-400" : "text-red-400"
}`}
>
{isOnline ? "ONLINE" : "OFFLINE"}
</span>
</div>
<p className="text-white/70 text-sm">{isOnline ? "All systems operational" : "Connection lost"}</p>
{/* Toggle button */}
<button
onClick={() => setIsOnline(!isOnline)}
className={`px-6 py-3 rounded-full font-semibold transition-all duration-300 transform hover:scale-105 ${
isOnline ? "bg-emerald-500 hover:bg-emerald-600 text-white" : "bg-red-500 hover:bg-red-600 text-white"
} shadow-lg hover:shadow-xl`}
>
Toggle Status
</button>
</div>
{/* Floating particles */}
<div className="absolute inset-0 overflow-hidden rounded-3xl pointer-events-none">
{Array.from({ length: 12 }).map((_, i) => (
<div
key={i}
className={`absolute w-1 h-1 rounded-full ${isOnline ? "bg-emerald-400" : "bg-red-400"} opacity-60`}
style={{
left: `${Math.random() * 100}%`,
top: `${Math.random() * 100}%`,
animation: `float ${3 + Math.random() * 2}s ease-in-out infinite`,
animationDelay: `${Math.random() * 2}s`,
}}
/>
))}
</div>
</div>
{/* Outer glow effect */}
<div
className={`absolute inset-0 rounded-3xl transition-all duration-500 -z-10 ${
isOnline ? "bg-emerald-500/20 shadow-emerald-500/20" : "bg-red-500/20 shadow-red-500/20"
} shadow-2xl blur-xl`}
/>
</div>
<style jsx>{`
@keyframes float {
0%, 100% {
transform: translateY(0px) rotate(0deg);
opacity: 0.6;
}
50% {
transform: translateY(-20px) rotate(180deg);
opacity: 1;
}
}
`}</style>
</div>
)
}