Skip to content

Commit

Permalink
fix: hide TOC hamburger when TOC is hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed Jul 31, 2024
1 parent 1e6269a commit 7ca75ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
26 changes: 14 additions & 12 deletions packages/site/src/components/Navigation/TopNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export function NavItems({ nav }: { nav?: SiteManifest['nav'] }) {
);
}

export function TopNav() {
export function TopNav({ hideToc }: { hideToc?: boolean }) {
const [open, setOpen] = useNavOpen();
const config = useSiteManifest();
const { title, nav, actions } = config ?? {};
Expand All @@ -152,17 +152,19 @@ export function TopNav() {
<div className="bg-white/80 backdrop-blur dark:bg-stone-900/80 shadow dark:shadow-stone-700 p-3 md:px-8 fixed w-screen top-0 z-30 h-[60px]">
<nav className="flex items-center justify-between flex-wrap max-w-[1440px] mx-auto">
<div className="flex flex-row xl:min-w-[19.5rem] mr-2 sm:mr-7 justify-start items-center">
<div className="block xl:hidden">
<button
className="flex items-center border-stone-400 text-stone-800 hover:text-stone-900 dark:text-stone-200 hover:dark:text-stone-100"
onClick={() => {
setOpen(!open);
}}
>
<MenuIcon width="2rem" height="2rem" className="m-1" />
<span className="sr-only">Open Menu</span>
</button>
</div>
{!hideToc && (
<div className="block xl:hidden">
<button
className="flex items-center border-stone-400 text-stone-800 hover:text-stone-900 dark:text-stone-200 hover:dark:text-stone-100"
onClick={() => {
setOpen(!open);
}}
>
<MenuIcon width="2rem" height="2rem" className="m-1" />
<span className="sr-only">Open Menu</span>
</button>
</div>
)}
<HomeLink name={title} logo={logo} logoDark={logo_dark} logoText={logo_text} />
</div>
<div className="flex items-center flex-grow w-auto">
Expand Down
2 changes: 1 addition & 1 deletion themes/book/app/routes/$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function ArticlePageAndNavigation({
const { container, toc } = useTocHeight(top, inset);
return (
<UiStateProvider>
<TopNav />
<TopNav hideToc={ hide_toc } />
<Navigation
tocRef={toc}
hide_toc={hide_toc}
Expand Down

0 comments on commit 7ca75ea

Please sign in to comment.