1
- import { FaTicketAlt , FaGift , FaCoins , FaDollarSign , FaTrophy , FaChevronRight , FaLock , FaRegLightbulb , FaStar } from "react-icons/fa" ;
1
+ import { FaTicketAlt , FaGift , FaCoins , FaDollarSign , FaTrophy , FaChevronRight , FaLock , FaRegLightbulb , FaStar , FaChevronLeft } from "react-icons/fa" ;
2
2
import CardRifa from "./components/CardRifa" ;
3
- import { useState , useEffect } from "react" ;
3
+ import { useState , useEffect , useCallback } from "react" ;
4
4
import { getAllRifas } from "../../api/rifa" ;
5
5
import { useNavigate } from "react-router" ;
6
6
@@ -9,6 +9,45 @@ const Inicio = () => {
9
9
const [ loading , setLoading ] = useState ( true ) ;
10
10
const [ error , setError ] = useState ( null ) ;
11
11
const navigate = useNavigate ( ) ;
12
+ const [ currentSlide , setCurrentSlide ] = useState ( 0 ) ;
13
+
14
+ // Array de contenido para el slider (imágenes y frases)
15
+ const sliderContent = [
16
+ {
17
+ title : '¡Gana <span class="text-yellow-300">increíbles</span><br/>premios con solo<br/>un <span class="text-yellow-300">click</span>!' ,
18
+ subtitle : 'Crea o participa en rifas de manera<br/><span class="font-bold text-white">segura, rápida y transparente</span>.' ,
19
+ image : '/image/prize-3.png' ,
20
+ } ,
21
+ {
22
+ title : 'Convierte tus <span class="text-yellow-300">sueños</span><br/>en realidad<br/>con <span class="text-yellow-300">TuRifa</span>!' ,
23
+ subtitle : 'Premios exclusivos que<br/><span class="font-bold text-white">están esperando por ti</span>.' ,
24
+ image : '/image/prize-2.png' ,
25
+ } ,
26
+ {
27
+ title : 'Cada boleto es una<br/><span class="text-yellow-300">oportunidad</span><br/>de <span class="text-yellow-300">ganar</span>!' ,
28
+ subtitle : 'Miles de ganadores<br/><span class="font-bold text-white">¡El próximo podrías ser tú!</span>' ,
29
+ image : '/image/prize-1.png' ,
30
+ }
31
+ ] ;
32
+
33
+ // Función para avanzar al siguiente slide
34
+ const nextSlide = useCallback ( ( ) => {
35
+ setCurrentSlide ( ( prev ) => ( prev + 1 ) % sliderContent . length ) ;
36
+ } , [ sliderContent . length ] ) ;
37
+
38
+ // Función para retroceder al slide anterior
39
+ const prevSlide = useCallback ( ( ) => {
40
+ setCurrentSlide ( ( prev ) => ( prev === 0 ? sliderContent . length - 1 : prev - 1 ) ) ;
41
+ } , [ sliderContent . length ] ) ;
42
+
43
+ // Efecto para el cambio automático de slides
44
+ useEffect ( ( ) => {
45
+ const interval = setInterval ( ( ) => {
46
+ nextSlide ( ) ;
47
+ } , 5000 ) ; // Cambia cada 5 segundos
48
+
49
+ return ( ) => clearInterval ( interval ) ;
50
+ } , [ nextSlide ] ) ;
12
51
13
52
useEffect ( ( ) => {
14
53
const fetchRifas = async ( ) => {
@@ -38,54 +77,111 @@ const Inicio = () => {
38
77
return (
39
78
< div className = "font-sans min-h-screen bg-gradient-to-b from-gray-50 to-blue-50" >
40
79
41
- { /* Hero Section - Mejorado con gradientes y animaciones */ }
80
+ { /* Hero Section - Ahora con slider/carrusel */ }
42
81
< section className = "bg-gradient-to-r from-blue-600 to-indigo-700 text-white shadow-xl mb-16 overflow-hidden relative py-12" >
43
82
{ /* Decorative elements */ }
44
83
< div className = "absolute top-0 right-0 w-64 h-64 bg-white opacity-10 rounded-full -translate-y-1/2 translate-x-1/4" > </ div >
45
84
< div className = "absolute bottom-0 left-0 w-72 h-72 bg-indigo-300 opacity-20 rounded-full translate-y-1/2 -translate-x-1/3" > </ div >
46
85
47
86
< div className = "container mx-auto flex flex-col md:flex-row items-center justify-between px-6 md:px-10 max-w-6xl relative z-10" >
48
87
< div className = "w-full md:w-1/2 flex flex-col justify-center px-4 md:px-0 py-8 md:py-16" >
49
- < h1 className = "text-4xl md:text-5xl font-extrabold leading-tight mb-6 text-center md:text-left" >
50
- ¡Gana < span className = "text-yellow-300" > increíbles</ span >
51
- < br />
52
- premios con solo
53
- < br />
54
- un < span className = "text-yellow-300" > click</ span > !
55
- </ h1 >
56
- < p className = "mt-2 text-lg md:text-xl text-blue-100 font-medium text-center md:text-left leading-relaxed mb-8" >
57
- Crea o participa en rifas de manera
58
- < br />
59
- < span className = "font-bold text-white" > segura, rápida y transparente</ span > .
60
- </ p >
88
+ { /* Contenido del slider - textos */ }
89
+ < div className = "relative overflow-hidden h-48 md:h-70" >
90
+ { sliderContent . map ( ( slide , index ) => (
91
+ < div
92
+ key = { index }
93
+ className = { `absolute w-full transition-all duration-700 transform ${
94
+ index === currentSlide
95
+ ? "translate-x-0 opacity-100"
96
+ : index < currentSlide
97
+ ? "-translate-x-full opacity-0"
98
+ : "translate-x-full opacity-0"
99
+ } `}
100
+ >
101
+ < h1
102
+ className = "text-4xl md:text-5xl font-extrabold leading-tight mb-6 text-center md:text-left"
103
+ dangerouslySetInnerHTML = { { __html : slide . title } }
104
+ />
105
+ < p
106
+ className = "mt-2 text-lg md:text-xl text-blue-100 font-medium text-center md:text-left leading-relaxed mb-8"
107
+ dangerouslySetInnerHTML = { { __html : slide . subtitle } }
108
+ />
109
+ </ div >
110
+ ) ) }
111
+ </ div >
61
112
62
- < div className = "flex flex-col sm:flex-row gap-4 justify-center md:justify-start" >
63
- < button className = "bg-white text-indigo-700 hover:bg-yellow-300 py-3 px-8 rounded-full font-bold text-lg shadow-lg transition-all duration-300 hover:shadow-xl flex items-center justify-center" >
113
+ < div className = "flex flex-col sm:flex-row gap-4 justify-center md:justify-start mt-20 md:mt-12" >
114
+ < button
115
+ onClick = { ( ) => navigate ( "/rifas" ) }
116
+ className = "bg-white text-indigo-700 hover:bg-yellow-300 py-3 px-8 rounded-full font-bold text-lg shadow-lg transition-all duration-300 hover:shadow-xl flex items-center justify-center" >
64
117
Explorar Rifas
65
118
< FaChevronRight className = "ml-2" />
66
119
</ button >
67
120
< button
68
- onClick = { ( ) => navigate ( "/crear/rifa" ) }
69
- className = "bg-transparent hover:bg-blue-700 border-2 border-white py-3 px-8 rounded-full font-bold text-lg transition-colors duration-300 flex items-center justify-center" >
70
-
121
+ onClick = { ( ) => navigate ( "/crear/rifa" ) }
122
+ className = "bg-transparent hover:bg-blue-700 border-2 border-white py-3 px-8 rounded-full font-bold text-lg transition-colors duration-300 flex items-center justify-center" >
71
123
Crear Rifa
72
124
</ button >
73
125
</ div >
126
+
127
+ { /* Controles del slider */ }
128
+ < div className = "flex justify-center md:justify-start mt-6 space-x-3" >
129
+ { sliderContent . map ( ( _ , index ) => (
130
+ < button
131
+ key = { index }
132
+ onClick = { ( ) => setCurrentSlide ( index ) }
133
+ className = { `w-3 h-3 rounded-full transition-all duration-300 ${
134
+ currentSlide === index
135
+ ? "bg-yellow-300 w-6"
136
+ : "bg-white opacity-50 hover:opacity-75"
137
+ } `}
138
+ aria-label = { `Go to slide ${ index + 1 } ` }
139
+ />
140
+ ) ) }
141
+ </ div >
74
142
</ div >
75
143
76
144
< div className = "w-full md:w-1/2 flex items-center justify-center px-4 md:px-0 mt-8 md:mt-0 relative" >
77
145
< div className = "absolute w-64 h-64 bg-yellow-300 rounded-full filter blur-3xl opacity-30" > </ div >
78
- < img
79
- className = "relative z-10 h-auto max-h-80 w-auto object-contain mx-auto transform hover:scale-105 transition-transform duration-700 bounce-slow"
80
- src = "/image/gift.png"
81
- alt = "Premio de rifa"
82
- />
146
+
147
+ { /* Contenido del slider - imágenes */ }
148
+ < div className = "relative w-full h-80 flex justify-center items-center" >
149
+ { sliderContent . map ( ( slide , index ) => (
150
+ < img
151
+ key = { index }
152
+ src = { slide . image }
153
+ alt = { `Slide ${ index + 1 } ` }
154
+ className = { `absolute max-h-1000 w-auto object-contain mx-auto transform hover:scale-105 transition-all duration-700 bounce-slow
155
+ ${ index === currentSlide
156
+ ? "opacity-100 scale-100"
157
+ : "opacity-0 scale-90" } `}
158
+ />
159
+ ) ) }
160
+ </ div >
161
+
162
+ { /* Botones adicionales para el control del slider */ }
163
+ < div className = "absolute inset-x-0 top-1/2 transform -translate-y-1/2 flex justify-between items-center px-4 md:px-8" >
164
+ < button
165
+ onClick = { prevSlide }
166
+ className = "bg-white/30 backdrop-blur-sm hover:bg-white/50 rounded-full p-2 text-white transition-all duration-300"
167
+ aria-label = "Previous slide"
168
+ >
169
+ < FaChevronLeft className = "w-5 h-5" />
170
+ </ button >
171
+ < button
172
+ onClick = { nextSlide }
173
+ className = "bg-white/30 backdrop-blur-sm hover:bg-white/50 rounded-full p-2 text-white transition-all duration-300"
174
+ aria-label = "Next slide"
175
+ >
176
+ < FaChevronRight className = "w-5 h-5" />
177
+ </ button >
178
+ </ div >
83
179
</ div >
84
180
</ div >
85
181
</ section >
86
182
87
183
88
- { /* How it works - Mejorado con tarjetas y transiciones */ }
184
+ { /* How it works - Sin cambios */ }
89
185
< section className = "max-w-5xl mx-auto mb-20 px-6" >
90
186
< div className = "text-center mb-12" >
91
187
< span className = "bg-blue-100 text-blue-700 text-sm font-medium py-1 px-3 rounded-full" > Proceso Sencillo</ span >
@@ -225,7 +321,7 @@ const Inicio = () => {
225
321
</ div >
226
322
</ section >
227
323
228
- { /* Benefits section - New */ }
324
+ { /* Benefits section - Sin cambios */ }
229
325
< section className = "bg-gradient-to-br from-blue-50 to-indigo-100 py-16" >
230
326
< div className = "max-w-5xl mx-auto px-6" >
231
327
< div className = "text-center mb-12" >
@@ -266,7 +362,7 @@ const Inicio = () => {
266
362
</ div >
267
363
</ section >
268
364
269
- { /* Footer-like info - Improved */ }
365
+ { /* Footer-like info - Sin cambios */ }
270
366
< section className = "max-w-5xl mx-auto my-12 px-6" >
271
367
< div className = "bg-gradient-to-r from-blue-600 to-indigo-600 rounded-2xl shadow-xl overflow-hidden" >
272
368
< div className = "flex flex-col md:flex-row justify-between items-center p-8 md:p-10" >
0 commit comments