Skip to content

Commit f86cbdb

Browse files
committed
add slider to our history page
1 parent 5fa1c38 commit f86cbdb

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

frontend/src/pages/about/our-history.tsx

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import Navbar from "@/components/Navbar";
22
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;
38

49
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);
712

813
return (
914
<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 = () => {
4247

4348
<div className="border-t border-gray-300 my-5"></div>
4449

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}`}/>
5177
</div>
52-
))}
78+
</div>
5379
</section>
5480
<Footer />
5581
</section>

0 commit comments

Comments
 (0)