1
1
import React , { useEffect , useState } from 'react' ;
2
2
import Layout from '@theme/Layout' ;
3
3
import Head from '@docusaurus/Head' ;
4
+ import type confettiType from 'canvas-confetti' ;
4
5
5
- const GiveawayPage = ( ) => {
6
+ const GiveawayPage : React . FC = ( ) => {
6
7
const [ timeLeft , setTimeLeft ] = useState ( {
7
8
days : '--' ,
8
9
hours : '--' ,
9
10
minutes : '--' ,
10
11
seconds : '--' ,
11
12
} ) ;
12
13
13
- const countdownTarget = new Date ( '2025-08-15T23:59:59' ) . getTime ( ) ; // Customize this date
14
+ const countdownTarget = new Date ( '2025-08-15T23:59:59' ) . getTime ( ) ; // Update the deadline if needed
14
15
16
+ // Countdown Timer Effect
15
17
useEffect ( ( ) => {
16
18
const interval = setInterval ( ( ) => {
17
19
const now = new Date ( ) . getTime ( ) ;
@@ -36,14 +38,27 @@ const GiveawayPage = () => {
36
38
} ) ;
37
39
} , 1000 ) ;
38
40
39
- // Confetti burst
40
- import ( 'canvas-confetti' ) . then ( confetti => {
41
- confetti . default ( { particleCount : 150 , spread : 70 , origin : { y : 0.6 } } ) ;
42
- } ) ;
43
-
44
41
return ( ) => clearInterval ( interval ) ;
45
42
} , [ ] ) ;
46
43
44
+ // Confetti Effect
45
+ useEffect ( ( ) => {
46
+ const runConfetti = async ( ) => {
47
+ const module = await import ( 'canvas-confetti' ) ;
48
+ const confetti = module . default as typeof confettiType ;
49
+
50
+ confetti ( {
51
+ particleCount : 150 ,
52
+ spread : 70 ,
53
+ origin : { y : 0.6 } ,
54
+ } ) ;
55
+ } ;
56
+
57
+ const timer = setTimeout ( runConfetti , 1000 ) ;
58
+
59
+ return ( ) => clearTimeout ( timer ) ;
60
+ } , [ ] ) ;
61
+
47
62
return (
48
63
< Layout >
49
64
< Head >
@@ -56,9 +71,9 @@ const GiveawayPage = () => {
56
71
< p className = "text-lg mb-8" > Participate now and win exclusive swag, resources, and more!</ p >
57
72
58
73
< div className = "flex justify-center gap-4 text-center mb-12" >
59
- { [ 'days' , 'hours' , 'minutes' , 'seconds' ] . map ( unit => (
74
+ { [ 'days' , 'hours' , 'minutes' , 'seconds' ] . map ( ( unit ) => (
60
75
< div key = { unit } className = "bg-white/10 px-6 py-4 rounded-xl shadow-md" >
61
- < div className = "text-3xl font-bold" > { timeLeft [ unit ] } </ div >
76
+ < div className = "text-3xl font-bold" > { timeLeft [ unit as keyof typeof timeLeft ] } </ div >
62
77
< div className = "text-sm uppercase tracking-widest" > { unit } </ div >
63
78
</ div >
64
79
) ) }
@@ -75,7 +90,6 @@ const GiveawayPage = () => {
75
90
</ tr >
76
91
</ thead >
77
92
< tbody >
78
- { /* Replace this static data with dynamic data if needed */ }
79
93
< tr className = "border-b border-white/10" >
80
94
< td > 1</ td >
81
95
< td > OpenSourcePro</ td >
@@ -95,7 +109,7 @@ const GiveawayPage = () => {
95
109
</ table >
96
110
</ div >
97
111
98
- < p className = "text-sm text-white/ 60 italic" >
112
+ < p className = "text-sm text-white text-opacity- 60 italic" >
99
113
Winners will be announced after the countdown ends. Stay active on the dashboard to climb up the leaderboard!
100
114
</ p >
101
115
</ div >
0 commit comments