1
Fork 0

Rollup merge of #93183 - jsha:mobile-nav-fixes, r=GuillaumeGomez

rustdoc: mobile nav fixes

- Make sure the mobile-topbar doesn't overflow its height if the user sets a bigger font.

- Make sure the sidebar can be scrolled all the way to the bottom by shortening it to accommodate the mobile-topbar.

- Make the item name in the mobile-topbar clickable to go to the top of the page.

- Remove excess padding sidebar in mobile mode.

Demo https://rustdoc.crud.net/jsha/mobile-nav-fixes/std/string/struct.String.html

r? `@GuillaumeGomez`
This commit is contained in:
Eric Huss 2022-01-30 08:37:49 -08:00 committed by GitHub
commit 4ddf986d68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 4 deletions

View file

@ -1799,8 +1799,9 @@ details.rustdoc-toggle[open] > summary.hideme::after {
background-color: rgba(0,0,0,0);
margin: 0;
padding: 0;
padding-left: 15px;
z-index: 11;
/* Reduce height slightly to account for mobile topbar. */
height: calc(100vh - 45px);
}
/* The source view uses a different design for the sidebar toggle, and doesn't have a topbar,
@ -1831,7 +1832,13 @@ details.rustdoc-toggle[open] > summary.hideme::after {
padding: 0.3em;
padding-right: 0.6em;
text-overflow: ellipsis;
overflow-x: hidden;
overflow: hidden;
white-space: nowrap;
/* Rare exception to specifying font sizes in rem. Since the topbar
height is specified in pixels, this also has to be specified in
pixels to avoid overflowing the topbar when the user sets a bigger
font size. */
font-size: 22.4px;
}
.mobile-topbar .logo-container {
@ -1864,6 +1871,9 @@ details.rustdoc-toggle[open] > summary.hideme::after {
.sidebar-menu-toggle {
width: 45px;
/* Rare exception to specifying font sizes in rem. Since this is acting
as an icon, it's okay to specify its sizes in pixels. */
font-size: 32px;
border: none;
}

View file

@ -216,6 +216,7 @@ a.anchor,
pre.rust a,
.sidebar h2 a,
.sidebar h3 a,
.mobile-topbar h2 a,
.in-band a {
color: #c5c5c5;
}

View file

@ -192,6 +192,7 @@ a.anchor,
pre.rust a,
.sidebar h2 a,
.sidebar h3 a,
.mobile-topbar h2 a,
.in-band a {
color: #ddd;
}

View file

@ -189,6 +189,7 @@ a.anchor,
pre.rust a,
.sidebar h2 a,
.sidebar h3 a,
.mobile-topbar h2 a,
.in-band a {
color: #000;
}

View file

@ -72,7 +72,7 @@ function resourcePath(basename, extension) {
var mobileLocationTitle = document.querySelector(".mobile-topbar h2.location");
var locationTitle = document.querySelector(".sidebar h2.location");
if (mobileLocationTitle && locationTitle) {
mobileLocationTitle.innerText = locationTitle.innerText;
mobileLocationTitle.innerHTML = locationTitle.innerHTML;
}
}
}());