Skip to content
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

Fix top navbar style #1719

Merged
merged 4 commits into from
Apr 16, 2022
Merged

Fix top navbar style #1719

merged 4 commits into from
Apr 16, 2022

Conversation

GuillaumeGomez
Copy link
Member

I just realized that the display of the top navbar menu is broken (well, not good looking):

Screenshot from 2022-04-11 14-06-07

It comes from my changes in #1717 to allow having a different font size.

Overall, the style for the top navbar is quite the nightmare so I decided to remove the float properties and to use flex instead. The result is quite nice (imo) and fixes some small UI issues:

Screenshot from 2022-04-11 15-16-23

And it looks like this with bigger font size:

Screenshot from 2022-04-11 15-12-54

I checked other pages and they work well too.

@github-actions github-actions bot added the S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed label Apr 11, 2022
@jsha
Copy link
Contributor

jsha commented Apr 12, 2022

In my local Chrome, with the light theme, it looks like this:

image

There are grey rectangles between the menu names. Looking the Dev Tools, it appears to be due to these rules in the light CSS:

::-webkit-scrollbar-thumb {
    background-color: rgba(36,37,39,0.6);
}
::-webkit-scrollbar-track {
    background-color: #ecebeb;
}

Those are getting applied to the <div class="pure-menu pure-menu-horizontal">, but I'm not sure why.

@GuillaumeGomez
Copy link
Member Author

Great catch! I'll check tomorrow what's going on.

Comment on lines 131 to 132
max-height: 100%;
overflow-x: hidden;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these lines are unnecessary. When I remove these properties locally, the unwanted grey rectangles (which are tiny vertical scrollbars) go away. Also, with these properties removed, even if the menu items' font size is weird, it doesn't interfere with the main page.

Copy link
Contributor

Choose a reason for hiding this comment

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

In fact, I think this whole CSS rule (including the comment about what happens with a locally installed old Fira Sans) should get deleted. Switching to the flex layout seems like it sufficed to fix the issue with overflowing menu titles, even without this rule.

Copy link
Contributor

Choose a reason for hiding this comment

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

(I just tested in a locally installed Firefox, with the Fira Sans from #1669 (comment), at these commits:

  1. ad8d4fe (i.e. right before Set overflow-y: hidden on navbar #1711)
  2. 0ae5807 (this branch)
  3. 0ae5807 with this CSS rule removed

And I can confirm that at (1) I have the overflow issue. Both (2) and (3) fix the overflow issue, and (3) additionally fixes the scrollbar issue introduced in this branch.

BTW the scrollbar issue seems to be Chrome-only.

Copy link
Member Author

@GuillaumeGomez GuillaumeGomez Apr 13, 2022

Choose a reason for hiding this comment

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

Without this change:

Screenshot from 2022-04-13 16-51-54

With this change:

Screenshot from 2022-04-13 16-52-21

So we definitely need it.

Comment on lines 31 to 35
position: relative;

.container, .pure-menu-horizontal {
position: relative;
height: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

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

What are the position: relative and height: 100% needed for here? I think they are unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's because with this, we can set the element of the navbar to height: 100%. It prevents the bottom margin to disappear in case the font size is too big.

form.landing-search-form-nav {
max-width: 1200px;
height: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can get rid of this height: 100%. That makes the search field vertically misaligned, but you can fix that by also removing the height: 100% on line 92.

Copy link
Member Author

Choose a reason for hiding this comment

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

Without the height: 100%:

Screenshot from 2022-04-13 16-56-07

max-width: 150px;
display: none;
border-left: 1px solid var(--color-border);
height: 100%;
overflow-x: hidden;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need overflow-x: hidden here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a trick I used to fix the scrollbar issue when the font-size is too big. I thought flex-shrink: 1 would do it but apparently it doesn't...

}

.pure-menu-item {
height: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is also unnecessary.

@jsha
Copy link
Contributor

jsha commented Apr 12, 2022

Overall, great change! I am really happy to have the items show up in the same HTML order as the visual order on the page.

@syphar syphar added S-waiting-on-author Status: This PR is incomplete or needs to address review comments and removed S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed labels Apr 13, 2022
@GuillaumeGomez
Copy link
Member Author

In my local Chrome, with the light theme, it looks like this:

image

There are grey rectangles between the menu names. Looking the Dev Tools, it appears to be due to these rules in the light CSS:

::-webkit-scrollbar-thumb {
    background-color: rgba(36,37,39,0.6);
}
::-webkit-scrollbar-track {
    background-color: #ecebeb;
}

Those are getting applied to the <div class="pure-menu pure-menu-horizontal">, but I'm not sure why.

I can't reproduce it on my chrome:

Screenshot from 2022-04-13 16-59-08

Any idea what's going on in yours? Do you have some extension or some other custom setting maybe?

@jsha
Copy link
Contributor

jsha commented Apr 13, 2022

Mine is Chrome Version 100.0.4896.88 (Official Build) (64-bit) on Ubuntu 21.10. It still reproduces when I run google-chrome --user-data-dir=$(mktemp -d) http://localhost:3000/regex/latest/regex/ to have a totally clean profile.

I do have that old copy of Fira Sans still installed, which probably contributes.

If I remove the max-height: 100%, the natural height of those menu titles is 36px. The max-height constrains their parent element, which leads to a scrollbar.

If you follow the tweaks I recommended above that will fix things.

@GuillaumeGomez
Copy link
Member Author

GuillaumeGomez commented Apr 13, 2022

I tested all of them and they all ended up in bad rendering in firefox. :-/

EDIT: I forgot to precise: bad rendering when the minimum font size is more than expected.

@jsha
Copy link
Contributor

jsha commented Apr 13, 2022

Which type of bad rendering? The "body text is too narrow" bad rendering? Or "bottom border of menu title is not visible"?

@GuillaumeGomez
Copy link
Member Author

Size of top navbar items becomes chaotic:

Screenshot from 2022-04-13 16-56-07

For example, sysinfo item even gets its height different from the rest.

@jsha
Copy link
Contributor

jsha commented Apr 13, 2022

I spent some time fiddling with this locally and came up with a solution that I think is tidier, avoids the scrollbars on Chrome, and looks right on both Chrome and Firefox. I sent it as a PR against your branch: GuillaumeGomez#1. Let me know what you think!

@GuillaumeGomez
Copy link
Member Author

Nice, thanks a lot! Will test it locally as soon as possible.

@GuillaumeGomez
Copy link
Member Author

I integrated @jsha's improvements so this should now be ready!

@jsha
Copy link
Contributor

jsha commented Apr 14, 2022

I've manually tested the version on this branch in Firefox and Chrome, with the old version of Fira Sans locally installed. Tests I did:

  • Scrolled vertically to make sure the navbar stayed in place
  • Opened and closed menus
  • Verified that the rustdoc content was not artificially narrow
  • Verified that the vertical bars separating menu titles went all the way to the top and bottom of the navbar
  • Verified that menu titles were approximately centered vertically

I also tested with a large font size in firefox, and a large minimum font size. The presentation wasn't perfect but it was good enough. And it didn't interere with the rustdoc content.

@syphar syphar added S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed and removed S-waiting-on-author Status: This PR is incomplete or needs to address review comments labels Apr 16, 2022
Copy link
Member

@syphar syphar left a comment

Choose a reason for hiding this comment

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

LGTM, definitely fixes #1725

@syphar syphar merged commit de197f9 into rust-lang:master Apr 16, 2022
@github-actions github-actions bot added S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it and removed S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed labels Apr 16, 2022
@syphar syphar removed the S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it label Apr 16, 2022
@GuillaumeGomez GuillaumeGomez deleted the top-navbar branch April 16, 2022 11:15
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.

3 participants