Skip to content

Fix positioning for detail toggles on mobile. #84602

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

Closed
wants to merge 4 commits into from
Closed
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
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn toggle_open(w: &mut Buffer, text: &str) {
write!(
w,
"<details class=\"rustdoc-toggle type-contents-toggle\">\
<summary class=\"hideme\">\
<summary class=\"hide-me\">\
<span>Show {}</span>\
</summary>",
text
Expand Down
114 changes: 59 additions & 55 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,64 @@ h4 > .notable-traits {
border-top: 1px solid;
}

/* The hide-me class is used on summary tags that contain a span with
placeholder text shown only when the toggle is closed. For instance,
"Expand description" or "Show methods". */
details.rustdoc-toggle > summary.hide-me {
cursor: pointer;
}

details.rustdoc-toggle > summary::marker {
display: none;
}

details.rustdoc-toggle > summary::-webkit-details-marker {
Copy link
Member

Choose a reason for hiding this comment

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

Is there an equivalent on firefox?

display: none;
}

details.rustdoc-toggle > summary.hide-me > span {
margin-left: 9px;
}

details.rustdoc-toggle > summary::before {
content: "[+]";
font-weight: 300;
font-size: 0.8em;
letter-spacing: 1px;
cursor: pointer;
}

details.rustdoc-toggle > summary.hide-me::before {
position: relative;
}

details.rustdoc-toggle > summary:not(.hide-me)::before {
position: absolute;
left: -23px;
}

/* When a "hide-me" summary is open and the "Expand description" or "Show
methods" text is hidden, we want the [-] toggle that remains to not
affect the layout of the items to its right. To do that, we use
absolute positioning. Note that we also set position: relative
on the parent <details> to make this work properly. */
details.rustdoc-toggle[open] > summary.hide-me {
position: absolute;
}

details.rustdoc-toggle[open] {
position: relative;
}

details.rustdoc-toggle[open] > summary.hide-me > span {
display: none;
}

details.rustdoc-toggle[open] > summary::before {
content: "[−]";
display: inline;
}

/* Media Queries */

@media (min-width: 701px) {
Expand Down Expand Up @@ -1573,7 +1631,7 @@ h4 > .notable-traits {
left: -10px;
}

.item-list > details.rustdoc-toggle > summary:not(.hideme)::before {
details.rustdoc-toggle > summary:not(.hide-me)::before {
left: -10px;
}

Expand Down Expand Up @@ -1770,57 +1828,3 @@ div.name.expand::before {
left: -15px;
top: 2px;
}

/* The hideme class is used on summary tags that contain a span with
placeholder text shown only when the toggle is closed. For instance,
"Expand description" or "Show methods". */
details.rustdoc-toggle > summary.hideme {
cursor: pointer;
}

details.rustdoc-toggle > summary::-webkit-details-marker {
display: none;
}

details.rustdoc-toggle > summary.hideme > span {
margin-left: 9px;
}

details.rustdoc-toggle > summary::before {
content: "[+]";
font-weight: 300;
font-size: 0.8em;
letter-spacing: 1px;
cursor: pointer;
}

details.rustdoc-toggle > summary.hideme::before {
position: relative;
}

details.rustdoc-toggle > summary:not(.hideme)::before {
position: absolute;
left: -23px;
}

/* When a "hideme" summary is open and the "Expand description" or "Show
methods" text is hidden, we want the [-] toggle that remains to not
affect the layout of the items to its right. To do that, we use
absolute positioning. Note that we also set position: relative
on the parent <details> to make this work properly. */
details.rustdoc-toggle[open] > summary.hideme {
position: absolute;
}

details.rustdoc-toggle[open] {
position: relative;
}

details.rustdoc-toggle[open] > summary.hideme > span {
display: none;
}

details.rustdoc-toggle[open] > summary::before {
content: "[−]";
display: inline;
}
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ a {
}

.collapse-toggle,
details.rustdoc-toggle > summary.hideme > span,
details.rustdoc-toggle > summary.hide-me > span,
details.rustdoc-toggle > summary::before {
color: #999;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ a.test-arrow {
}

.collapse-toggle,
details.rustdoc-toggle > summary.hideme > span,
details.rustdoc-toggle > summary.hide-me > span,
details.rustdoc-toggle > summary::before {
color: #999;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ a.test-arrow {
}

.collapse-toggle,
details.rustdoc-toggle > summary.hideme > span,
details.rustdoc-toggle > summary.hide-me > span,
details.rustdoc-toggle > summary::before {
color: #999;
}
Expand Down