Skip to content

Commit 8272eae

Browse files
committed
Stop using the trigram of heaven as a hamburger button
It doesn't look quite right, because the lines are too far apart, and it's not going to be announced by screenreaders as a menu button, since that's not what the symbol means. This adds a real tooltip and uses a better drawing of the icon.
1 parent bd14fb6 commit 8272eae

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

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

+20-7
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,7 @@ a.tooltip:hover::after {
15481548
}
15491549
#sidebar-button {
15501550
display: none;
1551+
line-height: 0;
15511552
}
15521553
.hide-sidebar #sidebar-button,
15531554
.src #sidebar-button {
@@ -1925,11 +1926,8 @@ in src-script.js and main.js
19251926

19261927
.sidebar-menu-toggle {
19271928
width: 45px;
1928-
/* Rare exception to specifying font sizes in rem. Since this is acting
1929-
as an icon, it's okay to specify its sizes in pixels. */
1930-
font-size: 32px;
19311929
border: none;
1932-
color: var(--main-color);
1930+
line-height: 0;
19331931
}
19341932

19351933
.hide-sidebar .sidebar-menu-toggle {
@@ -1964,13 +1962,25 @@ in src-script.js and main.js
19641962
width: 22px;
19651963
height: 22px;
19661964
}
1965+
.sidebar-menu-toggle:before {
1966+
filter: var(--mobile-sidebar-menu-filter);
1967+
}
1968+
.sidebar-menu-toggle:hover {
1969+
background: var(--main-background-color);
1970+
}
19671971

1968-
/* src sidebar button opens modal
1972+
/* sidebar button opens modal
19691973
use hamburger button */
1970-
.src #sidebar-button > a:before {
1974+
.src #sidebar-button > a:before, .sidebar-menu-toggle:before {
19711975
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" \
19721976
viewBox="0 0 22 22" fill="none" stroke="black">\
1973-
<path d="M3,5h16M3,11h16M3,17h16" stroke-width="3"/></svg>');
1977+
<path d="M3,5h16M3,11h16M3,17h16" stroke-width="2.75"/></svg>');
1978+
opacity: 0.75;
1979+
}
1980+
.src #sidebar-button > a:hover:before, .sidebar-menu-toggle:hover:before,
1981+
.src #sidebar-button > a:active:before, .sidebar-menu-toggle:active:before,
1982+
.src #sidebar-button > a:focus:before, .sidebar-menu-toggle:focus:before {
1983+
opacity: 1;
19741984
}
19751985

19761986
/* Display an alternating layout on tablets and phones */
@@ -2303,6 +2313,7 @@ in src-script.js and main.js
23032313
--code-attribute-color: #999;
23042314
--toggles-color: #999;
23052315
--toggle-filter: none;
2316+
--mobile-sidebar-menu-filter: none;
23062317
--search-input-focused-border-color: #66afe9;
23072318
--copy-path-button-color: #999;
23082319
--copy-path-img-filter: invert(50%);
@@ -2407,6 +2418,7 @@ in src-script.js and main.js
24072418
--code-attribute-color: #999;
24082419
--toggles-color: #999;
24092420
--toggle-filter: invert(100%);
2421+
--mobile-sidebar-menu-filter: invert(100%);
24102422
--search-input-focused-border-color: #008dfd;
24112423
--copy-path-button-color: #999;
24122424
--copy-path-img-filter: invert(50%);
@@ -2518,6 +2530,7 @@ Original by Dempfi (https://github.com/dempfi/ayu)
25182530
--code-attribute-color: #999;
25192531
--toggles-color: #999;
25202532
--toggle-filter: invert(100%);
2533+
--mobile-sidebar-menu-filter: invert(100%);
25212534
--search-input-focused-border-color: #5c6773; /* Same as `--border-color`. */
25222535
--copy-path-button-color: #fff;
25232536
--copy-path-img-filter: invert(70%);

src/librustdoc/html/templates/page.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
{{ layout.external_html.before_content|safe }}
7878
{% if page.css_class != "src" %}
7979
<nav class="mobile-topbar"> {# #}
80-
<button class="sidebar-menu-toggle">&#9776;</button> {# #}
80+
<button class="sidebar-menu-toggle" title="show sidebar"></button> {# #}
8181
{% if !layout.logo.is_empty() || page.rust_logo %}
8282
<a class="logo-container" href="{{page.root_path|safe}}{{display_krate_with_trailing_slash|safe}}index.html"> {# #}
8383
{% if page.rust_logo %}

tests/rustdoc-gui/sidebar-source-code-display.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ call-function: ("check-colors", {
130130
set-window-size: (500, 700)
131131
reload:
132132
// Waiting for the sidebar to be displayed...
133-
wait-for-css: ("#src-sidebar", {"position": "sticky", "left": "0"})
133+
wait-for-css: (".src .sidebar > *", {"visibility": "visible"})
134134

135135
// We now check it takes the full size of the display.
136136
assert-property: ("body", {"clientWidth": "500", "clientHeight": "700"})
137137
assert-property: (".sidebar", {"clientWidth": "500", "clientHeight": "700"})
138138

139139
// We now check that the scroll position is kept when opening the sidebar.
140140
click: "#sidebar-button"
141-
wait-for-css: (".sidebar", {"position": "absolute", "left": "-1000px"})
141+
wait-for-css: (".src .sidebar > *", {"visibility": "hidden"})
142142
// We scroll to line 117 to change the scroll position.
143143
scroll-to: '//*[@id="117"]'
144144
assert-window-property: {"pageYOffset": "2516"}

tests/rustdoc/logo-class-rust.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
#![doc(rust_logo)]
44
// Note: this test is paired with logo-class.rs and logo-class-default.rs.
55
// @has logo_class_rust/struct.SomeStruct.html '//*[@class="logo-container"]/img[@class="rust-logo"]' ''
6-
// @has src/logo_class_rust/logo-class-rust.rs.html '//*[@class="sub-logo-container"]/img[@class="rust-logo"]' ''
76
pub struct SomeStruct;

tests/rustdoc/logo-class.rs

-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@
44

55
// @has logo_class/struct.SomeStruct.html '//*[@class="logo-container"]/img[@src="https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png"]' ''
66
// @!has logo_class/struct.SomeStruct.html '//*[@class="logo-container"]/img[@class="rust-logo"]' ''
7-
//
8-
// @has src/logo_class/logo-class.rs.html '//*[@class="sub-logo-container"]/img[@src="https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png"]' ''
9-
// @!has src/logo_class/logo-class.rs.html '//*[@class="sub-logo-container"]/img[@class="rust-logo"]' ''
107
pub struct SomeStruct;

0 commit comments

Comments
 (0)