1+ import { useEffect , useRef } from "react" ;
2+ import { gsap } from "gsap" ;
3+ import { ScrollTrigger } from "gsap/ScrollTrigger" ;
14import { Link } from "react-router-dom" ;
25import Marquee from "react-fast-marquee" ;
36import Card from "@/components/Card" ;
47
8+ gsap . registerPlugin ( ScrollTrigger ) ;
9+
510export default function AboutSection ( ) {
611 const images1 = [
712 {
@@ -79,12 +84,85 @@ export default function AboutSection() {
7984 } ,
8085 ] ;
8186
87+ const paragraphRef = useRef ( null ) ;
88+
89+ useEffect ( ( ) => {
90+ const paragraph = paragraphRef . current ;
91+
92+ const originalSpan = paragraph . querySelector ( ".text-primary" ) ;
93+ const highlightedText = originalSpan . textContent ;
94+
95+ // Split all text nodes while preserving the special span
96+ const splitText = ( node ) => {
97+ if ( node . nodeType === 3 ) {
98+ // Text node
99+ const letters = node . textContent . split ( "" ) ;
100+ const fragments = letters . map ( ( letter ) => {
101+ const span = document . createElement ( "span" ) ;
102+ span . className = "inline-block letter-span" ;
103+ span . innerHTML = letter === " " ? " " : letter ;
104+ return span ;
105+ } ) ;
106+ node . replaceWith ( ...fragments ) ;
107+ } else if ( node . classList ?. contains ( "text-primary" ) ) {
108+ // For highlighted text, split but add special class
109+ const letters = node . textContent . split ( "" ) ;
110+ const fragments = letters . map ( ( letter ) => {
111+ const span = document . createElement ( "span" ) ;
112+ span . className = "inline-block letter-span highlighted" ;
113+ span . innerHTML = letter === " " ? " " : letter ;
114+ return span ;
115+ } ) ;
116+ node . replaceWith ( ...fragments ) ;
117+ } else {
118+ [ ...node . childNodes ] . forEach ( ( child ) => splitText ( child ) ) ;
119+ }
120+ } ;
121+
122+ // Clone the paragraph to preserve original structure
123+ const clone = paragraph . cloneNode ( true ) ;
124+ splitText ( clone ) ;
125+ paragraph . innerHTML = clone . innerHTML ;
126+
127+ // Create a timeline for synchronized animations
128+ const tl = gsap . timeline ( {
129+ scrollTrigger : {
130+ trigger : paragraph ,
131+ start : "top 80%" ,
132+ end : "top 20%" ,
133+ scrub : true ,
134+ } ,
135+ } ) ;
136+
137+ // Animate regular text
138+ tl . fromTo (
139+ paragraph . querySelectorAll ( ".letter-span:not(.highlighted)" ) ,
140+ { color : "#595959" } ,
141+ {
142+ color : "#B7AB98" ,
143+ stagger : 0.02 ,
144+ } ,
145+ 0 , // Start at the beginning of the timeline
146+ ) ;
147+
148+ // Animate highlighted text
149+ tl . fromTo (
150+ paragraph . querySelectorAll ( ".highlighted" ) ,
151+ { color : "#595959" } ,
152+ {
153+ color : "#E76941" ,
154+ stagger : 0.02 ,
155+ } ,
156+ 0 , // Start at the same time as regular text
157+ ) ;
158+ } , [ ] ) ;
159+
82160 return (
83161 < >
84- < section className = "relative min-h-fit bg-secondary -dark text-white py-12 px-4 md:px-6 lg:px-8 overflow-hidden" >
162+ < section className = "relative min-h-fit bg-background -dark text-white py-12 md:px-6 lg:px-12 overflow-hidden" >
85163 < div className = "absolute top-4 -left-1 w-8 h-8 bg-white rounded-full opacity-100" />
86164 < div className = "absolute -top-2 right-20 w-20 h-20 bg-primary-dark rounded-full opacity-100 z-10" />
87- < div className = "max-w-full mx-auto px-12 relative z-20" >
165+ < div className = "max-w-full mx-auto relative z-20" >
88166 < h1
89167 className = "text-secondary-dark shadow-black font-poppins font-extrabold text-4xl md:text-6xl lg:text-8xl mb-12 relative z-20"
90168 style = { {
@@ -95,28 +173,23 @@ export default function AboutSection() {
95173 </ h1 >
96174
97175 < div className = "mb-16 max-w-full relative" >
98- < p className = "text-xl md:text-3xl font-poppins font-bold leading-relaxed" >
99- < span className = "text-text-aboutuslight" >
100- Codex is the coding club at{ " " }
101- </ span >
102- < span className = "text-text-aboutusorange" >
176+ < p
177+ ref = { paragraphRef }
178+ className = "text-xl md:text-4xl md:leading-snug font-poppins font-semibold"
179+ >
180+ Codex is the coding club at{ " " }
181+ < span className = "text-primary" >
103182 Symbiosis Institute of Technology
104- </ span >
105- < span className = "text-text-aboutuslight" >
106- { " " }
107- that brings together students passionate about technology and
108- programming. Our club is committed to creating an engaging
109- environment{ " " }
110- </ span >
111- < span className = "text-text-aboutusdark" >
112- where members can learn, collaborate, and grow their coding
113- expertise through a variety of activities and events.
114- </ span >
183+ </ span > { " " }
184+ that brings together students passionate about technology and
185+ programming. Our club is committed to creating an engaging
186+ environment where members can learn, collaborate, and grow their
187+ coding expertise through a variety of activities and events.
115188 </ p >
116189 < Link to = "/about-us" >
117190 < button
118191 type = "button"
119- className = "absolute -bottom-6 right-0 text-xl underline text-text-aboutuslight hover:text-text-light transition-colors"
192+ className = "absolute -bottom-6 right-0 text-xl underline text-primary hover:text-text-light transition-colors"
120193 >
121194 Know More
122195 </ button >
0 commit comments