-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c2afca
commit c89a40d
Showing
2 changed files
with
74 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from "react"; | ||
import { useThemeConfig } from "@docusaurus/theme-common"; | ||
import { | ||
splitNavbarItems, | ||
useNavbarMobileSidebar, | ||
} from "@docusaurus/theme-common/internal"; | ||
import NavbarItem from "@theme/NavbarItem"; | ||
import NavbarColorModeToggle from "@theme/Navbar/ColorModeToggle"; | ||
import SearchBar from "@theme/SearchBar"; | ||
import NavbarMobileSidebarToggle from "@theme/Navbar/MobileSidebar/Toggle"; | ||
import NavbarLogo from "@theme/Navbar/Logo"; | ||
import NavbarSearch from "@theme/Navbar/Search"; | ||
import styles from "./styles.module.css"; | ||
|
||
function useNavbarItems() { | ||
// TODO temporary casting until ThemeConfig type is improved | ||
return useThemeConfig().navbar.items; | ||
} | ||
function NavbarItems({ items }) { | ||
return ( | ||
<> | ||
{items.map((item, i) => ( | ||
<NavbarItem {...item} key={i} /> | ||
))} | ||
</> | ||
); | ||
} | ||
function NavbarContentLayout({ left, right }) { | ||
return ( | ||
<div className="navbar__inner"> | ||
<div className="navbar__items">{left}</div> | ||
<div className="navbar__items navbar__items--right">{right}</div> | ||
</div> | ||
); | ||
} | ||
export default function NavbarContent() { | ||
const mobileSidebar = useNavbarMobileSidebar(); | ||
const items = useNavbarItems(); | ||
const [leftItems, rightItems] = splitNavbarItems(items); | ||
const searchBarItem = items.find((item) => item.type === "search"); | ||
return ( | ||
<NavbarContentLayout | ||
left={ | ||
// TODO stop hardcoding items? | ||
<> | ||
{!mobileSidebar.disabled && <NavbarMobileSidebarToggle />} | ||
<NavbarLogo /> | ||
<NavbarItems items={leftItems} /> | ||
</> | ||
} | ||
right={ | ||
// TODO stop hardcoding items? | ||
// Ask the user to add the respective navbar items => more flexible | ||
<> | ||
{!searchBarItem && ( | ||
<NavbarSearch> | ||
<SearchBar /> | ||
</NavbarSearch> | ||
)} | ||
<NavbarItems items={rightItems} /> | ||
<NavbarColorModeToggle className={styles.colorModeToggle} /> | ||
</> | ||
} | ||
/> | ||
); | ||
} |
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,8 @@ | ||
/* | ||
Hide color mode toggle in small viewports | ||
*/ | ||
@media (max-width: 996px) { | ||
.colorModeToggle { | ||
display: none; | ||
} | ||
} |
c89a40d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
developers-basistheory-com – ./
developers-basistheory-com.vercel.app
developers-basistheory-com-git-master-basis-theory.vercel.app
developers-basistheory-com-basis-theory.vercel.app