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 sidebar display on small devices #87167

Merged
merged 2 commits into from
Jul 16, 2021
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
10 changes: 6 additions & 4 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1631,15 +1631,18 @@ details.undocumented[open] > summary::before {
display: none;
}

/* We do NOT hide this element so that alternative device readers still have this information
available. */
.sidebar-elems {
position: fixed;
z-index: 1;
left: 0;
top: 45px;
bottom: 0;
width: 246px;
/* We move the sidebar to the left by its own width so it doesn't appear. */
left: -246px;
overflow-y: auto;
border-right: 1px solid;
display: none;
}

.sidebar > .block.version {
Expand Down Expand Up @@ -1727,8 +1730,7 @@ details.undocumented[open] > summary::before {
}

.show-it {
display: block;
width: 246px;
left: 0;
}

.show-it > .block.items {
Expand Down
10 changes: 10 additions & 0 deletions src/test/rustdoc-gui/sidebar-mobile.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This test ensure that the sidebar isn't "hidden" on mobile but instead moved out of the viewport.
// This is especially important for devices for "text-first" content (like for users with
// sight issues).
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
// Switching to "mobile view" by reducing the width to 600px.
size: (600, 600)
assert-css: (".sidebar-elems", {"display": "block", "left": "-246px"})
// Opening the sidebar menu.
click: ".sidebar-menu"
assert-css: (".sidebar-elems", {"display": "block", "left": "0px"})