-
Notifications
You must be signed in to change notification settings - Fork 50
✨ Add navbar_end part in navbar UI #802
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
Changes from 3 commits
31df4dc
9d1a85e
3dc9508
84e9c28
53c3144
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@myst-theme/site": patch | ||
| "@myst-theme/book": patch | ||
| --- | ||
|
|
||
| ✨ Add navbar_end part in navbar UI |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {button}`MyST Docs <https://mystmd.org>` {button}`GitHub <https://github.com/jupyter-book/myst-theme>` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| import React, { useEffect, useRef } from 'react'; | ||
| import classNames from 'classnames'; | ||
| import { useNavigation } from '@remix-run/react'; | ||
| import type { GenericParent } from 'myst-common'; | ||
| import { MyST } from 'myst-to-react'; | ||
| import { | ||
| useNavOpen, | ||
| useSiteManifest, | ||
|
|
@@ -135,6 +137,7 @@ export const PrimarySidebar = ({ | |
| sidebarRef, | ||
| nav, | ||
| footer, | ||
| navbarEnd, | ||
| headings, | ||
| hide_toc, | ||
| mobileOnly, | ||
|
|
@@ -143,6 +146,7 @@ export const PrimarySidebar = ({ | |
| nav?: SiteManifest['nav']; | ||
| headings?: Heading[]; | ||
| footer?: React.ReactNode; | ||
| navbarEnd?: GenericParent; | ||
| hide_toc?: boolean; | ||
| mobileOnly?: boolean; | ||
| }) => { | ||
|
|
@@ -204,6 +208,16 @@ export const PrimarySidebar = ({ | |
| <SidebarNav nav={nav} /> | ||
| </nav> | ||
| )} | ||
| {navbarEnd && ( | ||
| <div | ||
| className={classNames( | ||
| 'article myst-primary-sidebar-navbar-end xl:hidden p-2 my-1 flex flex-wrap gap-2 [&_p]:contents', | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we show the navbar items up until we hit |
||
| sidebarSectionInsetClass, | ||
| )} | ||
| > | ||
| <MyST ast={navbarEnd} /> | ||
| </div> | ||
| )} | ||
| {nav && headings && <div className="my-3 border-b-2 lg:hidden" />} | ||
| {headings && ( | ||
| <nav | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ import classNames from 'classnames'; | |
| import { Menu, Transition } from '@headlessui/react'; | ||
| import { ChevronDownIcon, Bars3Icon as MenuIcon } from '@heroicons/react/24/solid'; | ||
| import type { SiteManifest, SiteNavItem } from 'myst-config'; | ||
| import type { GenericParent } from 'myst-common'; | ||
| import { MyST } from 'myst-to-react'; | ||
| import { ThemeButton } from './ThemeButton.js'; | ||
| import { Search } from './Search.js'; | ||
| import { | ||
|
|
@@ -113,7 +115,15 @@ export function NavItems({ nav }: { nav?: SiteManifest['nav'] }) { | |
| ); | ||
| } | ||
|
|
||
| export function TopNav({ hideToc, hideSearch }: { hideToc?: boolean; hideSearch?: boolean }) { | ||
| export function TopNav({ | ||
| hideToc, | ||
| hideSearch, | ||
| navbarEnd, | ||
| }: { | ||
| hideToc?: boolean; | ||
| hideSearch?: boolean; | ||
| navbarEnd?: GenericParent; | ||
| }) { | ||
| const [open, setOpen] = useNavOpen(); | ||
| const config = useSiteManifest(); | ||
| const { title, nav, actions } = config ?? {}; | ||
|
|
@@ -152,8 +162,17 @@ export function TopNav({ hideToc, hideSearch }: { hideToc?: boolean; hideSearch? | |
| <div className="flex items-center flex-grow w-auto"> | ||
| <NavItems nav={nav} /> | ||
| <div className="flex-grow block"></div> | ||
| {/* Search bar */} | ||
| {!hideSearch && <Search />} | ||
| <ThemeButton /> | ||
| {/* Light/Dark theme button */} | ||
| <ThemeButton className="w-10 h-10 ml-3" /> | ||
| {/* Custom part at end of navbar */} | ||
|
choldgraf marked this conversation as resolved.
Outdated
|
||
| {navbarEnd && ( | ||
| <div className="article myst-navbar-end hidden xl:flex items-center ml-3 [&>*]:m-0"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why hidden ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's hidden because we have to render the navbar items in two places:
So here we hide it until we hit |
||
| <MyST ast={navbarEnd} /> | ||
| </div> | ||
| )} | ||
| {/* Mobile pop-up for page actions */} | ||
| <div className="block sm:hidden"> | ||
| <ActionMenu actions={actions} /> | ||
| </div> | ||
|
|
||
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.
GenericParent feels so... generic :)
Uh oh!
There was an error while loading. Please reload this page.
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.
I can't tell if this is a suggestion to do something different or not - but it's a good point that footer already uses
ReactNode....I can try to make this follow the same pattern and see if I can get the outcome we want. Is that what you'd like me to do?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.
Sorry, I was musing to myself that the typing feels less than optimal here. But this requires a systematic review to address, nothing for you to take care of here!