rustdoc: clean up source sidebar hide button
This is a redesign of the feature, with parts pulled from https://github.com/rust-lang/rust/pull/119049 but with a button that looks more like a button and matches the one used on other sidebar pages.
This commit is contained in:
parent
43dcc9b786
commit
859bbc5def
10 changed files with 92 additions and 196 deletions
|
@ -2,18 +2,17 @@
|
|||
javascript: false
|
||||
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
||||
// Since the javascript is disabled, there shouldn't be a toggle.
|
||||
assert-false: "#src-sidebar-toggle"
|
||||
wait-for-css: (".sidebar", {"display": "none"})
|
||||
assert-css: ("#sidebar-button", {"display": "none"})
|
||||
|
||||
// Let's retry with javascript enabled.
|
||||
javascript: true
|
||||
reload:
|
||||
wait-for: "#src-sidebar-toggle"
|
||||
assert-css: ("#src-sidebar-toggle", {"visibility": "visible"})
|
||||
assert-css: (".sidebar > *:not(#src-sidebar-toggle)", {"visibility": "hidden"})
|
||||
wait-for: "#src-sidebar"
|
||||
assert-css: ("#src-sidebar", {"position": "absolute", "left": "-1000px"})
|
||||
// Let's expand the sidebar now.
|
||||
click: "#src-sidebar-toggle"
|
||||
wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
|
||||
click: "#src-sidebar"
|
||||
wait-for-css: ("#src-sidebar", {"position": "sticky", "left": "0"})
|
||||
|
||||
// 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,
|
||||
|
@ -38,28 +37,12 @@ define-function: (
|
|||
block {
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
|
||||
wait-for-css: ("#src-sidebar", {"position": "sticky", "left": "0"})
|
||||
assert-css: (
|
||||
"#src-sidebar details[open] > .files a.selected",
|
||||
{"color": |color_hover|, "background-color": |background|},
|
||||
)
|
||||
|
||||
// Without hover or focus.
|
||||
assert-css: ("#src-sidebar-toggle > button", {"background-color": |background_toggle|})
|
||||
// With focus.
|
||||
focus: "#src-sidebar-toggle > button"
|
||||
assert-css: (
|
||||
"#src-sidebar-toggle > button:focus",
|
||||
{"background-color": |background_toggle_hover|},
|
||||
)
|
||||
focus: ".search-input"
|
||||
// With hover.
|
||||
move-cursor-to: "#src-sidebar-toggle > button"
|
||||
assert-css: (
|
||||
"#src-sidebar-toggle > button:hover",
|
||||
{"background-color": |background_toggle_hover|},
|
||||
)
|
||||
|
||||
// Without hover or focus.
|
||||
assert-css: (
|
||||
"#src-sidebar details[open] > .files a:not(.selected)",
|
||||
|
@ -125,8 +108,6 @@ call-function: ("check-colors", {
|
|||
"color_hover": "#000",
|
||||
"background": "#fff",
|
||||
"background_hover": "#e0e0e0",
|
||||
"background_toggle": "rgba(0, 0, 0, 0)",
|
||||
"background_toggle_hover": "#e0e0e0",
|
||||
})
|
||||
call-function: ("check-colors", {
|
||||
"theme": "dark",
|
||||
|
@ -134,8 +115,6 @@ call-function: ("check-colors", {
|
|||
"color_hover": "#ddd",
|
||||
"background": "#333",
|
||||
"background_hover": "#444",
|
||||
"background_toggle": "rgba(0, 0, 0, 0)",
|
||||
"background_toggle_hover": "#676767",
|
||||
})
|
||||
call-function: ("check-colors", {
|
||||
"theme": "ayu",
|
||||
|
@ -143,42 +122,28 @@ call-function: ("check-colors", {
|
|||
"color_hover": "#ffb44c",
|
||||
"background": "#14191f",
|
||||
"background_hover": "#14191f",
|
||||
"background_toggle": "rgba(0, 0, 0, 0)",
|
||||
"background_toggle_hover": "rgba(70, 70, 70, 0.33)",
|
||||
})
|
||||
|
||||
// Now checking on mobile devices.
|
||||
set-window-size: (500, 700)
|
||||
reload:
|
||||
// Waiting for the sidebar to be displayed...
|
||||
wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
|
||||
wait-for-css: ("#src-sidebar", {"position": "sticky", "left": "0"})
|
||||
|
||||
// We now check it takes the full size of the display.
|
||||
assert-property: ("body", {"clientWidth": "500", "clientHeight": "700"})
|
||||
assert-property: (".sidebar", {"clientWidth": "500", "clientHeight": "700"})
|
||||
|
||||
// We now check the display of the toggle once the sidebar is expanded.
|
||||
assert-property: ("#src-sidebar-toggle", {"clientWidth": "500", "clientHeight": "39"})
|
||||
assert-css: (
|
||||
"#src-sidebar-toggle",
|
||||
{
|
||||
"border-top-width": "0px",
|
||||
"border-right-width": "0px",
|
||||
"border-left-width": "0px",
|
||||
"border-bottom-width": "1px",
|
||||
},
|
||||
)
|
||||
|
||||
// We now check that the scroll position is kept when opening the sidebar.
|
||||
click: "#src-sidebar-toggle"
|
||||
wait-for-css: (".sidebar", {"left": "-1000px"})
|
||||
click: "#sidebar-button"
|
||||
wait-for-css: (".sidebar", {"position": "absolute", "left": "-1000px"})
|
||||
// We scroll to line 117 to change the scroll position.
|
||||
scroll-to: '//*[@id="117"]'
|
||||
assert-window-property: {"pageYOffset": "2516"}
|
||||
// Expanding the sidebar...
|
||||
click: "#src-sidebar-toggle"
|
||||
click: "#sidebar-button"
|
||||
wait-for-css: (".sidebar", {"left": "0px"})
|
||||
click: "#src-sidebar-toggle"
|
||||
click: "#sidebar-button"
|
||||
wait-for-css: (".sidebar", {"left": "-1000px"})
|
||||
// The "scrollTop" property should be the same.
|
||||
assert-window-property: {"pageYOffset": "2516"}
|
||||
|
@ -189,7 +154,7 @@ assert-window-property: {"pageYOffset": "2516"}
|
|||
// you click one of them, you probably want to actually see the file's contents, and not just
|
||||
// make it the current selection.
|
||||
set-window-size: (500, 700)
|
||||
click: "#src-sidebar-toggle"
|
||||
click: "#sidebar-button"
|
||||
wait-for-css: ("#src-sidebar", {"visibility": "visible"})
|
||||
assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
|
||||
click: ".sidebar a.selected"
|
||||
|
@ -200,6 +165,6 @@ assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
|
|||
set-window-size: (1000, 1000)
|
||||
wait-for-css: ("#src-sidebar", {"visibility": "hidden"})
|
||||
assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
|
||||
click: "#src-sidebar-toggle"
|
||||
click: "#sidebar-button"
|
||||
wait-for-css: ("#src-sidebar", {"visibility": "visible"})
|
||||
assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue