@@ -2,60 +2,76 @@ import Image from "next/image";
22import * as React from "react" ;
33
44export default function ProgressBar ( { pageName } : { pageName : string } ) {
5+ const [ progressWidth , setProgressWidth ] = React . useState ( 0 ) ;
56 let progress = 0 ;
67 let titleName = "" ;
8+
79 switch ( pageName ) {
810 case "schedule" :
911 progress = 0 ;
1012 titleName = "Drone Competition Schedule" ;
1113 break ;
1214 case "format-rules" :
13- progress = 33 ;
15+ progress = 30 ;
1416 titleName = "Format & Rules" ;
1517 break ;
1618 case "guests-sponsors" :
1719 titleName = "Guests & Sponsors" ;
18- progress = 66 ;
20+ progress = 60 ;
1921 break ;
2022 case "leaderboard" :
2123 titleName = "Leaderboard" ;
22- progress = 90 ;
24+ progress = 80 ;
2325 break ;
2426 }
2527
28+ React . useEffect ( ( ) => {
29+ const updateProgress = ( ) => {
30+ if ( pageName === "leaderboard" ) {
31+ setProgressWidth ( window . innerWidth >= 768 ? 90 : 80 ) ;
32+ } else {
33+ setProgressWidth ( progress ) ;
34+ }
35+ } ;
36+
37+ updateProgress ( ) ;
38+ window . addEventListener ( "resize" , updateProgress ) ;
39+ return ( ) => window . removeEventListener ( "resize" , updateProgress ) ;
40+ } , [ pageName , progress ] ) ;
41+
2642 return (
2743 < div >
2844 < div className = "w-full flex-col justify-center" >
2945 < div className = "mb-4 flex items-center justify-center" >
30- < a className = "title-large text-center text-[50px ] text-dark md:text-[60px]" >
46+ < a className = "title-large text-center text-[30px ] text-dark md:text-[50px] lg :text-[60px]" >
3147 { titleName }
3248 </ a >
3349 </ div >
34- < div className = "flex flex-1" >
50+ < div className = "flex flex-1 items-center " >
3551 < div
3652 className = "flex-shrink-0"
3753 style = { {
38- width : `${ progress } %` ,
54+ width : `${ progressWidth } %` ,
3955 transition : "width 3s ease-in-out" ,
4056 } }
4157 />
42- < div >
58+ < div className = "flex-shrink-0" >
4359 < Image
4460 src = "/Drone.svg"
4561 alt = "Drone"
46- width = "50 "
47- height = "20 "
48- className = "object-contain"
62+ width = "30 "
63+ height = "12 "
64+ className = "object-contain md:h-[16px] md:w-[40px] lg:h-[20px] lg:w-[50px] "
4965 />
5066 </ div >
5167
52- < div className = "ml-auto" >
68+ < div className = "ml-auto flex-shrink-0 " >
5369 < Image
5470 src = "/FinishFlag.svg"
5571 alt = "Finish Flag"
56- width = "25 "
57- height = "10 "
58- className = "object-contain"
72+ width = "20 "
73+ height = "8 "
74+ className = "object-contain md:h-[12px] md:w-[30px] lg:h-[20px] lg:w-[50px] "
5975 />
6076 </ div >
6177 </ div >
0 commit comments