From c68c716f75ab1617ed000b5608e925c8c85e32aa Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Wed, 3 Jan 2024 18:52:19 +0800 Subject: [PATCH] Fix site navigation being somewhat jumbled at certain viewport widths (#6022) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **What's the problem this PR addresses?** Site navigation issues with bits of text overlapping each other and becoming unreadable, as well as awkward typography. Screenshot before the fix: Screenshot 2023-12-14 at 19 50 27 **How did you fix it?** - Allow horizontal scrolling of first top nav group - Avoid awkward linebreaks - Remove faux placeholder from search button that tries to act as a text input Screenshot after the fix (note that the scrollbar is hidden unless scrolling is initiated or OS is set up to “always show” scrollbars): Screenshot 2023-12-14 at 20 07 08 **Checklist** - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). - [x] I have set the packages that need to be released for my changes to be effective. - [x] I will check that all automated PR checks pass before the PR gets reviewed. --- packages/docusaurus/src/css/custom.css | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/packages/docusaurus/src/css/custom.css b/packages/docusaurus/src/css/custom.css index dea3955ad191..cc3848670762 100644 --- a/packages/docusaurus/src/css/custom.css +++ b/packages/docusaurus/src/css/custom.css @@ -127,6 +127,39 @@ html.blog-wrapper .container { display: none; } +.navbar__item { + /* Avoid awkward linebreaks of menu items. + * Labels should be kept short, however. */ + white-space: nowrap; +} + +.navbar__inner > .navbar__items:first-child { + /* Allow the first nav item group to scroll horizontally. */ + + /* Without this rule, rightmost items in first nav group + * would overlap leftmost items in second nav group, + * becoming completely unreadable. */ + + /* NOTE: Would NOT work as is if there is a drop-down menu. */ + /* That’s why it’s only applied to the first nav item group: + * the second nav group has a dropdown, which would be cut off + * by this overflow rule. */ + + overflow-x: auto; +} + +.DocSearch-Button-Placeholder { + /* Hide faux placeholder in the search trigger button + * while maintaining reasonable whitespace. + * This is subjective, but I believe placeholder doesn’t add + * useful information and makes the button visually + * appear as a text input field, which it is in fact not. */ + width: 0; + overflow: hidden; + visibility: hidden; + white-space: nowrap; +} + .navbar__logo { height: var(--ifm-navbar-height); }