11"use client" ;
22
3+ import Image from "next/image" ;
4+ import Link from "next/link" ;
35import { usePathname } from "next/navigation" ;
46import { useEffect , useState } from "react" ;
57
68interface MenuItem {
79 name : string ;
810 href : string ;
911 external ?: boolean ;
12+ newTab ?: boolean ;
1013}
1114
1215const menuItems : MenuItem [ ] = [
@@ -75,10 +78,11 @@ export default function Menu() {
7578 } }
7679 aria-label = "Open menu"
7780 aria-expanded = { isOpen } >
78- { /* eslint-disable-next-line @next/next/no-img-element */ }
79- < img
81+ < Image
8082 src = "/images/Hiero-Icon-Nav-Menu.svg"
8183 alt = "Open menu"
84+ width = { 20 }
85+ height = { 20 }
8286 className = "w-5 h-5"
8387 />
8488 </ button >
@@ -88,10 +92,11 @@ export default function Menu() {
8892 className = { `absolute hidden items-center justify-center w-full h-screen bg-black top-0 left-0 text-white sm:relative sm:h-auto sm:top-auto sm:bg-transparent sm:left-auto sm:w-9/12 sm:max-w-xl sm:block ${ isOpen ? "active-navigation" : "" } ` }
8993 aria-hidden = { isDesktop ? false : ! isOpen } >
9094 < div className = "absolute top-[27px] sm:hidden" >
91- { /* eslint-disable-next-line @next/next/no-img-element */ }
92- < img
95+ < Image
9396 src = "/images/Hiero-Icon-wLogo-white-text.svg"
9497 alt = "Hiero logo"
98+ width = { 128 }
99+ height = { 40 }
95100 className = "h-[40px] w-[128px]"
96101 />
97102 </ div >
@@ -103,29 +108,48 @@ export default function Menu() {
103108 setIsOpen ( false ) ;
104109 } }
105110 aria-label = "Close menu" >
106- { /* eslint-disable-next-line @next/next/no-img-element */ }
107- < img
111+ < Image
108112 src = "/images/Hiero-Icon-ModalClose.svg"
109113 alt = "Close menu"
114+ width = { 20 }
115+ height = { 20 }
110116 className = "w-5 h-5"
111117 />
112118 </ button >
113119
114120 < ul id = "menu" className = "flex flex-col sm:flex-row justify-between" >
115121 { menuItems . map ( item => {
122+ const active = isActive ( item . href ) ;
123+ const isExternal = item . external ?? item . href . startsWith ( "http" ) ;
124+ const openInNewTab = item . newTab ?? isExternal ;
125+
116126 return (
117127 < li
118128 key = { item . name }
119129 className = { `text-center sm:text-left ${ item . name === "Connect" ? "sm:hidden" : "" } ` . trim ( ) } >
120- < a
121- href = { item . href }
122- className = { isActive ( item . href ) ? "active" : "" }
123- aria-current = { isActive ( item . href ) ? "page" : undefined }
124- onClick = { ( ) => {
125- setIsOpen ( false ) ;
126- } } >
127- { item . name }
128- </ a >
130+ { isExternal ? (
131+ < a
132+ href = { item . href }
133+ target = { openInNewTab ? "_blank" : undefined }
134+ rel = { openInNewTab ? "noopener noreferrer" : undefined }
135+ className = { active ? "active" : "" }
136+ aria-current = { active ? "page" : undefined }
137+ onClick = { ( ) => {
138+ setIsOpen ( false ) ;
139+ } } >
140+ { item . name }
141+ </ a >
142+ ) : (
143+ < Link
144+ href = { item . href }
145+ className = { active ? "active" : "" }
146+ aria-current = { active ? "page" : undefined }
147+ onClick = { ( ) => {
148+ setIsOpen ( false ) ;
149+ } } >
150+ { item . name }
151+ </ Link >
152+ ) }
129153 </ li >
130154 ) ;
131155 } ) }
@@ -134,12 +158,13 @@ export default function Menu() {
134158 < a
135159 href = "https://github.com/hiero-ledger/"
136160 target = "_blank"
137- rel = "noopener"
161+ rel = "noopener noreferrer "
138162 className = "flex" >
139- { /* eslint-disable-next-line @next/next/no-img-element */ }
140- < img
163+ < Image
141164 src = "/images/Hiero-Icon-Github.svg"
142165 alt = "GitHub"
166+ width = { 35 }
167+ height = { 35 }
143168 className = "h-[35px] w-[35px] sm:h-[17px] sm:w-[17px]"
144169 />
145170 </ a >
0 commit comments