Skip to content

Commit d774bc3

Browse files
authored
Rollup merge of rust-lang#98502 - GuillaumeGomez:source-sidebar-hover, r=notriddle
Fix source sidebar hover in ayu theme In the screenshot below, `rc.rs` should be orange: ![Screenshot from 2022-06-25 22-24-06](https://user-images.githubusercontent.com/3050060/175789532-99e8781d-2e62-43f7-bbd9-1b1151e1f8c1.png) It's because the CSS selector was not precise enough and was "overloaded" with another one. This PR fixes it and adds a test for the colors in the source sidebar. cc `@jsha` r? `@notriddle`
2 parents b1d66d8 + 2bb46be commit d774bc3

File tree

4 files changed

+105
-6
lines changed

4 files changed

+105
-6
lines changed

src/librustdoc/html/static/css/themes/ayu.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -629,11 +629,11 @@ kbd {
629629
color: #fff;
630630
border-bottom-color: #5c6773;
631631
}
632-
div.files > a:hover, div.name:hover {
632+
#source-sidebar div.files > a:hover, div.name:hover {
633633
background-color: #14191f;
634634
color: #ffb44c;
635635
}
636-
div.files > .selected {
636+
#source-sidebar div.files > .selected {
637637
background-color: #14191f;
638638
color: #ffb44c;
639639
}

src/librustdoc/html/static/css/themes/dark.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,10 @@ kbd {
499499
#source-sidebar > .title {
500500
border-bottom-color: #ccc;
501501
}
502-
div.files > a:hover, div.name:hover {
502+
#source-sidebar div.files > a:hover, div.name:hover {
503503
background-color: #444;
504504
}
505-
div.files > .selected {
505+
#source-sidebar div.files > .selected {
506506
background-color: #333;
507507
}
508508

src/librustdoc/html/static/css/themes/light.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,10 @@ kbd {
483483
#source-sidebar > .title {
484484
border-bottom-color: #ccc;
485485
}
486-
div.files > a:hover, div.name:hover {
486+
#source-sidebar div.files > a:hover, div.name:hover {
487487
background-color: #E0E0E0;
488488
}
489-
div.files > .selected {
489+
#source-sidebar div.files > .selected {
490490
background-color: #fff;
491491
}
492492

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

+99
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,102 @@ assert-css: (".sidebar > *:not(#sidebar-toggle)", {"visibility": "hidden", "opac
1717
click: "#sidebar-toggle"
1818
// Because of the transition CSS, we check by using `wait-for-css` instead of `assert-css`.
1919
wait-for-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1})
20+
21+
// Now we check the display of the sidebar items.
22+
show-text: true
23+
24+
// First we start with the light theme.
25+
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
26+
reload:
27+
// Waiting for the sidebar to be displayed...
28+
wait-for-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1})
29+
assert-css: (
30+
"#source-sidebar .expand + .children a.selected",
31+
{"color": "rgb(0, 0, 0)", "background-color": "rgb(255, 255, 255)"},
32+
)
33+
// Without hover.
34+
assert-css: (
35+
"#source-sidebar .expand + .children > .files a:not(.selected)",
36+
{"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"},
37+
)
38+
// With hover.
39+
move-cursor-to: "#source-sidebar .expand + .children > .files a:not(.selected)"
40+
assert-css: (
41+
"#source-sidebar .expand + .children > .files a:not(.selected)",
42+
{"color": "rgb(0, 0, 0)", "background-color": "rgb(224, 224, 224)"},
43+
)
44+
// Without hover.
45+
assert-css: (
46+
"#source-sidebar .expand + .children .folders .name",
47+
{"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"},
48+
)
49+
// With hover.
50+
move-cursor-to: "#source-sidebar .expand + .children .folders .name"
51+
assert-css: (
52+
"#source-sidebar .expand + .children .folders .name",
53+
{"color": "rgb(0, 0, 0)", "background-color": "rgb(224, 224, 224)"},
54+
)
55+
56+
// Now with the dark theme.
57+
local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
58+
reload:
59+
// Waiting for the sidebar to be displayed...
60+
wait-for-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1})
61+
assert-css: (
62+
"#source-sidebar .expand + .children a.selected",
63+
{"color": "rgb(221, 221, 221)", "background-color": "rgb(51, 51, 51)"},
64+
)
65+
// Without hover.
66+
assert-css: (
67+
"#source-sidebar .expand + .children > .files a:not(.selected)",
68+
{"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"},
69+
)
70+
// With hover.
71+
move-cursor-to: "#source-sidebar .expand + .children > .files a:not(.selected)"
72+
assert-css: (
73+
"#source-sidebar .expand + .children > .files a:not(.selected)",
74+
{"color": "rgb(221, 221, 221)", "background-color": "rgb(68, 68, 68)"},
75+
)
76+
// Without hover.
77+
assert-css: (
78+
"#source-sidebar .expand + .children .folders .name",
79+
{"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"},
80+
)
81+
// With hover.
82+
move-cursor-to: "#source-sidebar .expand + .children .folders .name"
83+
assert-css: (
84+
"#source-sidebar .expand + .children .folders .name",
85+
{"color": "rgb(221, 221, 221)", "background-color": "rgb(68, 68, 68)"},
86+
)
87+
88+
// And finally with the ayu theme.
89+
local-storage: {"rustdoc-theme": "ayu", "rustdoc-use-system-theme": "false"}
90+
reload:
91+
// Waiting for the sidebar to be displayed...
92+
wait-for-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1})
93+
assert-css: (
94+
"#source-sidebar .expand + .children a.selected",
95+
{"color": "rgb(255, 180, 76)", "background-color": "rgb(20, 25, 31)"},
96+
)
97+
// Without hover.
98+
assert-css: (
99+
"#source-sidebar .expand + .children > .files a:not(.selected)",
100+
{"color": "rgb(197, 197, 197)", "background-color": "rgba(0, 0, 0, 0)"},
101+
)
102+
// With hover.
103+
move-cursor-to: "#source-sidebar .expand + .children > .files a:not(.selected)"
104+
assert-css: (
105+
"#source-sidebar .expand + .children > .files a:not(.selected)",
106+
{"color": "rgb(255, 180, 76)", "background-color": "rgb(20, 25, 31)"},
107+
)
108+
// Without hover.
109+
assert-css: (
110+
"#source-sidebar .expand + .children .folders .name",
111+
{"color": "rgb(197, 197, 197)", "background-color": "rgba(0, 0, 0, 0)"},
112+
)
113+
// With hover.
114+
move-cursor-to: "#source-sidebar .expand + .children .folders .name"
115+
assert-css: (
116+
"#source-sidebar .expand + .children .folders .name",
117+
{"color": "rgb(255, 180, 76)", "background-color": "rgb(20, 25, 31)"},
118+
)

0 commit comments

Comments
 (0)