diff --git a/src/components/navigation/sidebars/nav/index.tsx b/src/components/navigation/sidebars/nav/index.tsx index 95c57ec..12559c0 100644 --- a/src/components/navigation/sidebars/nav/index.tsx +++ b/src/components/navigation/sidebars/nav/index.tsx @@ -37,10 +37,11 @@ const NavComponent: Component = props => { const handleClickOutside = (event: MouseEvent) => { const isLink = "href" in (event.target || {}); + const isInBody = document.body.contains(event.target as Node); if ( isLink || - (document.body.contains(event.target as Node) && - !navRef.contains(event.target as Node)) + !isInBody || + (isInBody && !navRef.contains(event.target as Node)) ) { setOpen(false); } @@ -70,11 +71,8 @@ const NavComponent: Component = props => { ref={navRef!} >
toggle(e)}> - {open() ? ( - - ) : ( - - )} + +
= props => { }); createEffect(() => { - const tocRoot = document.getElementById("toc")!; if (open()) { window.addEventListener("click", handleClickOutside); document.body.style.overflow = "hidden"; diff --git a/src/styles/docs/nav/nav.css b/src/styles/docs/nav/nav.css index 2bfebb1..ce91117 100644 --- a/src/styles/docs/nav/nav.css +++ b/src/styles/docs/nav/nav.css @@ -5,6 +5,17 @@ display: none; } +.nav-icon { + opacity: 0; + position: absolute; + transition: opacity 0.6s; +} + +.nav-icon.active { + opacity: 1; + position: relative; +} + .nav-toggle { position: unset; height: 24px;