Skip to content

Commit d30057b

Browse files
authored
Rollup merge of #105764 - notriddle:notriddle/src-sidebar-toggle, r=GuillaumeGomez
rustdoc: name the source page sidebar-toggle `#src-sidebar-toggle` The old name doesn't get across where it's really supposed to be used.
2 parents 3142e6f + a84483e commit d30057b

File tree

6 files changed

+37
-37
lines changed

6 files changed

+37
-37
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -396,15 +396,15 @@ img {
396396
overflow-y: hidden;
397397
}
398398

399-
.source .sidebar, #sidebar-toggle, #source-sidebar {
399+
.source .sidebar, #src-sidebar-toggle, #source-sidebar {
400400
background-color: var(--sidebar-background-color);
401401
}
402402

403-
#sidebar-toggle > button:hover, #sidebar-toggle > button:focus {
403+
#src-sidebar-toggle > button:hover, #src-sidebar-toggle > button:focus {
404404
background-color: var(--sidebar-background-color-hover);
405405
}
406406

407-
.source .sidebar > *:not(#sidebar-toggle) {
407+
.source .sidebar > *:not(#src-sidebar-toggle) {
408408
visibility: hidden;
409409
}
410410

@@ -413,7 +413,7 @@ img {
413413
flex-basis: 300px;
414414
}
415415

416-
.source-sidebar-expanded .source .sidebar > *:not(#sidebar-toggle) {
416+
.source-sidebar-expanded .source .sidebar > *:not(#src-sidebar-toggle) {
417417
visibility: visible;
418418
}
419419

@@ -1289,7 +1289,7 @@ a.test-arrow:hover {
12891289
font-size: 1rem;
12901290
}
12911291

1292-
#sidebar-toggle {
1292+
#src-sidebar-toggle {
12931293
position: sticky;
12941294
top: 0;
12951295
left: 0;
@@ -1318,7 +1318,7 @@ a.test-arrow:hover {
13181318
#source-sidebar div.files > a.selected {
13191319
background-color: var(--source-sidebar-background-selected);
13201320
}
1321-
#sidebar-toggle > button {
1321+
#src-sidebar-toggle > button {
13221322
font-size: inherit;
13231323
font-weight: bold;
13241324
background: none;
@@ -1720,7 +1720,7 @@ in storage.js
17201720
left: -11px;
17211721
}
17221722

1723-
#sidebar-toggle {
1723+
#src-sidebar-toggle {
17241724
position: fixed;
17251725
left: 1px;
17261726
top: 100px;
@@ -1734,7 +1734,7 @@ in storage.js
17341734
border-left: 0;
17351735
}
17361736

1737-
.source-sidebar-expanded #sidebar-toggle {
1737+
.source-sidebar-expanded #src-sidebar-toggle {
17381738
left: unset;
17391739
top: unset;
17401740
width: unset;
@@ -1845,10 +1845,10 @@ in storage.js
18451845
width: 35px;
18461846
}
18471847

1848-
#sidebar-toggle {
1848+
#src-sidebar-toggle {
18491849
top: 10px;
18501850
}
1851-
.source-sidebar-expanded #sidebar-toggle {
1851+
.source-sidebar-expanded #src-sidebar-toggle {
18521852
top: unset;
18531853
}
18541854
}

src/librustdoc/html/static/js/source-script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function toggleSidebar() {
8383

8484
function createSidebarToggle() {
8585
const sidebarToggle = document.createElement("div");
86-
sidebarToggle.id = "sidebar-toggle";
86+
sidebarToggle.id = "src-sidebar-toggle";
8787

8888
const inner = document.createElement("button");
8989

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test checks that the source code pages sidebar toggle is working as expected.
22
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
33
click: ".srclink"
4-
wait-for: "#sidebar-toggle"
5-
click: "#sidebar-toggle"
4+
wait-for: "#src-sidebar-toggle"
5+
click: "#src-sidebar-toggle"
66
fail: true
77
assert-css: ("#source-sidebar", { "left": "-300px" })

src/test/rustdoc-gui/cursor.goml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ assert-css: (".sidebar-menu-toggle", {"cursor": "pointer"})
2121

2222
// the sidebar toggle button on the source code pages
2323
goto: "file://" + |DOC_PATH| + "/src/lib2/lib.rs.html"
24-
assert-css: ("#sidebar-toggle > button", {"cursor": "pointer"})
24+
assert-css: ("#src-sidebar-toggle > button", {"cursor": "pointer"})

src/test/rustdoc-gui/sidebar-source-code-display.goml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
javascript: false
33
goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
44
// Since the javascript is disabled, there shouldn't be a toggle.
5-
assert-false: "#sidebar-toggle"
5+
assert-false: "#src-sidebar-toggle"
66
wait-for-css: (".sidebar", {"display": "none"})
77

88
// Let's retry with javascript enabled.
99
javascript: true
1010
reload:
11-
wait-for: "#sidebar-toggle"
12-
assert-css: ("#sidebar-toggle", {"visibility": "visible"})
13-
assert-css: (".sidebar > *:not(#sidebar-toggle)", {"visibility": "hidden"})
11+
wait-for: "#src-sidebar-toggle"
12+
assert-css: ("#src-sidebar-toggle", {"visibility": "visible"})
13+
assert-css: (".sidebar > *:not(#src-sidebar-toggle)", {"visibility": "hidden"})
1414
// Let's expand the sidebar now.
15-
click: "#sidebar-toggle"
16-
wait-for-css: ("#sidebar-toggle", {"visibility": "visible"})
15+
click: "#src-sidebar-toggle"
16+
wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
1717

1818
// We now check that opening the sidebar and clicking a link will leave it open.
1919
// The behavior here on desktop is different than the behavior on mobile,
@@ -38,25 +38,25 @@ define-function: (
3838
[
3939
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
4040
("reload"),
41-
("wait-for-css", ("#sidebar-toggle", {"visibility": "visible"})),
41+
("wait-for-css", ("#src-sidebar-toggle", {"visibility": "visible"})),
4242
("assert-css", (
4343
"#source-sidebar details[open] > .files a.selected",
4444
{"color": |color_hover|, "background-color": |background|},
4545
)),
4646

4747
// Without hover or focus.
48-
("assert-css", ("#sidebar-toggle > button", {"background-color": |background_toggle|})),
48+
("assert-css", ("#src-sidebar-toggle > button", {"background-color": |background_toggle|})),
4949
// With focus.
50-
("focus", "#sidebar-toggle > button"),
50+
("focus", "#src-sidebar-toggle > button"),
5151
("assert-css", (
52-
"#sidebar-toggle > button:focus",
52+
"#src-sidebar-toggle > button:focus",
5353
{"background-color": |background_toggle_hover|},
5454
)),
5555
("focus", ".search-input"),
5656
// With hover.
57-
("move-cursor-to", "#sidebar-toggle > button"),
57+
("move-cursor-to", "#src-sidebar-toggle > button"),
5858
("assert-css", (
59-
"#sidebar-toggle > button:hover",
59+
"#src-sidebar-toggle > button:hover",
6060
{"background-color": |background_toggle_hover|},
6161
)),
6262

@@ -151,16 +151,16 @@ call-function: ("check-colors", {
151151
size: (500, 700)
152152
reload:
153153
// Waiting for the sidebar to be displayed...
154-
wait-for-css: ("#sidebar-toggle", {"visibility": "visible"})
154+
wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
155155

156156
// We now check it takes the full size of the display.
157157
assert-property: ("body", {"clientWidth": "500", "clientHeight": "700"})
158158
assert-property: (".sidebar", {"clientWidth": "500", "clientHeight": "700"})
159159

160160
// We now check the display of the toggle once the sidebar is expanded.
161-
assert-property: ("#sidebar-toggle", {"clientWidth": "500", "clientHeight": "39"})
161+
assert-property: ("#src-sidebar-toggle", {"clientWidth": "500", "clientHeight": "39"})
162162
assert-css: (
163-
"#sidebar-toggle",
163+
"#src-sidebar-toggle",
164164
{
165165
"border-top-width": "0px",
166166
"border-right-width": "0px",
@@ -170,36 +170,36 @@ assert-css: (
170170
)
171171

172172
// We now check that the scroll position is kept when opening the sidebar.
173-
click: "#sidebar-toggle"
173+
click: "#src-sidebar-toggle"
174174
wait-for-css: (".sidebar", {"width": "0px"})
175175
// We scroll to line 117 to change the scroll position.
176176
scroll-to: '//*[@id="117"]'
177177
assert-window-property: {"pageYOffset": "2542"}
178178
// Expanding the sidebar...
179-
click: "#sidebar-toggle"
179+
click: "#src-sidebar-toggle"
180180
wait-for-css: (".sidebar", {"width": "500px"})
181-
click: "#sidebar-toggle"
181+
click: "#src-sidebar-toggle"
182182
wait-for-css: (".sidebar", {"width": "0px"})
183183
// The "scrollTop" property should be the same.
184184
assert-window-property: {"pageYOffset": "2542"}
185185

186186
// We now check that the scroll position is restored if the window is resized.
187187
size: (500, 700)
188-
click: "#sidebar-toggle"
188+
click: "#src-sidebar-toggle"
189189
wait-for-css: ("#source-sidebar", {"visibility": "visible"})
190190
assert-window-property: {"pageYOffset": "0"}
191191
size: (900, 900)
192192
assert-window-property: {"pageYOffset": "2542"}
193193
size: (500, 700)
194-
click: "#sidebar-toggle"
194+
click: "#src-sidebar-toggle"
195195
wait-for-css: ("#source-sidebar", {"visibility": "hidden"})
196196

197197
// We now check that opening the sidebar and clicking a link will close it.
198198
// The behavior here on mobile is different than the behavior on desktop,
199199
// but common sense dictates that if you have a list of files that fills the entire screen, and
200200
// you click one of them, you probably want to actually see the file's contents, and not just
201201
// make it the current selection.
202-
click: "#sidebar-toggle"
202+
click: "#src-sidebar-toggle"
203203
wait-for-css: ("#source-sidebar", {"visibility": "visible"})
204204
assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
205205
click: ".sidebar a.selected"
@@ -210,6 +210,6 @@ assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
210210
size: (1000, 1000)
211211
wait-for-css: ("#source-sidebar", {"visibility": "hidden"})
212212
assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
213-
click: "#sidebar-toggle"
213+
click: "#src-sidebar-toggle"
214214
wait-for-css: ("#source-sidebar", {"visibility": "visible"})
215215
assert-local-storage: {"rustdoc-source-sidebar-show": "true"}

src/test/rustdoc-gui/source-code-page.goml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
9797
// Checking the source code sidebar.
9898

9999
// First we "open" it.
100-
click: "#sidebar-toggle"
100+
click: "#src-sidebar-toggle"
101101
assert: ".source-sidebar-expanded"
102102

103103
// We check that the first entry of the sidebar is collapsed

0 commit comments

Comments
 (0)