forked from denoland/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: design updates for secondary navbar (denoland#499)
- Loading branch information
Showing
8 changed files
with
214 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
# Generated files | ||
.docusaurus | ||
.cache-loader | ||
.deno-lock | ||
|
||
# Misc | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { type ComponentProps } from "react"; | ||
import clsx from "clsx"; | ||
import { useThemeConfig } from "@docusaurus/theme-common"; | ||
import { | ||
useHideableNavbar, | ||
useNavbarMobileSidebar, | ||
} from "@docusaurus/theme-common/internal"; | ||
import { translate } from "@docusaurus/Translate"; | ||
import NavbarMobileSidebar from "@theme/Navbar/MobileSidebar"; | ||
import type { Props } from "@theme/Navbar/Layout"; | ||
import { useLocation } from "@docusaurus/router"; // Import useLocation | ||
|
||
import styles from "./styles.module.css"; | ||
|
||
function NavbarBackdrop(props: ComponentProps<"div">) { | ||
return ( | ||
<div | ||
role="presentation" | ||
{...props} | ||
className={clsx("navbar-sidebar__backdrop", props.className)} | ||
/> | ||
); | ||
} | ||
|
||
export default function NavbarLayout({ children }: Props): JSX.Element { | ||
const { | ||
navbar: { hideOnScroll, style }, | ||
} = useThemeConfig(); | ||
const mobileSidebar = useNavbarMobileSidebar(); | ||
const { navbarRef, isNavbarVisible } = useHideableNavbar(hideOnScroll); | ||
const location = useLocation(); // Get current location | ||
|
||
return ( | ||
<nav | ||
ref={navbarRef} | ||
aria-label={translate({ | ||
id: "theme.NavBar.navAriaLabel", | ||
message: "Main", | ||
description: "The ARIA label for the main navigation", | ||
})} | ||
className={clsx( | ||
"navbar", | ||
"navbar--fixed-top", | ||
hideOnScroll && [ | ||
styles.navbarHideable, | ||
!isNavbarVisible && styles.navbarHidden, | ||
], | ||
{ | ||
"navbar--dark": style === "dark", | ||
"navbar--primary": style === "primary", | ||
"navbar-sidebar--show": mobileSidebar.shown, | ||
}, | ||
)} | ||
> | ||
<div className="navbar__primary"> | ||
{children} | ||
</div> | ||
<NavbarBackdrop onClick={mobileSidebar.toggle} /> | ||
<NavbarMobileSidebar /> | ||
</nav> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.navbarHideable { | ||
transition: transform var(--ifm-transition-fast) ease; | ||
} | ||
|
||
.navbarHidden { | ||
transform: translate3d(0, calc(-100% - 2px), 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.