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.
This commit is contained in:
Matthias Krüger 2022-12-16 14:02:20 +01:00 committed by GitHub
commit d30057b797
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 37 deletions

View File

@ -396,15 +396,15 @@ img {
overflow-y: hidden; overflow-y: hidden;
} }
.source .sidebar, #sidebar-toggle, #source-sidebar { .source .sidebar, #src-sidebar-toggle, #source-sidebar {
background-color: var(--sidebar-background-color); background-color: var(--sidebar-background-color);
} }
#sidebar-toggle > button:hover, #sidebar-toggle > button:focus { #src-sidebar-toggle > button:hover, #src-sidebar-toggle > button:focus {
background-color: var(--sidebar-background-color-hover); background-color: var(--sidebar-background-color-hover);
} }
.source .sidebar > *:not(#sidebar-toggle) { .source .sidebar > *:not(#src-sidebar-toggle) {
visibility: hidden; visibility: hidden;
} }
@ -413,7 +413,7 @@ img {
flex-basis: 300px; flex-basis: 300px;
} }
.source-sidebar-expanded .source .sidebar > *:not(#sidebar-toggle) { .source-sidebar-expanded .source .sidebar > *:not(#src-sidebar-toggle) {
visibility: visible; visibility: visible;
} }
@ -1289,7 +1289,7 @@ a.test-arrow:hover {
font-size: 1rem; font-size: 1rem;
} }
#sidebar-toggle { #src-sidebar-toggle {
position: sticky; position: sticky;
top: 0; top: 0;
left: 0; left: 0;
@ -1318,7 +1318,7 @@ a.test-arrow:hover {
#source-sidebar div.files > a.selected { #source-sidebar div.files > a.selected {
background-color: var(--source-sidebar-background-selected); background-color: var(--source-sidebar-background-selected);
} }
#sidebar-toggle > button { #src-sidebar-toggle > button {
font-size: inherit; font-size: inherit;
font-weight: bold; font-weight: bold;
background: none; background: none;
@ -1720,7 +1720,7 @@ in storage.js
left: -11px; left: -11px;
} }
#sidebar-toggle { #src-sidebar-toggle {
position: fixed; position: fixed;
left: 1px; left: 1px;
top: 100px; top: 100px;
@ -1734,7 +1734,7 @@ in storage.js
border-left: 0; border-left: 0;
} }
.source-sidebar-expanded #sidebar-toggle { .source-sidebar-expanded #src-sidebar-toggle {
left: unset; left: unset;
top: unset; top: unset;
width: unset; width: unset;
@ -1845,10 +1845,10 @@ in storage.js
width: 35px; width: 35px;
} }
#sidebar-toggle { #src-sidebar-toggle {
top: 10px; top: 10px;
} }
.source-sidebar-expanded #sidebar-toggle { .source-sidebar-expanded #src-sidebar-toggle {
top: unset; top: unset;
} }
} }

View File

@ -83,7 +83,7 @@ function toggleSidebar() {
function createSidebarToggle() { function createSidebarToggle() {
const sidebarToggle = document.createElement("div"); const sidebarToggle = document.createElement("div");
sidebarToggle.id = "sidebar-toggle"; sidebarToggle.id = "src-sidebar-toggle";
const inner = document.createElement("button"); const inner = document.createElement("button");

View File

@ -1,7 +1,7 @@
// This test checks that the source code pages sidebar toggle is working as expected. // This test checks that the source code pages sidebar toggle is working as expected.
goto: "file://" + |DOC_PATH| + "/test_docs/index.html" goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
click: ".srclink" click: ".srclink"
wait-for: "#sidebar-toggle" wait-for: "#src-sidebar-toggle"
click: "#sidebar-toggle" click: "#src-sidebar-toggle"
fail: true fail: true
assert-css: ("#source-sidebar", { "left": "-300px" }) assert-css: ("#source-sidebar", { "left": "-300px" })

View File

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

View File

@ -2,18 +2,18 @@
javascript: false javascript: false
goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
// Since the javascript is disabled, there shouldn't be a toggle. // Since the javascript is disabled, there shouldn't be a toggle.
assert-false: "#sidebar-toggle" assert-false: "#src-sidebar-toggle"
wait-for-css: (".sidebar", {"display": "none"}) wait-for-css: (".sidebar", {"display": "none"})
// Let's retry with javascript enabled. // Let's retry with javascript enabled.
javascript: true javascript: true
reload: reload:
wait-for: "#sidebar-toggle" wait-for: "#src-sidebar-toggle"
assert-css: ("#sidebar-toggle", {"visibility": "visible"}) assert-css: ("#src-sidebar-toggle", {"visibility": "visible"})
assert-css: (".sidebar > *:not(#sidebar-toggle)", {"visibility": "hidden"}) assert-css: (".sidebar > *:not(#src-sidebar-toggle)", {"visibility": "hidden"})
// Let's expand the sidebar now. // Let's expand the sidebar now.
click: "#sidebar-toggle" click: "#src-sidebar-toggle"
wait-for-css: ("#sidebar-toggle", {"visibility": "visible"}) wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
// We now check that opening the sidebar and clicking a link will leave it open. // We now check that opening the sidebar and clicking a link will leave it open.
// The behavior here on desktop is different than the behavior on mobile, // The behavior here on desktop is different than the behavior on mobile,
@ -38,25 +38,25 @@ define-function: (
[ [
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
("reload"), ("reload"),
("wait-for-css", ("#sidebar-toggle", {"visibility": "visible"})), ("wait-for-css", ("#src-sidebar-toggle", {"visibility": "visible"})),
("assert-css", ( ("assert-css", (
"#source-sidebar details[open] > .files a.selected", "#source-sidebar details[open] > .files a.selected",
{"color": |color_hover|, "background-color": |background|}, {"color": |color_hover|, "background-color": |background|},
)), )),
// Without hover or focus. // Without hover or focus.
("assert-css", ("#sidebar-toggle > button", {"background-color": |background_toggle|})), ("assert-css", ("#src-sidebar-toggle > button", {"background-color": |background_toggle|})),
// With focus. // With focus.
("focus", "#sidebar-toggle > button"), ("focus", "#src-sidebar-toggle > button"),
("assert-css", ( ("assert-css", (
"#sidebar-toggle > button:focus", "#src-sidebar-toggle > button:focus",
{"background-color": |background_toggle_hover|}, {"background-color": |background_toggle_hover|},
)), )),
("focus", ".search-input"), ("focus", ".search-input"),
// With hover. // With hover.
("move-cursor-to", "#sidebar-toggle > button"), ("move-cursor-to", "#src-sidebar-toggle > button"),
("assert-css", ( ("assert-css", (
"#sidebar-toggle > button:hover", "#src-sidebar-toggle > button:hover",
{"background-color": |background_toggle_hover|}, {"background-color": |background_toggle_hover|},
)), )),
@ -151,16 +151,16 @@ call-function: ("check-colors", {
size: (500, 700) size: (500, 700)
reload: reload:
// Waiting for the sidebar to be displayed... // Waiting for the sidebar to be displayed...
wait-for-css: ("#sidebar-toggle", {"visibility": "visible"}) wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
// We now check it takes the full size of the display. // We now check it takes the full size of the display.
assert-property: ("body", {"clientWidth": "500", "clientHeight": "700"}) assert-property: ("body", {"clientWidth": "500", "clientHeight": "700"})
assert-property: (".sidebar", {"clientWidth": "500", "clientHeight": "700"}) assert-property: (".sidebar", {"clientWidth": "500", "clientHeight": "700"})
// We now check the display of the toggle once the sidebar is expanded. // We now check the display of the toggle once the sidebar is expanded.
assert-property: ("#sidebar-toggle", {"clientWidth": "500", "clientHeight": "39"}) assert-property: ("#src-sidebar-toggle", {"clientWidth": "500", "clientHeight": "39"})
assert-css: ( assert-css: (
"#sidebar-toggle", "#src-sidebar-toggle",
{ {
"border-top-width": "0px", "border-top-width": "0px",
"border-right-width": "0px", "border-right-width": "0px",
@ -170,28 +170,28 @@ assert-css: (
) )
// We now check that the scroll position is kept when opening the sidebar. // We now check that the scroll position is kept when opening the sidebar.
click: "#sidebar-toggle" click: "#src-sidebar-toggle"
wait-for-css: (".sidebar", {"width": "0px"}) wait-for-css: (".sidebar", {"width": "0px"})
// We scroll to line 117 to change the scroll position. // We scroll to line 117 to change the scroll position.
scroll-to: '//*[@id="117"]' scroll-to: '//*[@id="117"]'
assert-window-property: {"pageYOffset": "2542"} assert-window-property: {"pageYOffset": "2542"}
// Expanding the sidebar... // Expanding the sidebar...
click: "#sidebar-toggle" click: "#src-sidebar-toggle"
wait-for-css: (".sidebar", {"width": "500px"}) wait-for-css: (".sidebar", {"width": "500px"})
click: "#sidebar-toggle" click: "#src-sidebar-toggle"
wait-for-css: (".sidebar", {"width": "0px"}) wait-for-css: (".sidebar", {"width": "0px"})
// The "scrollTop" property should be the same. // The "scrollTop" property should be the same.
assert-window-property: {"pageYOffset": "2542"} assert-window-property: {"pageYOffset": "2542"}
// We now check that the scroll position is restored if the window is resized. // We now check that the scroll position is restored if the window is resized.
size: (500, 700) size: (500, 700)
click: "#sidebar-toggle" click: "#src-sidebar-toggle"
wait-for-css: ("#source-sidebar", {"visibility": "visible"}) wait-for-css: ("#source-sidebar", {"visibility": "visible"})
assert-window-property: {"pageYOffset": "0"} assert-window-property: {"pageYOffset": "0"}
size: (900, 900) size: (900, 900)
assert-window-property: {"pageYOffset": "2542"} assert-window-property: {"pageYOffset": "2542"}
size: (500, 700) size: (500, 700)
click: "#sidebar-toggle" click: "#src-sidebar-toggle"
wait-for-css: ("#source-sidebar", {"visibility": "hidden"}) wait-for-css: ("#source-sidebar", {"visibility": "hidden"})
// We now check that opening the sidebar and clicking a link will close it. // We now check that opening the sidebar and clicking a link will close it.
@ -199,7 +199,7 @@ wait-for-css: ("#source-sidebar", {"visibility": "hidden"})
// but common sense dictates that if you have a list of files that fills the entire screen, and // but common sense dictates that if you have a list of files that fills the entire screen, and
// you click one of them, you probably want to actually see the file's contents, and not just // you click one of them, you probably want to actually see the file's contents, and not just
// make it the current selection. // make it the current selection.
click: "#sidebar-toggle" click: "#src-sidebar-toggle"
wait-for-css: ("#source-sidebar", {"visibility": "visible"}) wait-for-css: ("#source-sidebar", {"visibility": "visible"})
assert-local-storage: {"rustdoc-source-sidebar-show": "true"} assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
click: ".sidebar a.selected" click: ".sidebar a.selected"
@ -210,6 +210,6 @@ assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
size: (1000, 1000) size: (1000, 1000)
wait-for-css: ("#source-sidebar", {"visibility": "hidden"}) wait-for-css: ("#source-sidebar", {"visibility": "hidden"})
assert-local-storage: {"rustdoc-source-sidebar-show": "false"} assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
click: "#sidebar-toggle" click: "#src-sidebar-toggle"
wait-for-css: ("#source-sidebar", {"visibility": "visible"}) wait-for-css: ("#source-sidebar", {"visibility": "visible"})
assert-local-storage: {"rustdoc-source-sidebar-show": "true"} assert-local-storage: {"rustdoc-source-sidebar-show": "true"}

View File

@ -97,7 +97,7 @@ assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
// Checking the source code sidebar. // Checking the source code sidebar.
// First we "open" it. // First we "open" it.
click: "#sidebar-toggle" click: "#src-sidebar-toggle"
assert: ".source-sidebar-expanded" assert: ".source-sidebar-expanded"
// We check that the first entry of the sidebar is collapsed // We check that the first entry of the sidebar is collapsed