|
| 1 | +import { useRef } from 'react'; |
| 2 | +import { gsap } from 'gsap'; |
| 3 | +import { ScrollTrigger } from 'gsap/ScrollTrigger'; |
| 4 | +import { useGSAP } from '@gsap/react'; |
| 5 | +import { useRetroSound } from '../hooks/useRetroSound'; |
| 6 | +import { getTopThree, RANKED_COUNT, BANNED_COUNT } from '@/data/leaderboard'; |
| 7 | +import Podium from './Podium'; |
| 8 | +import './Leaderboard.css'; |
| 9 | + |
| 10 | +gsap.registerPlugin(ScrollTrigger); |
| 11 | + |
| 12 | +const TOP_THREE = getTopThree(); |
| 13 | + |
| 14 | +export default function Leaderboard() { |
| 15 | + const sectionRef = useRef(null); |
| 16 | + const { playHover, playClick } = useRetroSound(); |
| 17 | + |
| 18 | + useGSAP(() => { |
| 19 | + const ctx = sectionRef.current; |
| 20 | + if (!ctx) return; |
| 21 | + |
| 22 | + const cards = ctx.querySelectorAll('.lb-podium__card'); |
| 23 | + gsap.set(cards, { opacity: 0, y: 40 }); |
| 24 | + gsap.to(cards, { |
| 25 | + opacity: 1, |
| 26 | + y: 0, |
| 27 | + duration: 0.9, |
| 28 | + stagger: 0.12, |
| 29 | + ease: 'expo.out', |
| 30 | + scrollTrigger: { |
| 31 | + trigger: ctx, |
| 32 | + start: 'top 75%', |
| 33 | + }, |
| 34 | + }); |
| 35 | + }, { scope: sectionRef }); |
| 36 | + |
| 37 | + return ( |
| 38 | + <section id="leaderboard" className="section lb-section" ref={sectionRef}> |
| 39 | + <div className="container"> |
| 40 | + <header className="lb-section__header"> |
| 41 | + <span className="section__label">Final_Standings</span> |
| 42 | + <h2 className="section__title">Hall of Fame</h2> |
| 43 | + <p className="section__subtitle"> |
| 44 | + The dust has settled. Out of {RANKED_COUNT} ranked teams, these |
| 45 | + three claimed the podium. |
| 46 | + </p> |
| 47 | + </header> |
| 48 | + |
| 49 | + <Podium teams={TOP_THREE} /> |
| 50 | + |
| 51 | + <div className="lb-section__cta"> |
| 52 | + <a |
| 53 | + href="/leaderboard" |
| 54 | + className="btn btn--secondary" |
| 55 | + onMouseEnter={playHover} |
| 56 | + onClick={playClick} |
| 57 | + > |
| 58 | + View Full Scoreboard |
| 59 | + <svg |
| 60 | + className="btn__arrow" |
| 61 | + viewBox="0 0 24 24" |
| 62 | + fill="none" |
| 63 | + stroke="currentColor" |
| 64 | + strokeWidth="2" |
| 65 | + strokeLinecap="round" |
| 66 | + strokeLinejoin="round" |
| 67 | + aria-hidden="true" |
| 68 | + > |
| 69 | + <line x1="5" y1="12" x2="19" y2="12" /> |
| 70 | + <polyline points="12 5 19 12 12 19" /> |
| 71 | + </svg> |
| 72 | + </a> |
| 73 | + <p className="lb-section__note"> |
| 74 | + {BANNED_COUNT} teams were disqualified for rule violations and hold no rank. |
| 75 | + </p> |
| 76 | + </div> |
| 77 | + </div> |
| 78 | + </section> |
| 79 | + ); |
| 80 | +} |
0 commit comments