@@ -7,11 +7,12 @@ import Link from "next/link";
77import { useEffect , useState } from "react" ;
88import { ScrollShadow } from "../components/ui/ScrollShadow/ScrollShadow" ;
99import { Button } from "../components/ui/button" ;
10- import { Sidebar } from "../components/ui/sidebar" ;
11- import { navLinks } from "./navLinks" ;
10+ import { Sidebar , type SidebarLink } from "../components/ui/sidebar" ;
1211import { otherLinks } from "./otherLinks" ;
1312
14- export function MobileHeader ( ) {
13+ export function MobileHeader ( props : {
14+ links : SidebarLink [ ] ;
15+ } ) {
1516 const [ isOpen , setIsOpen ] = useState ( false ) ;
1617
1718 useEffect ( ( ) => {
@@ -27,47 +28,49 @@ export function MobileHeader() {
2728 } , [ isOpen ] ) ;
2829
2930 return (
30- // biome-ignore lint/a11y/useKeyWithClickEvents: <explanation>
31- < header
32- className = "sticky top-0 z-10 flex justify-between gap-4 border-b bg-background px-4 py-4 xl:hidden "
33- onClick = { ( e ) => {
34- if ( e . target instanceof HTMLAnchorElement ) {
35- setIsOpen ( false ) ;
36- }
37- } }
38- >
39- < Link
40- className = "flex items-center gap-3"
41- href = "/"
42- aria-label = "thirdweb Docs"
43- title = "thirdweb Docs"
44- >
45- < Image src = { thirdwebIconSrc } className = "size-7" alt = "" />
46- < span className = "font-bold text-xl leading-none tracking-tight" >
47- Playground
48- </ span >
49- </ Link >
50- < Button
51- variant = "outline"
52- className = "!h-auto p-2"
53- onClick = { ( ) => {
54- setIsOpen ( ( v ) => ! v ) ;
55- } }
56- >
57- { ! isOpen ? (
58- < MenuIcon className = "size-6" />
59- ) : (
60- < XIcon className = "size-6" />
61- ) }
62- </ Button >
31+ < >
32+ < header className = "sticky top-0 z-10 flex justify-between gap-4 border-b bg-background px-4 py-4 xl:hidden" >
33+ < Link
34+ className = "flex items-center gap-3"
35+ href = "/"
36+ aria-label = "thirdweb Docs"
37+ title = "thirdweb Docs"
38+ >
39+ < Image src = { thirdwebIconSrc } className = "size-7" alt = "" />
40+ < span className = "font-bold text-xl leading-none tracking-tight" >
41+ Playground
42+ </ span >
43+ </ Link >
44+ < Button
45+ variant = "outline"
46+ className = "!h-auto p-2"
47+ onClick = { ( ) => {
48+ setIsOpen ( ( v ) => ! v ) ;
49+ } }
50+ >
51+ { ! isOpen ? (
52+ < MenuIcon className = "size-6" />
53+ ) : (
54+ < XIcon className = "size-6" />
55+ ) }
56+ </ Button >
57+ </ header >
58+
6359 { isOpen && (
64- < div className = "fade-in-0 slide-in-from-top-5 fixed top-[75px] right-0 bottom-0 left-0 z-50 flex animate-in flex-col bg-background duration-200" >
60+ < div
61+ className = "fade-in-0 slide-in-from-top-5 fixed top-[75px] right-0 bottom-0 left-0 z-50 flex animate-in flex-col bg-background duration-200"
62+ onClickCapture = { ( e ) => {
63+ if ( e . target instanceof HTMLElement && e . target . closest ( "a" ) ) {
64+ setIsOpen ( false ) ;
65+ }
66+ } }
67+ >
6568 < div className = "relative flex max-h-full flex-1 flex-col overflow-hidden" >
6669 < ScrollShadow
6770 className = "grow px-6"
6871 scrollableClassName = "max-h-full pt-6"
6972 >
70- < Sidebar links = { navLinks } />
73+ < Sidebar links = { props . links } />
7174 </ ScrollShadow >
7275 </ div >
7376
@@ -87,6 +90,6 @@ export function MobileHeader() {
8790 </ div >
8891 </ div >
8992 ) }
90- </ header >
93+ </ >
9194 ) ;
9295}
0 commit comments