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

rustdoc: mobile nav fixes #93183

Merged
merged 1 commit into from
Jan 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ a.anchor,
pre.rust a,
.sidebar h2 a,
.sidebar h3 a,
.mobile-topbar h2 a,
.in-band a {
color: #c5c5c5;
}
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ a.anchor,
pre.rust a,
.sidebar h2 a,
.sidebar h3 a,
.mobile-topbar h2 a,
.in-band a {
color: #ddd;
}
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ a.anchor,
pre.rust a,
.sidebar h2 a,
.sidebar h3 a,
.mobile-topbar h2 a,
.in-band a {
color: #000;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}());
Expand Down
4 changes: 4 additions & 0 deletions src/test/rustdoc-gui/mobile.goml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
goto: file://|DOC_PATH|/staged_api/struct.Foo.html
size: (400, 600)

font-size: 18

// The out-of-band info (source, stable version, collapse) should be below the
// h1 when the screen gets narrow enough.
assert-css: (".main-heading", {
"display": "flex",
"flex-direction": "column"
})

assert-property: (".mobile-topbar h2.location", {"offsetHeight": 45})

// Note: We can't use assert-text here because the 'Since' is set by CSS and
// is therefore not part of the DOM.
assert-css: (".content .out-of-band .since::before", { "content": "\"Since \"" })
Expand Down
5 changes: 5 additions & 0 deletions src/test/rustdoc-gui/sidebar-mobile.goml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ assert-property: (".mobile-topbar", {"clientHeight": "45"})
click: ".sidebar-menu-toggle"
click: ".sidebar-links a"
assert-position: ("#method\.must_use", {"y": 45})

// Check that the bottom-most item on the sidebar menu can be scrolled fully into view.
click: ".sidebar-menu-toggle"
scroll-to: ".block.keyword li:nth-child(1)"
assert-position: (".block.keyword li:nth-child(1)", {"y": 542.96875})
Copy link
Member

Choose a reason for hiding this comment

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

Wow, that's quite the number. XD

2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/type-declation-overflow.goml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ assert-property: (".item-decl pre", {"scrollWidth": "950"})
// On mobile:
size: (600, 600)
goto: file://|DOC_PATH|/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html
assert-property: (".mobile-topbar .location", {"scrollWidth": "504"})
assert-property: (".mobile-topbar .location", {"scrollWidth": "986"})
assert-property: (".mobile-topbar .location", {"clientWidth": "504"})
assert-css: (".mobile-topbar .location", {"overflow-x": "hidden"})