|
1 | 1 | import Navbar from "@/components/Navbar"; |
2 | 2 | import Footer from "@/components/Footer"; |
| 3 | +import { useState } from "react"; |
| 4 | + |
| 5 | +const MIN_YEAR = 2007; |
| 6 | +const MAX_YEAR = 2020; |
| 7 | +const DEFAULT_YEAR = 2020; |
3 | 8 |
|
4 | 9 | const OurHistory = () => { |
5 | | - // Years from 2020 to 2007 |
6 | | - const years: number[] = Array.from({ length: 14 }, (_, i) => 2020 - i); |
| 10 | + const [year, setYear] = useState(DEFAULT_YEAR); |
| 11 | + const [shouldDisplayTip, setShouldDisplayTip] = useState(true); |
7 | 12 |
|
8 | 13 | return ( |
9 | 14 | <section className="flex flex-col min-h-screen justify-between py-8 xl:px-24 md:px-10 px-5 relative overflow-hidden"> |
@@ -42,14 +47,35 @@ const OurHistory = () => { |
42 | 47 |
|
43 | 48 | <div className="border-t border-gray-300 my-5"></div> |
44 | 49 |
|
45 | | - {years.map((year: number) => ( |
46 | | - <div key={year} className="mb-4"> |
47 | | - <div className="flex flex-col items-center mb-5"> |
48 | | - <h2 className="text-2xl font-semibold mb-2">{year}</h2> |
49 | | - <img src={`/images/csesoc-team-${year}.png`} alt={`CSESoc Team ${year}`} height={600} width={600}/> |
50 | | - </div> |
| 50 | + <div className="flex flex-col items-center mt-5"> |
| 51 | + <h2 className="text-4xl font-semibold mb-5">{year}</h2> |
| 52 | + |
| 53 | + <input |
| 54 | + id="history-year-slider" |
| 55 | + type="range" |
| 56 | + min={MIN_YEAR} |
| 57 | + max={MAX_YEAR} |
| 58 | + defaultValue={DEFAULT_YEAR} |
| 59 | + step={1} |
| 60 | + className="w-full h-2 bg-blue-300 rounded-lg appearance-none cursor-pointer" |
| 61 | + onChange={(e) => { |
| 62 | + setYear(parseInt(e.target.value)) |
| 63 | + setShouldDisplayTip(false) |
| 64 | + }} |
| 65 | + /> |
| 66 | + <div className="flex flex-row w-full justify-between mt-1"> |
| 67 | + <p>{MIN_YEAR}</p> |
| 68 | + <p>{MAX_YEAR}</p> |
| 69 | + </div> |
| 70 | + |
| 71 | + {shouldDisplayTip && ( |
| 72 | + <p className="mt-5">Use the slider to see the teams from past years!</p> |
| 73 | + )} |
| 74 | + |
| 75 | + <div key={year} className="h-[600px] w-[600px] mt-10"> |
| 76 | + <img src={`/images/csesoc-team-${year}.png`} alt={`CSESoc Team ${year}`}/> |
51 | 77 | </div> |
52 | | - ))} |
| 78 | + </div> |
53 | 79 | </section> |
54 | 80 | <Footer /> |
55 | 81 | </section> |
|
0 commit comments