MCPcopy Index your code
hub / github.com/SyntaxUI/syntaxui / MobileNavigationDialog

Function MobileNavigationDialog

src/components/MobileNavigation.tsx:49–134  ·  view source on GitHub ↗
({
  isOpen,
  close,
}: {
  isOpen: boolean
  close: () => void
})

Source from the content-addressed store, hash-verified

47const IsInsideMobileNavigationContext = createContext(false)
48
49function MobileNavigationDialog({
50 isOpen,
51 close,
52}: {
53 isOpen: boolean
54 close: () => void
55}) {
56 let pathname = usePathname()
57 let searchParams = useSearchParams()
58 let initialPathname = useRef(pathname).current
59 let initialSearchParams = useRef(searchParams).current
60
61 useEffect(() => {
62 if (pathname !== initialPathname || searchParams !== initialSearchParams) {
63 close()
64 }
65 }, [pathname, searchParams, close, initialPathname, initialSearchParams])
66
67 function onClickDialog(event: React.MouseEvent<HTMLDivElement>) {
68 if (!(event.target instanceof HTMLElement)) {
69 return
70 }
71
72 let link = event.target.closest('a')
73 if (
74 link &&
75 link.pathname + link.search + link.hash ===
76 window.location.pathname + window.location.search + window.location.hash
77 ) {
78 close()
79 }
80 }
81
82 return (
83 <Transition.Root show={isOpen} as={Fragment}>
84 <Dialog
85 onClickCapture={onClickDialog}
86 onClose={close}
87 className="fixed inset-0 z-50 lg:hidden"
88 >
89 <Transition.Child
90 as={Fragment}
91 enter="duration-300 ease-out"
92 enterFrom="opacity-0"
93 enterTo="opacity-100"
94 leave="duration-200 ease-in"
95 leaveFrom="opacity-100"
96 leaveTo="opacity-0"
97 >
98 <div className="fixed inset-0 top-14 bg-zinc-400/20 backdrop-blur-sm dark:bg-black/40" />
99 </Transition.Child>
100
101 <Dialog.Panel>
102 <Transition.Child
103 as={Fragment}
104 enter="duration-300 ease-out"
105 enterFrom="opacity-0"
106 enterTo="opacity-100"

Callers

nothing calls this directly

Calls 1

closeFunction · 0.85

Tested by

no test coverage detected