Skip to content

Commit

Permalink
Rollup merge of #101944 - notriddle:notriddle/toggle-all-docs, r=jsha…
Browse files Browse the repository at this point in the history
…,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
  • Loading branch information
notriddle committed Oct 31, 2022
2 parents 7e62406 + bdbc977 commit 8d6ed3e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 11 additions & 4 deletions src/librustdoc/html/static/css/rustdoc.css
Expand Up @@ -163,9 +163,6 @@ h1.fqn {
padding-bottom: 6px;
margin-bottom: 15px;
}
#toggle-all-docs {
text-decoration: none;
}
/* The only headings that get underlines are:
Markdown-generated headings within the top-doc
Rustdoc-generated h2 section headings (e.g. "Implementations", "Required Methods", etc)
Expand Down Expand Up @@ -209,7 +206,7 @@ ul.all-items {
font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif;
}

a#toggle-all-docs,
#toggle-all-docs,
a.anchor,
.small-section-header a,
#source-sidebar a,
Expand Down Expand Up @@ -299,6 +296,16 @@ button {
padding: 1px 6px;
}

button#toggle-all-docs {
padding: 0;
background: none;
border: none;
cursor: pointer;
/* iOS button gradient: https://stackoverflow.com/q/5438567 */
-webkit-appearance: none;
opacity: 1;
}

/* end tweaks for normalize.css 8 */

.rustdoc {
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/templates/print_item.html
Expand Up @@ -21,8 +21,8 @@ <h1 class="fqn"> {#- -#}
<a class="srclink" href="{{href|safe}}">source</a> · {# -#}
{%- else -%}
{%- endmatch -%}
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs"> {#- -#}
[<span class="inner">&#x2212;</span>] {#- -#}
</a> {#- -#}
<button id="toggle-all-docs" title="collapse all docs"> {#- -#}
[<span>&#x2212;</span>] {#- -#}
</button> {#- -#}
</span> {#- -#}
</div> {#- -#}

0 comments on commit 8d6ed3e

Please sign in to comment.