1- import { useState , useEffect } from "react" ;
2- import { Menu , X , Home , FileText , Briefcase , Code , Award , GraduationCap , Mail , FileUser } from "lucide-react" ;
1+ import { useEffect , useState } from "react" ;
2+ import { Award , Briefcase , Code , FileText , GraduationCap , Home , Mail , Menu , X } from "lucide-react" ;
33import styles from "./navbar.module.css" ;
44
55interface NavbarProps {
66 onNavigateToContact ?: ( ) => void ;
77 onNavigateToCV ?: ( ) => void ;
8+ currentPage ?: string ;
89}
910
10- export function Navbar ( { onNavigateToContact, onNavigateToCV} : NavbarProps = { } ) {
11+ export function Navbar ( { onNavigateToContact, onNavigateToCV, currentPage } : NavbarProps = { } ) {
1112 const [ isScrolled , setIsScrolled ] = useState ( false ) ;
1213 const [ isMobileMenuOpen , setIsMobileMenuOpen ] = useState ( false ) ;
1314 const [ activeSection , setActiveSection ] = useState ( "hero" ) ;
@@ -17,15 +18,15 @@ export function Navbar({onNavigateToContact, onNavigateToCV}: NavbarProps = {})
1718 setIsScrolled ( window . scrollY > 50 ) ;
1819
1920 // Determine active section based on scroll position
20- const sections = [ "hero" , "overview" , "skills" , "experience" , 'project' , "education" , "awards" , "contact" ] ;
21+ const sections = [ "hero" , "overview" , "skills" , "experience" , 'project' , "education" , "awards" , "contact" , "cv" ] ;
2122 const scrollPosition = window . scrollY + window . innerHeight / 2 ;
2223 const documentHeight = document . documentElement . scrollHeight ;
2324 const windowHeight = window . innerHeight ;
2425 const scrollBottom = window . scrollY + windowHeight ;
2526
2627 // Check if we're near the bottom of the page (within 200px)
27- if ( documentHeight - scrollBottom < 200 ) {
28- setActiveSection ( "contact " ) ;
28+ if ( currentPage === 'cv' ) {
29+ setActiveSection ( "cv " ) ;
2930 return ;
3031 }
3132
@@ -69,6 +70,7 @@ export function Navbar({onNavigateToContact, onNavigateToCV}: NavbarProps = {})
6970 { id : "education" , label : "Education" , icon : GraduationCap } ,
7071 { id : "awards" , label : "Awards" , icon : Award } ,
7172 { id : "contact" , label : "Contact" , icon : Mail } ,
73+ { id : "cv" , label : "CV" , icon : FileText } ,
7274 ] ;
7375
7476 const handleContactClick = ( ) => {
@@ -90,7 +92,7 @@ export function Navbar({onNavigateToContact, onNavigateToCV}: NavbarProps = {})
9092 return (
9193 < nav className = { `${ styles . navbar } ${ isScrolled ? styles . scrolled : "" } ` } >
9294 < div className = { styles . navContainer } >
93- { isScrolled || onNavigateToCV ? (
95+ { isScrolled ? (
9496 < button className = { styles . logo } onClick = { ( ) => scrollToSection ( "hero" ) } >
9597 < span className = { styles . logoText } > Towfiqul Islam</ span >
9698 < span className = { styles . logoSubtext } > Senior Software Engineer</ span >
@@ -100,21 +102,26 @@ export function Navbar({onNavigateToContact, onNavigateToCV}: NavbarProps = {})
100102 < span className = { styles . logoText } > </ span >
101103 < span className = { styles . logoSubtext } > </ span >
102104 </ button >
103- )
104- }
105+ ) }
105106
106107 < div className = { `${ styles . navLinks } ${ isMobileMenuOpen ? styles . mobileOpen : "" } ` } >
107108 { navItems . map ( ( item ) => {
108109 const Icon = item . icon ;
109110 return (
110- < button
111- key = { item . id }
112- onClick = { ( ) => scrollToSection ( item . id ) }
113- className = { `${ styles . navLink } ${ activeSection === item . id ? styles . active : "" } ` }
114- >
115- < Icon className = { styles . navIcon } />
116- < span > { item . label } </ span >
117- </ button >
111+ item . id === 'cv' ?
112+ ( < button onClick = { handleCVClick }
113+ className = { `${ styles . navLink } ${ activeSection === "cv" ? styles . active : "" } ` } >
114+ < FileText className = { styles . navIcon } />
115+ < span > CV</ span >
116+ </ button > ) :
117+ ( < button
118+ key = { item . id }
119+ onClick = { ( ) => scrollToSection ( item . id ) }
120+ className = { `${ styles . navLink } ${ activeSection === item . id ? styles . active : "" } ` }
121+ >
122+ < Icon className = { styles . navIcon } />
123+ < span > { item . label } </ span >
124+ </ button > )
118125 ) ;
119126 } ) }
120127 { /*<button*/ }
@@ -124,12 +131,6 @@ export function Navbar({onNavigateToContact, onNavigateToCV}: NavbarProps = {})
124131 { /* <Mail className={styles.navIcon}/>*/ }
125132 { /* <span>Contact</span>*/ }
126133 { /*</button>*/ }
127- { onNavigateToCV && (
128- < button onClick = { handleCVClick } className = { styles . navLink } >
129- < FileUser className = { styles . navIcon } />
130- < span > CV</ span >
131- </ button >
132- ) }
133134 </ div >
134135
135136 < button
0 commit comments