Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🍔 Remove TOC hamburger icon when TOC itself is hidden #442

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/forty-panthers-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@myst-theme/article': patch
'@myst-theme/site': patch
'@myst-theme/book': patch
---

Hide TOC hamburger when TOC is hidden, remove unused option
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
1 change: 0 additions & 1 deletion themes/article/app/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export interface TemplateOptions {
hide_toc?: boolean;
hide_outline?: boolean;
hide_footer_links?: boolean;
outline_maxdepth?: number;
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
Loading