| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- import { useState, useEffect } from 'react';
- import { ChevronLeft, ChevronRight } from 'lucide-react';
- import { carouselData } from '@/data/mockData';
- export function HeroCarousel() {
- const [currentIndex, setCurrentIndex] = useState(0);
- const [isHovering, setIsHovering] = useState(false);
- useEffect(() => {
- if (isHovering) return;
- const interval = setInterval(() => {
- setCurrentIndex((prev) => (prev + 1) % carouselData.length);
- }, 5000);
- return () => clearInterval(interval);
- }, [isHovering]);
- const goToSlide = (index: number) => {
- setCurrentIndex(index);
- };
- const prevSlide = () => {
- setCurrentIndex((prev) => (prev - 1 + carouselData.length) % carouselData.length);
- };
- const nextSlide = () => {
- setCurrentIndex((prev) => (prev + 1) % carouselData.length);
- };
- return (
- <div
- className="relative w-full overflow-hidden"
- style={{ height: '85vh', minHeight: '600px' }}
- onMouseEnter={() => setIsHovering(true)}
- onMouseLeave={() => setIsHovering(false)}
- >
- <div className="absolute inset-0 overflow-hidden">
- {carouselData.map((slide, index) => (
- <div
- key={slide.id}
- className={`absolute inset-0 bg-gradient-to-br ${slide.bgGradient} transition-opacity duration-1000 ${
- index === currentIndex ? 'opacity-100 z-10' : 'opacity-0 z-0'
- }`}
- >
- <div className="absolute inset-0 bg-[url('data:image/svg+xml,%3Csvg%20width%3D%2260%22%20height%3D%2260%22%20viewBox%3D%220%200%2060%2060%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cg%20fill%3D%22%23ffffff%22%20fill-opacity%3D%220.03%22%3E%3Cpath%20d%3D%22M36%2034v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6%2034v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6%204V0H4v4H0v2h4v4h2V6h4V4H6z%22%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E')] opacity-50" />
-
- <div className="absolute top-1/4 left-1/4 w-96 h-96 bg-glow-green/10 rounded-full blur-3xl animate-pulse" />
- <div className="absolute bottom-1/4 right-1/4 w-96 h-96 bg-tech-cyan-500/10 rounded-full blur-3xl animate-pulse" style={{ animationDelay: '1s' }} />
-
- <div className="absolute inset-0">
- {[...Array(30)].map((_, i) => (
- <div
- key={i}
- className="absolute w-1 h-1 bg-glow-green/30 rounded-full animate-float"
- style={{
- left: `${Math.random() * 100}%`,
- top: `${Math.random() * 100}%`,
- animationDelay: `${Math.random() * 5}s`,
- animationDuration: `${5 + Math.random() * 5}s`,
- }}
- />
- ))}
- </div>
- </div>
- ))}
- </div>
- <div className="relative z-20 h-full flex flex-col items-center justify-center px-4">
- <div className="text-center">
- <h1 className="text-3xl md:text-4xl lg:text-5xl font-bold text-white mb-6 leading-tight transition-all duration-1000">
- {carouselData[currentIndex].title}
- </h1>
- <p className="text-base md:text-lg lg:text-xl text-white/90 mb-6 max-w-4xl mx-auto leading-relaxed transition-all duration-1000">
- {carouselData[currentIndex].subtitle}
- </p>
- <p className="text-sm md:text-base lg:text-lg text-white/70 max-w-2xl mx-auto transition-all duration-1000">
- {carouselData[currentIndex].testimonial}
- </p>
- </div>
- </div>
- <button
- onClick={prevSlide}
- className="absolute left-4 md:left-8 top-1/2 -translate-y-1/2 z-30 w-12 h-12 bg-white/10 backdrop-blur-sm rounded-full flex items-center justify-center text-white hover:bg-white/20 transition-all"
- >
- <ChevronLeft className="w-6 h-6" />
- </button>
- <button
- onClick={nextSlide}
- className="absolute right-4 md:right-8 top-1/2 -translate-y-1/2 z-30 w-12 h-12 bg-white/10 backdrop-blur-sm rounded-full flex items-center justify-center text-white hover:bg-white/20 transition-all"
- >
- <ChevronRight className="w-6 h-6" />
- </button>
- <div className="absolute bottom-12 left-1/2 -translate-x-1/2 z-30 flex gap-3">
- {carouselData.map((_, index) => (
- <button
- key={index}
- onClick={() => goToSlide(index)}
- className={`w-3 h-3 rounded-full transition-all ${
- index === currentIndex ? 'bg-glow-green w-8' : 'bg-white/30 hover:bg-white/50'
- }`}
- />
- ))}
- </div>
- </div>
- );
- }
|