@@ -10,6 +10,7 @@ import { Badge } from "../../_components/badge"
10
10
import MenuIcon from "../pixelarticons/menu.svg?svgr"
11
11
import CloseIcon from "../pixelarticons/close.svg?svgr"
12
12
import { GraphQLConfLogoLink } from "./graphql-conf-logo-link"
13
+ import { Anchor } from "../../_design-system/anchor"
13
14
14
15
export interface NavbarProps {
15
16
links : { href : string ; children : React . ReactNode ; "aria-disabled" ?: true } [ ]
@@ -30,6 +31,15 @@ export function Navbar({ links, year }: NavbarProps): ReactElement {
30
31
31
32
useEffect ( ( ) => {
32
33
document . body . style . overflow = mobileDrawerOpen ? "hidden" : "auto"
34
+ if ( mobileDrawerOpen ) {
35
+ const closeOnEscape = ( event : KeyboardEvent ) => {
36
+ if ( event . key === "Escape" ) setMobileDrawerOpen ( false )
37
+ }
38
+ document . addEventListener ( "keydown" , closeOnEscape )
39
+ return ( ) => {
40
+ document . removeEventListener ( "keydown" , closeOnEscape )
41
+ }
42
+ }
33
43
} , [ mobileDrawerOpen ] )
34
44
35
45
return (
@@ -79,27 +89,27 @@ export function Navbar({ links, year }: NavbarProps): ReactElement {
79
89
< div className = "flex w-full flex-col lg:mt-0 lg:block" >
80
90
{ links . map (
81
91
( { "aria-disabled" : isDisabled , children, ...link } ) => (
82
- < NextLink
92
+ < Anchor
83
93
aria-disabled = { isDisabled }
84
94
key = { link . href }
85
95
{ ...link }
86
- // if external link, open in new tab
87
- { ...( link . href . startsWith ( "https" ) && {
88
- target : "_blank" ,
89
- rel : "noopener noreferrer" ,
90
- } ) }
91
96
className = { clsx (
92
97
"p-5 underline-offset-4 hover:underline aria-disabled:pointer-events-none max-lg:text-base" ,
93
98
pathname === link . href && "underline" ,
94
99
) }
100
+ onClick = { ( ) => {
101
+ if ( mobileDrawerOpen ) {
102
+ setMobileDrawerOpen ( false )
103
+ }
104
+ } }
95
105
>
96
106
{ children }
97
107
{ isDisabled && (
98
108
< sup className = "ml-2" >
99
109
< Badge className = "text-white" > Soon</ Badge >
100
110
</ sup >
101
111
) }
102
- </ NextLink >
112
+ </ Anchor >
103
113
) ,
104
114
) }
105
115
</ div >
0 commit comments