|
| 1 | +"use client"; |
| 2 | +import { useState, useEffect } from "react"; |
| 3 | + |
| 4 | +interface AppLoaderProps { |
| 5 | + onLoadComplete?: () => void; |
| 6 | +} |
| 7 | + |
| 8 | +export default function AppLoader({ onLoadComplete }: AppLoaderProps) { |
| 9 | + const [isVisible, setIsVisible] = useState(true); |
| 10 | + const [isFading, setIsFading] = useState(false); |
| 11 | + const [progress, setProgress] = useState(0); |
| 12 | + |
| 13 | + useEffect(() => { |
| 14 | + // Animate progress bar |
| 15 | + const progressInterval = setInterval(() => { |
| 16 | + setProgress((prev) => { |
| 17 | + if (prev >= 100) { |
| 18 | + clearInterval(progressInterval); |
| 19 | + return 100; |
| 20 | + } |
| 21 | + return prev + 2; |
| 22 | + }); |
| 23 | + }, 30); |
| 24 | + |
| 25 | + // Start fade out animation |
| 26 | + const fadeTimer = setTimeout(() => { |
| 27 | + setIsFading(true); |
| 28 | + }, 1800); |
| 29 | + |
| 30 | + // Hide loader after fade out |
| 31 | + const hideTimer = setTimeout(() => { |
| 32 | + setIsVisible(false); |
| 33 | + onLoadComplete?.(); |
| 34 | + }, 2300); |
| 35 | + |
| 36 | + return () => { |
| 37 | + clearInterval(progressInterval); |
| 38 | + clearTimeout(fadeTimer); |
| 39 | + clearTimeout(hideTimer); |
| 40 | + }; |
| 41 | + }, [onLoadComplete]); |
| 42 | + |
| 43 | + if (!isVisible) return null; |
| 44 | + |
| 45 | + return ( |
| 46 | + <div className={`fixed inset-0 z-[9999] flex items-center justify-center overflow-hidden transition-opacity duration-500 ${isFading ? 'opacity-0' : 'opacity-100'}`}> |
| 47 | + {/* Animated background gradient */} |
| 48 | + <div className="absolute inset-0 bg-gradient-to-br from-background via-background to-background"> |
| 49 | + <div className="absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,rgba(34,197,94,0.1),transparent_50%)]"></div> |
| 50 | + <div className="absolute inset-0 bg-[radial-gradient(circle_at_80%_20%,rgba(59,130,246,0.1),transparent_50%)]"></div> |
| 51 | + <div className="absolute inset-0 bg-[radial-gradient(circle_at_20%_80%,rgba(168,85,247,0.1),transparent_50%)]"></div> |
| 52 | + </div> |
| 53 | + |
| 54 | + {/* Animated particles */} |
| 55 | + <div className="absolute inset-0 overflow-hidden"> |
| 56 | + {[...Array(20)].map((_, i) => ( |
| 57 | + <div |
| 58 | + key={i} |
| 59 | + className="absolute w-1 h-1 bg-green-400/30 rounded-full animate-float" |
| 60 | + style={{ |
| 61 | + left: `${Math.random() * 100}%`, |
| 62 | + top: `${Math.random() * 100}%`, |
| 63 | + animationDelay: `${Math.random() * 3}s`, |
| 64 | + animationDuration: `${3 + Math.random() * 4}s`, |
| 65 | + }} |
| 66 | + /> |
| 67 | + ))} |
| 68 | + </div> |
| 69 | + |
| 70 | + {/* Main content */} |
| 71 | + <div className="relative z-10 flex flex-col items-center gap-8 px-4"> |
| 72 | + {/* Logo with glow effect */} |
| 73 | + <div className="relative"> |
| 74 | + <div className="absolute inset-0 blur-3xl bg-gradient-to-r from-green-400 to-blue-500 opacity-30 animate-pulse"></div> |
| 75 | + <div className="relative"> |
| 76 | + <h1 className="text-5xl md:text-7xl font-black tracking-tight"> |
| 77 | + <span className="bg-gradient-to-r from-green-400 via-emerald-400 to-blue-500 bg-clip-text text-transparent animate-gradient-x"> |
| 78 | + KickViewerBOT |
| 79 | + </span> |
| 80 | + </h1> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | + |
| 84 | + {/* Futuristic loader ring */} |
| 85 | + <div className="relative w-32 h-32"> |
| 86 | + {/* Outer ring */} |
| 87 | + <div className="absolute inset-0 rounded-full border-2 border-green-400/10"></div> |
| 88 | + |
| 89 | + {/* Spinning rings */} |
| 90 | + <div className="absolute inset-0 rounded-full border-2 border-transparent border-t-green-400 border-r-green-400 animate-spin"></div> |
| 91 | + <div |
| 92 | + className="absolute inset-2 rounded-full border-2 border-transparent border-t-blue-400 border-l-blue-400 animate-spin" |
| 93 | + style={{ animationDirection: "reverse", animationDuration: "1.5s" }} |
| 94 | + ></div> |
| 95 | + <div |
| 96 | + className="absolute inset-4 rounded-full border-2 border-transparent border-b-purple-400 border-r-purple-400 animate-spin" |
| 97 | + style={{ animationDuration: "2s" }} |
| 98 | + ></div> |
| 99 | + |
| 100 | + {/* Center glow */} |
| 101 | + <div className="absolute inset-8 rounded-full bg-gradient-to-br from-green-400/20 to-blue-500/20 blur-xl animate-pulse"></div> |
| 102 | + </div> |
| 103 | + |
| 104 | + {/* Progress bar */} |
| 105 | + <div className="w-64 md:w-80"> |
| 106 | + <div className="relative h-2 bg-foreground/5 rounded-full overflow-hidden backdrop-blur-sm"> |
| 107 | + <div |
| 108 | + className="absolute inset-y-0 left-0 bg-gradient-to-r from-green-400 via-emerald-400 to-blue-500 rounded-full transition-all duration-300 ease-out" |
| 109 | + style={{ width: `${progress}%` }} |
| 110 | + > |
| 111 | + <div className="absolute inset-0 bg-gradient-to-r from-transparent via-white/30 to-transparent animate-shimmer"></div> |
| 112 | + </div> |
| 113 | + </div> |
| 114 | + |
| 115 | + {/* Progress percentage */} |
| 116 | + <div className="flex justify-between items-center mt-3"> |
| 117 | + <span className="text-xs text-foreground/50 font-medium">Loading...</span> |
| 118 | + <span className="text-xs text-foreground/70 font-bold tabular-nums">{progress}%</span> |
| 119 | + </div> |
| 120 | + </div> |
| 121 | + |
| 122 | + {/* Animated status text */} |
| 123 | + <div className="flex items-center gap-3"> |
| 124 | + <div className="flex gap-1"> |
| 125 | + {[0, 1, 2].map((i) => ( |
| 126 | + <div |
| 127 | + key={i} |
| 128 | + className="w-1.5 h-1.5 bg-green-400 rounded-full animate-bounce" |
| 129 | + style={{ animationDelay: `${i * 0.15}s` }} |
| 130 | + /> |
| 131 | + ))} |
| 132 | + </div> |
| 133 | + <span className="text-sm text-foreground/60 font-medium"> |
| 134 | + Initializing application |
| 135 | + </span> |
| 136 | + </div> |
| 137 | + </div> |
| 138 | + </div> |
| 139 | + ); |
| 140 | +} |
0 commit comments