11import { useEffect , useState } from 'react'
22import './NavigationBar.css'
33
4- const navItems = [
4+ const topNavItems = [
55 { id : 'hero-section' , label : 'Home' } ,
66 { id : 'introduction-section' , label : 'Introduction' } ,
7+ ]
8+
9+ const vizItems = [
710 { id : 'section1' , label : 'Viz 1' } ,
811 { id : 'section2' , label : 'Viz 2' } ,
912 { id : 'section3' , label : 'Viz 3' } ,
1013 { id : 'section4' , label : 'Viz 4' } ,
1114 { id : 'section5' , label : 'Viz 5' } ,
1215 { id : 'section6' , label : 'Viz 6' } ,
16+ ]
17+
18+ const bottomNavItems = [
1319 { id : 'about-section' , label : 'Team' } ,
1420]
1521
22+ const allNavItems = [ ...topNavItems , ...vizItems , ...bottomNavItems ]
23+
1624const NavigationBar : React . FC = ( ) => {
1725 const [ isMenuOpen , setIsMenuOpen ] = useState ( false )
1826 const [ scrolled , setScrolled ] = useState ( false )
1927 const [ activeSection , setActiveSection ] = useState ( 'hero-section' )
28+ const [ isVizOpen , setIsVizOpen ] = useState ( false )
2029 const [ theme , setTheme ] = useState < 'dark' | 'light' > ( ( ) => {
2130 const stored = localStorage . getItem ( 'theme' ) as 'dark' | 'light' | null
2231 if ( stored ) return stored
@@ -51,9 +60,9 @@ const NavigationBar: React.FC = () => {
5160 setScrolled ( window . scrollY > 20 )
5261
5362 const viewportProbe = window . scrollY + window . innerHeight * 0.35
54- let currentSection = navItems [ 0 ] . id
63+ let currentSection = allNavItems [ 0 ] . id
5564
56- for ( const item of navItems ) {
65+ for ( const item of allNavItems ) {
5766 const section = document . getElementById ( item . id )
5867 if ( section && viewportProbe >= section . offsetTop ) {
5968 currentSection = item . id
@@ -81,6 +90,8 @@ const NavigationBar: React.FC = () => {
8190 setIsMenuOpen ( false )
8291 }
8392
93+ const vizIsActive = vizItems . some ( v => v . id === activeSection )
94+
8495 return (
8596 < nav className = { `navbar${ scrolled ? ' scrolled' : '' } ` } >
8697 < div className = "navbar-container" >
@@ -91,7 +102,76 @@ const NavigationBar: React.FC = () => {
91102 </ a >
92103
93104 < ul className = { `navbar-menu${ isMenuOpen ? ' active' : '' } ` } >
94- { navItems . map ( ( item ) => (
105+ { topNavItems . map ( ( item ) => (
106+ < li key = { item . id } >
107+ < a
108+ href = { `#${ item . id } ` }
109+ className = { `navbar-item${ activeSection === item . id ? ' active' : '' } ` }
110+ onClick = { ( ) => {
111+ setActiveSection ( item . id )
112+ closeMenu ( )
113+ } }
114+ >
115+ { item . label }
116+ </ a >
117+ </ li >
118+ ) ) }
119+
120+ { /* Desktop: hover dropdown */ }
121+ < li
122+ className = "navbar-dropdown-wrapper"
123+ onMouseEnter = { ( ) => setIsVizOpen ( true ) }
124+ onMouseLeave = { ( ) => setIsVizOpen ( false ) }
125+ >
126+ < span className = { `navbar-item navbar-dropdown-trigger${ vizIsActive ? ' active' : '' } ` } >
127+ Visualizations
128+ < svg
129+ className = { `dropdown-arrow${ isVizOpen ? ' open' : '' } ` }
130+ viewBox = "0 0 24 24" width = "12" height = "12"
131+ fill = "none" stroke = "currentColor" strokeWidth = "2"
132+ strokeLinecap = "round" strokeLinejoin = "round"
133+ >
134+ < path d = "M6 9l6 6 6-6" />
135+ </ svg >
136+ </ span >
137+ < ul className = { `navbar-dropdown${ isVizOpen ? ' open' : '' } ` } >
138+ < div className = "navbar-dropdown-inner" >
139+ { vizItems . map ( ( item ) => (
140+ < li key = { item . id } >
141+ < a
142+ href = { `#${ item . id } ` }
143+ className = { `navbar-item${ activeSection === item . id ? ' active' : '' } ` }
144+ onClick = { ( ) => {
145+ setActiveSection ( item . id )
146+ closeMenu ( )
147+ setIsVizOpen ( false )
148+ } }
149+ >
150+ { item . label }
151+ </ a >
152+ </ li >
153+ ) ) }
154+ </ div >
155+ </ ul >
156+ </ li >
157+
158+ { /* Mobile only: viz items shown flat */ }
159+ { vizItems . map ( ( item ) => (
160+ < li key = { `mob-${ item . id } ` } className = "mobile-viz-item" >
161+ < a
162+ href = { `#${ item . id } ` }
163+ className = { `navbar-item${ activeSection === item . id ? ' active' : '' } ` }
164+ onClick = { ( ) => {
165+ setActiveSection ( item . id )
166+ closeMenu ( )
167+ } }
168+ >
169+ { item . label }
170+ </ a >
171+ </ li >
172+ ) ) }
173+
174+ { bottomNavItems . map ( ( item ) => (
95175 < li key = { item . id } >
96176 < a
97177 href = { `#${ item . id } ` }
0 commit comments