Skip to content

Commit 9e4b25b

Browse files
committed
Update mobile navbar layout. Add a single-panel mobile menu component
1 parent b997c3e commit 9e4b25b

3 files changed

Lines changed: 35 additions & 4 deletions

File tree

‎src/css/custom.css‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,10 @@ html[data-theme="dark"] .theme-toggle .icon-moon {
442442
margin-right: auto;
443443
}
444444

445-
.navbar-sidebar__brand .theme-toggle {
446-
margin: 0;
445+
/* The theme switch lives in the page navbar; the sidebar is docs navigation only */
446+
.navbar-sidebar__brand .theme-toggle,
447+
.navbar-sidebar__back {
448+
display: none;
447449
}
448450
}
449451

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from "react";
2+
import clsx from "clsx";
3+
import { useNavbarSecondaryMenu } from "@docusaurus/theme-common/internal";
4+
import { ThemeClassNames } from "@docusaurus/theme-common";
5+
6+
// Single-panel mobile menu: the version selector (the only main-menu item shown on
7+
// mobile) above the docs sidebar, instead of the default two sliding panels.
8+
export default function NavbarMobileSidebarLayout({ header, primaryMenu, secondaryMenu }) {
9+
const { content } = useNavbarSecondaryMenu();
10+
const hasSidebar = Boolean(content);
11+
12+
return (
13+
<div className={clsx(ThemeClassNames.layout.navbar.mobileSidebar.container, "navbar-sidebar")}>
14+
{header}
15+
<div className="navbar-sidebar__items">
16+
<div
17+
className={clsx(ThemeClassNames.layout.navbar.mobileSidebar.panel, "navbar-sidebar__item menu")}
18+
>
19+
{primaryMenu}
20+
{hasSidebar && secondaryMenu}
21+
</div>
22+
</div>
23+
</div>
24+
);
25+
}

‎src/theme/NavbarItem/GitHubNavbarItem.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export default function GitHubNavbarItem({ mobile = false }) {
44
const [stars, setStars] = useState(null);
55

66
useEffect(() => {
7+
if (mobile) return undefined;
8+
79
const controller = new AbortController();
810

911
async function loadStars() {
@@ -28,10 +30,12 @@ export default function GitHubNavbarItem({ mobile = false }) {
2830

2931
loadStars();
3032
return () => controller.abort();
31-
}, []);
33+
}, [mobile]);
34+
35+
if (mobile) return null;
3236

3337
return (
34-
<div className={mobile ? "menu__list-item" : "navbar__item"}>
38+
<div className="navbar__item">
3539
<a
3640
className="nav-icon nav-github"
3741
href="https://github.com/FEAScript/FEAScript-core"

0 commit comments

Comments
 (0)