Skip to content

Commit b46d43f

Browse files
committed
rustdoc: bundle sidebar button icon into CSS
This removes an HTTP request from the loading pipeline, and allows it to be changed with a media query.
1 parent c0d5501 commit b46d43f

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

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

+22-1
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,16 @@ a.tooltip:hover::after {
15971597
border-color: var(--settings-button-border-focus);
15981598
}
15991599

1600+
#sidebar-button > a:before {
1601+
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22" \
1602+
fill="none" stroke="black">\
1603+
<rect x="1" y="1" width="20" height="20" ry="1.5" stroke-width="1.5"/>\
1604+
<circle cx="4.375" cy="4.375" r="1" stroke-width=".75"/>\
1605+
<path d="m7.6121 3v16 M5.375 7.625h-2 m2 3h-2 m2 3h-2" stroke-width="1.25"/></svg>');
1606+
width: 22px;
1607+
height: 22px;
1608+
}
1609+
16001610
#copy-path {
16011611
color: var(--copy-path-button-color);
16021612
background: var(--main-background-color);
@@ -1983,6 +1993,17 @@ in src-script.js and main.js
19831993
display: none;
19841994
}
19851995

1996+
/* sidebar button becomes topbar button */
1997+
#sidebar-button > a:before {
1998+
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" \
1999+
viewBox="0 0 22 22" fill="none" stroke="black">\
2000+
<rect x="1" y="1" width="20" height="20" ry="1.5" stroke-width="1.5"/>\
2001+
<circle cx="4.375" cy="4.375" r="1" stroke-width=".75"/>\
2002+
<path d="m3 7.375h16m0-3h-4" stroke-width="1.25"/></svg>');
2003+
width: 22px;
2004+
height: 22px;
2005+
}
2006+
19862007
/* Display an alternating layout on tablets and phones */
19872008
.item-table, .item-row, .item-table > li, .item-table > li > div,
19882009
.search-results > a, .search-results > a > div {
@@ -2690,7 +2711,7 @@ Original by Dempfi (https://github.com/dempfi/ayu)
26902711
}
26912712

26922713
:root[data-theme="ayu"] #settings-menu > a img,
2693-
:root[data-theme="ayu"] #sidebar-button > a img {
2714+
:root[data-theme="ayu"] #sidebar-button > a:before {
26942715
filter: invert(100);
26952716
}
26962717
/* End theme: ayu */

src/librustdoc/html/static/images/sidebar.svg

-15
This file was deleted.

src/librustdoc/html/templates/page.html

+1-4
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,7 @@ <h2> {# #}
132132
<span></span> {# This empty span is a hacky fix for Safari - See #93184 #}
133133
{% if page.css_class != "src" %}
134134
<div id="sidebar-button" tabindex="-1"> {# #}
135-
<a href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}all.html" title="show sidebar"> {# #}
136-
<img width="22" height="22" alt="Show sidebar" {#+ #}
137-
src="{{static_root_path|safe}}{{files.sidebar_svg}}"> {# #}
138-
</a> {# #}
135+
<a href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}all.html" title="show sidebar"></a> {# #}
139136
</div> {# #}
140137
{% endif %}
141138
<input {#+ #}

0 commit comments

Comments
 (0)