Skip to content

Commit 6b018f3

Browse files
feat: add events highlight section on homepage
1 parent 011c693 commit 6b018f3

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@vitejs/plugin-react": "^4.2.1",
2121
"baffle": "^0.3.6",
2222
"framer-motion": "^11.5.4",
23+
"gsap": "^3.12.5",
2324
"lodash": "^4.17.21",
2425
"prop-types": "^15.8.1",
2526
"react": "^18.2.0",
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import { useEffect, useRef } from "react";
2+
import gsap from "gsap";
3+
import { ScrollTrigger } from "gsap/ScrollTrigger";
4+
5+
const EventsHighlight = () => {
6+
const containerRef = useRef(null);
7+
8+
const images = [
9+
{
10+
url: "/CodeX-Website/gallery/Community Session/cs1.jpg",
11+
alt: "Image 1",
12+
side: "left",
13+
},
14+
{
15+
url: "/CodeX-Website/gallery/AIML SESSION/aiml1.jpg",
16+
alt: "Image 2",
17+
side: "right",
18+
},
19+
{
20+
url: "/CodeX-Website/gallery//AIML SESSION/aiml6.jpg",
21+
alt: "Image 3",
22+
side: "left",
23+
},
24+
{
25+
url: "/CodeX-Website/gallery/Community Session/cs3.jpg",
26+
alt: "Image 4",
27+
side: "right",
28+
},
29+
{
30+
url: "/CodeX-Website/gallery/HackTober Fest/htf1_1.jpg",
31+
alt: "Image 5",
32+
side: "left",
33+
},
34+
{
35+
url: "/CodeX-Website/gallery/Laser Lock/ll1.jpg",
36+
alt: "Image 6",
37+
side: "right",
38+
},
39+
];
40+
41+
useEffect(() => {
42+
gsap.registerPlugin(ScrollTrigger);
43+
44+
// Set up each image animation
45+
images.forEach((_, index) => {
46+
const imageSection = containerRef.current.children[index];
47+
48+
gsap.fromTo(
49+
imageSection,
50+
{
51+
opacity: 1,
52+
y: "20vh",
53+
},
54+
{
55+
opacity: 1,
56+
y: "-100vh",
57+
ease: "none",
58+
scrollTrigger: {
59+
trigger: imageSection,
60+
start: "top bottom",
61+
end: "bottom top",
62+
scrub: 1,
63+
markers: false,
64+
},
65+
},
66+
);
67+
});
68+
69+
return () => {
70+
ScrollTrigger.getAll().forEach((trigger) => trigger.kill());
71+
};
72+
}, []);
73+
74+
return (
75+
<div className="relative">
76+
{/* Fixed description */}
77+
<div className="sticky top-1/2 z-0 text-center">
78+
<h2 className="xs:text-4xl md:text-6xl lg:text-8xl font-bold text-black mb-4 text-white mt-[48vh] tracking-tighter font-black font-poppins">
79+
Events Highlight
80+
</h2>
81+
</div>
82+
83+
{/* Images container */}
84+
<div ref={containerRef} className="relative">
85+
{images.map((image, index) => (
86+
<div
87+
key={index}
88+
className={`relative h-[50vh] flex items-center justify-center ${
89+
image.side === "left" ? "ml-24" : "mr-24"
90+
}`}
91+
>
92+
<div
93+
className={`absolute ${
94+
image.side === "left" ? "left-0 z-100" : "right-0"
95+
} xs:w-[20rem] md:w-[30rem]`}
96+
>
97+
<img
98+
src={image.url}
99+
alt={image.alt}
100+
className="w-full object-contain rounded-lg shadow-xl"
101+
/>
102+
</div>
103+
</div>
104+
))}
105+
</div>
106+
</div>
107+
);
108+
};
109+
110+
export default EventsHighlight;

src/pages/Home/index.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { useContext } from "react";
22
import Heading from "@/components/Heading";
33
import { CursorVariantContext } from "@/context/CursorVariantProvider";
44
import PageTransition from "@/components/PageTransition";
5+
import EventsHighlight from "../../components/EventsHighlight";
6+
import SkewButton from "../../components/SkewButton";
57

68
function Home() {
79
const { setCursorVariantText, setCursorVariantDefault } =
@@ -24,6 +26,10 @@ function Home() {
2426
</div>
2527
</div>
2628
<Heading text="What do we do?" />
29+
<EventsHighlight />
30+
<div className="h-[50vh] mt-[50vh">
31+
<SkewButton link="/events" text="See all events" />
32+
</div>
2733
</PageTransition>
2834
);
2935
}

0 commit comments

Comments
 (0)