11"use client" ;
22import { FaLinkedin , FaGithub , FaMedium } from 'react-icons/fa' ;
3- import { motion } from "motion/react" ;
3+ import { motion , useInView } from "framer- motion" ; // Import useInView
44import Timeline from '../ui/components/Timeline' ;
5- import { useEffect , useState } from 'react' ;
5+ import { useEffect , useState , useRef } from 'react' ; // Import useRef
6+ import { trackContentView } from '../tracking' ;
67
78export default function About ( ) {
89 const [ skills , setSkills ] = useState < string [ ] > ( [ ] ) ;
@@ -134,6 +135,46 @@ export default function About() {
134135 } ,
135136 ] ;
136137
138+ // Ref for the "My Journey" section
139+ const journeySectionRef = useRef ( null ) ;
140+ const isJourneySectionInView = useInView ( journeySectionRef , { once : true } ) ; // Trigger only once
141+
142+ useEffect ( ( ) => {
143+ if ( isJourneySectionInView ) {
144+ trackContentView ( 'journey_start' ) ;
145+ }
146+ } , [ isJourneySectionInView ] ) ;
147+
148+ // Ref for the "Introduction" section
149+ const introSectionRef = useRef ( null ) ;
150+ const isIntroSectionInView = useInView ( introSectionRef , { once : true } ) ;
151+
152+ useEffect ( ( ) => {
153+ if ( isIntroSectionInView ) {
154+ trackContentView ( 'introduction' ) ;
155+ }
156+ } , [ isIntroSectionInView ] ) ;
157+
158+ // Ref for the "Top Links" (Social Links) section
159+ const topLinksSectionRef = useRef ( null ) ;
160+ const isTopLinksSectionInView = useInView ( topLinksSectionRef , { once : true } ) ;
161+
162+ useEffect ( ( ) => {
163+ if ( isTopLinksSectionInView ) {
164+ trackContentView ( 'top_link' ) ;
165+ }
166+ } , [ isTopLinksSectionInView ] ) ;
167+
168+ // Ref for the "Skills" section
169+ const skillsSectionRef = useRef ( null ) ;
170+ const isSkillsSectionInView = useInView ( skillsSectionRef , { once : true } ) ;
171+
172+ useEffect ( ( ) => {
173+ if ( isSkillsSectionInView ) {
174+ trackContentView ( 'skills' ) ;
175+ }
176+ } , [ isSkillsSectionInView ] ) ;
177+
137178 return (
138179 < div className = "min-h-screen" role = "main" aria-labelledby = "about-section" >
139180 < section id = "about" className = "container mx-auto py-16 px-4" >
@@ -142,6 +183,7 @@ export default function About() {
142183 initial = { { opacity : 0 , y : 20 } }
143184 animate = { { opacity : 1 , y : 0 } }
144185 transition = { { duration : 0.8 } }
186+ ref = { introSectionRef } // Assign ref
145187 className = "text-center"
146188 >
147189 < h1 id = "about-section" className = "text-5xl font-bold mb-4" >
@@ -156,42 +198,51 @@ export default function About() {
156198 </ motion . div >
157199
158200 { /* Social Links */ }
159- < div className = "flex justify-center space-x-6 mt-8" aria-label = "Social Media Links" >
160- < a
161- href = "https://www.linkedin.com/in/abhinavkumar985/"
162- target = "_blank"
163- rel = "noopener noreferrer"
164- className = "text-5xl hover:text-accent transition-colors"
165- style = { { color : 'rgb(10, 102, 194)' } }
166- aria-label = "LinkedIn Profile"
167- >
168- < FaLinkedin />
169- </ a >
170- < a
171- href = "https://github.com/abhinavkumar985"
172- target = "_blank"
173- rel = "noopener noreferrer"
174- className = "text-5xl hover:text-accent transition-colors"
175- aria-label = "GitHub Profile"
176- >
177- < FaGithub />
178- </ a >
179- < a
180- href = "https://medium.com/@abhinavkumar985"
181- target = "_blank"
182- rel = "noopener noreferrer"
183- className = "text-5xl hover:text-accent transition-colors"
184- aria-label = "Medium Blog"
185- >
186- < FaMedium />
187- </ a >
188- </ div >
201+ < motion . div
202+ initial = { { opacity : 0 , y : 20 } }
203+ animate = { { opacity : 1 , y : 0 } }
204+ transition = { { duration : 0.8 } }
205+ ref = { topLinksSectionRef } // Assign ref
206+ className = "text-center"
207+ >
208+ < div className = "flex justify-center space-x-6 mt-8" aria-label = "Social Media Links" >
209+ < a
210+ href = "https://www.linkedin.com/in/abhinavkumar985/"
211+ target = "_blank"
212+ rel = "noopener noreferrer"
213+ className = "text-5xl hover:text-accent transition-colors"
214+ style = { { color : 'rgb(10, 102, 194)' } }
215+ aria-label = "LinkedIn Profile"
216+ >
217+ < FaLinkedin />
218+ </ a >
219+ < a
220+ href = "https://github.com/abhinavkumar985"
221+ target = "_blank"
222+ rel = "noopener noreferrer"
223+ className = "text-5xl hover:text-accent transition-colors"
224+ aria-label = "GitHub Profile"
225+ >
226+ < FaGithub />
227+ </ a >
228+ < a
229+ href = "https://medium.com/@abhinavkumar985"
230+ target = "_blank"
231+ rel = "noopener noreferrer"
232+ className = "text-5xl hover:text-accent transition-colors"
233+ aria-label = "Medium Blog"
234+ >
235+ < FaMedium />
236+ </ a >
237+ </ div >
238+ </ motion . div >
189239
190240 { /* Timeline Section */ }
191241 < motion . div
192242 initial = { { opacity : 0 , y : 20 } }
193243 animate = { { opacity : 1 , y : 0 } }
194244 transition = { { duration : 0.8 , delay : 0.2 } }
245+ ref = { journeySectionRef } // Assign the ref here
195246 className = "mt-16"
196247 >
197248 < h2 className = "text-4xl font-semibold text-center" id = "timeline-section" >
@@ -205,6 +256,7 @@ export default function About() {
205256 initial = { { opacity : 0 , y : 20 } }
206257 animate = { { opacity : 1 , y : 0 } }
207258 transition = { { duration : 0.8 , delay : 0.4 } }
259+ ref = { skillsSectionRef } // Assign ref
208260 className = "mt-16"
209261 >
210262 < h2 className = "text-3xl font-semibold text-center mb-8" id = "skills-section" >
0 commit comments