Skip to content

Commit 152e888

Browse files
committed
Rustdoc mobile: put out-of-band on its own line
Before this, the item name and the stability, source link, and "collapse all docs" would compete for room on a single line, resulting in awkward wrapping behavior on mobile. This gives a separate line for that out-of-band information. It also removes the "copy path" icon on mobile to make a little more room. Also, switch to flex-wrap: wrap, so anytime there's not enough room for `source`, it gets bumped to the next line.
1 parent 237949b commit 152e888

File tree

3 files changed

+43
-15
lines changed

3 files changed

+43
-15
lines changed

src/librustdoc/html/static/css/rustdoc.css

+20-9
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ h1.fqn {
148148
}
149149
.main-heading {
150150
display: flex;
151+
flex-wrap: wrap;
152+
justify-content: space-between;
153+
border-bottom: 1px dashed #DDDDDD;
154+
padding-bottom: 6px;
151155
margin-bottom: 15px;
152-
153-
/* workaround to keep flex from breaking below 700 px width due to the float: right on the nav
154-
above the h1 */
155-
padding-left: 1px;
156156
}
157157
.main-heading a:hover {
158158
text-decoration: underline;
@@ -623,11 +623,7 @@ nav.sub {
623623

624624
.content .out-of-band {
625625
flex-grow: 0;
626-
text-align: right;
627-
margin-left: auto;
628-
margin-right: 0;
629626
font-size: 1.15rem;
630-
padding: 0 0 0 12px;
631627
font-weight: normal;
632628
float: right;
633629
}
@@ -1748,10 +1744,25 @@ details.rustdoc-toggle[open] > summary.hideme::after {
17481744
padding-top: 0px;
17491745
}
17501746

1751-
.rustdoc {
1747+
.rustdoc,
1748+
.main-heading {
17521749
flex-direction: column;
17531750
}
17541751

1752+
.content .out-of-band {
1753+
text-align: left;
1754+
margin-left: initial;
1755+
padding: initial;
1756+
}
1757+
1758+
.content .out-of-band .since::before {
1759+
content: "Since ";
1760+
}
1761+
1762+
#copy-path {
1763+
display: none;
1764+
}
1765+
17551766
/* Hide the logo and item name from the sidebar. Those are displayed
17561767
in the mobile-topbar instead. */
17571768
.sidebar .sidebar-logo,

src/test/rustdoc-gui/mobile.goml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Test various properties of the mobile UI
2+
goto: file://|DOC_PATH|/staged_api/struct.Foo.html
3+
size: (400, 600)
4+
5+
// The out-of-band info (source, stable version, collapse) should be below the
6+
// h1 when the screen gets narrow enough.
7+
assert-css: (".main-heading", {
8+
"display": "flex",
9+
"flex-direction": "column"
10+
})
11+
12+
// Note: We can't use assert-text here because the 'Since' is set by CSS and
13+
// is therefore not part of the DOM.
14+
assert-css: (".content .out-of-band .since::before", { "content": "\"Since \"" })
15+
16+
size: (1000, 1000)
17+
assert-css-false: (".content .out-of-band .since::before", { "content": "\"Since \"" })

src/test/rustdoc-gui/toggle-docs-mobile.goml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
22
size: (433, 600)
33
assert-attribute: (".top-doc", {"open": ""})
4-
click: (4, 250) // This is the position of the top doc comment toggle
4+
click: (4, 270) // This is the position of the top doc comment toggle
55
assert-attribute-false: (".top-doc", {"open": ""})
6-
click: (4, 250)
6+
click: (4, 270)
77
assert-attribute: (".top-doc", {"open": ""})
88
// To ensure that the toggle isn't over the text, we check that the toggle isn't clicked.
9-
click: (3, 250)
9+
click: (3, 270)
1010
assert-attribute: (".top-doc", {"open": ""})
1111

1212
// Assert the position of the toggle on the top doc block.
@@ -22,10 +22,10 @@ assert-position: (
2222
// Now we do the same but with a little bigger width
2323
size: (600, 600)
2424
assert-attribute: (".top-doc", {"open": ""})
25-
click: (4, 250) // New Y position since all search elements are back on one line.
25+
click: (4, 270) // New Y position since all search elements are back on one line.
2626
assert-attribute-false: (".top-doc", {"open": ""})
27-
click: (4, 250)
27+
click: (4, 270)
2828
assert-attribute: (".top-doc", {"open": ""})
2929
// To ensure that the toggle isn't over the text, we check that the toggle isn't clicked.
30-
click: (3, 250)
30+
click: (3, 270)
3131
assert-attribute: (".top-doc", {"open": ""})

0 commit comments

Comments
 (0)