Skip to content

Commit a0e9c70

Browse files
authored
Rollup merge of rust-lang#101944 - notriddle:notriddle/toggle-all-docs, r=jsha,GuillaumeGomez
rustdoc: clean up `#toggle-all-docs` This change converts the element from an `<a>` link to a button. It's pretty much directly trading slightly more CSS for slightly less HTML, and it's also semantically correct (so you don't get a broken "bookmark" option when you right click on it). While doing this, I also got rid of the unnecessary `class="inner"` attribute on the inner span. There was a style targeting `.collapse-toggle > .inner`, but no CSS ever targeted the `#toggle-all-docs > .inner`. Preview: https://notriddle.com/notriddle-rustdoc-test/button-toggle-all-docs/index.html
2 parents 5965158 + bdbc977 commit a0e9c70

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

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

+11-4
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ h1.fqn {
163163
padding-bottom: 6px;
164164
margin-bottom: 15px;
165165
}
166-
#toggle-all-docs {
167-
text-decoration: none;
168-
}
169166
/* The only headings that get underlines are:
170167
Markdown-generated headings within the top-doc
171168
Rustdoc-generated h2 section headings (e.g. "Implementations", "Required Methods", etc)
@@ -209,7 +206,7 @@ ul.all-items {
209206
font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif;
210207
}
211208

212-
a#toggle-all-docs,
209+
#toggle-all-docs,
213210
a.anchor,
214211
.small-section-header a,
215212
#source-sidebar a,
@@ -299,6 +296,16 @@ button {
299296
padding: 1px 6px;
300297
}
301298

299+
button#toggle-all-docs {
300+
padding: 0;
301+
background: none;
302+
border: none;
303+
cursor: pointer;
304+
/* iOS button gradient: https://stackoverflow.com/q/5438567 */
305+
-webkit-appearance: none;
306+
opacity: 1;
307+
}
308+
302309
/* end tweaks for normalize.css 8 */
303310

304311
.rustdoc {

src/librustdoc/html/templates/print_item.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ <h1 class="fqn"> {#- -#}
2121
<a class="srclink" href="{{href|safe}}">source</a> · {# -#}
2222
{%- else -%}
2323
{%- endmatch -%}
24-
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs"> {#- -#}
25-
[<span class="inner">&#x2212;</span>] {#- -#}
26-
</a> {#- -#}
24+
<button id="toggle-all-docs" title="collapse all docs"> {#- -#}
25+
[<span>&#x2212;</span>] {#- -#}
26+
</button> {#- -#}
2727
</span> {#- -#}
2828
</div> {#- -#}

0 commit comments

Comments
 (0)