Skip to content

add a scrollbar for nav links in the header when they exceed available free space #3376

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

Merged
merged 1 commit into from
Oct 5, 2024

Conversation

dimaMachina
Copy link
Collaborator

@dimaMachina dimaMachina commented Oct 5, 2024

fixes #2785

inspired by mdx website

Screen.Recording.2024-10-05.at.12.32.37.mov

TODO

maybe add a box-shadow to help users understand there is a scroll like in the sidebar and TOC footers?

@apply _shadow-[0_-12px_16px_rgb(var(--nextra-bg))];

Copy link

changeset-bot bot commented Oct 5, 2024

🦋 Changeset detected

Latest commit: 4e8dcaf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
nextra-theme-docs Patch
nextra Patch
nextra-theme-blog Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Oct 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextra-theme-docs-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 5, 2024 9:33am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
nextra ⬜️ Ignored (Inspect) Oct 5, 2024 9:33am

Copy link
Contributor

github-actions bot commented Oct 5, 2024

📦 Next.js Bundle Analysis for swr-site

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 167.27 KB (🟡 +17 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Copy link
Contributor

github-actions bot commented Oct 5, 2024

📦 Next.js Bundle Analysis for docs

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 174.98 KB (15 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Twelve Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/about 8.09 KB (🟢 -1 B) 183.07 KB
/docs/blog-theme/start 14.11 KB (-1 B) 189.09 KB
/docs/docs-theme/built-ins 7.65 KB (🟢 -1 B) 182.63 KB
/docs/guide/advanced/customize-the-cascade-layers 7.66 KB (🟢 3 B) 182.64 KB
/docs/guide/advanced/npm2yarn 10.74 KB (-1 B) 185.71 KB
/docs/guide/advanced/tailwind-css 7.26 KB (🟢 1 B) 182.24 KB
/docs/guide/advanced/twoslash-support 9.29 KB (🟢 -1 B) 184.27 KB
/docs/guide/custom-css 7.15 KB (🟢 3 B) 182.13 KB
/docs/guide/i18n 8.31 KB (🟢 -1 B) 183.28 KB
/docs/guide/image 8.37 KB (🟢 -2 B) 183.35 KB
/docs/guide/organize-files 11.31 KB (-1 B) 186.29 KB
/docs/guide/static-exports 11.27 KB (-1 B) 186.25 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by undefined% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

@dimaMachina
Copy link
Collaborator Author

cc @87xie lmk wdyt 🙏

@dimaMachina dimaMachina merged commit f3a5575 into main Oct 5, 2024
9 checks passed
@dimaMachina dimaMachina deleted the v3-128 branch October 5, 2024 09:41
@87xie
Copy link
Contributor

87xie commented Oct 5, 2024

I think each approach is quite subjective, and it might be more appropriate to leave these trade-offs to the outer-land.

If Nextra v3 could provide lower-level components that allow users to compose their components (similar to the approach in v4):

<Navbar>
  <MyLogo />
  <MyLinks />
  <Searchbar />
  <ProjectLink />
</Navbar>

This would give them the flexibility to implement the solutions that might be more suitable for their use case, for example, prioritizing the hiding of less important elements, using overflow: scroll, or dynamically calculating with JavaScript.

My use case with theme-docs doesn't involve a complex header, so I’m unable to provide useful suggestions 😅

@marcklingen
Copy link
Contributor

thanks for adding this (just noticed it and was looking for the pr)!

we use theme-docs for our main website and docs and would love to customize the main nav more easily as described by @87xie

@@ -127,47 +127,51 @@ export function Navbar({ items }: NavBarProps): ReactElement {
{renderComponent(themeConfig.logo)}
</div>
)}
{items.map(pageOrMenu => {
if (pageOrMenu.display === 'hidden') return null
<div className="_flex _gap-4 _overflow-x-auto nextra-scrollbar _py-1.5">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the focus ring styles of the first and last links are being cut off.

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, noticed it too, little regression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent Navbar breakpoint
3 participants