Skip to content

Commit 08e2e4e

Browse files
authored
Rollup merge of rust-lang#106194 - notriddle:notriddle/sidebar-background, r=GuillaumeGomez
rustdoc: combine common sidebar background color CSS rules
2 parents d07be1a + 5c0b60f commit 08e2e4e

File tree

3 files changed

+92
-6
lines changed

3 files changed

+92
-6
lines changed

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,6 @@ img {
378378
filter: var(--rust-logo-filter);
379379
}
380380

381-
.sidebar, .mobile-topbar, .sidebar-menu-toggle {
382-
background-color: var(--sidebar-background-color);
383-
}
384-
385381
.sidebar {
386382
font-size: 0.875rem;
387383
flex: 0 0 200px;
@@ -400,7 +396,8 @@ img {
400396
overflow-y: hidden;
401397
}
402398

403-
.source .sidebar, #src-sidebar-toggle, #source-sidebar {
399+
.sidebar, .mobile-topbar, .sidebar-menu-toggle,
400+
#src-sidebar-toggle, #source-sidebar {
404401
background-color: var(--sidebar-background-color);
405402
}
406403

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

+46-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,52 @@
11
// The goal of this test is to ensure that the sidebar is working as expected in the source
22
// code pages.
33
goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
4-
// First: desktop mode.
4+
show-text: true
5+
6+
// First, check the sidebar colors.
7+
define-function: (
8+
"check-colors",
9+
(theme, color, background_color),
10+
[
11+
("local-storage", {
12+
"rustdoc-theme": |theme|,
13+
"rustdoc-use-system-theme": "false",
14+
}),
15+
("reload"),
16+
// Checking results colors.
17+
("assert-css", (".source .sidebar", {
18+
"color": |color|,
19+
"background-color": |background_color|
20+
}, ALL)),
21+
],
22+
)
23+
24+
call-function: (
25+
"check-colors",
26+
{
27+
"theme": "ayu",
28+
"color": "rgb(197, 197, 197)",
29+
"background_color": "rgb(20, 25, 31)",
30+
}
31+
)
32+
call-function: (
33+
"check-colors",
34+
{
35+
"theme": "dark",
36+
"color": "rgb(221, 221, 221)",
37+
"background_color": "rgb(80, 80, 80)",
38+
}
39+
)
40+
call-function: (
41+
"check-colors",
42+
{
43+
"theme": "light",
44+
"color": "rgb(0, 0, 0)",
45+
"background_color": "rgb(245, 245, 245)",
46+
}
47+
)
48+
49+
// Next, desktop mode layout.
550
size: (1100, 800)
651
// We check that the sidebar isn't expanded and has the expected width.
752
assert-css: ("nav.sidebar", {"width": "50px"})

src/test/rustdoc-gui/sidebar.goml

+44
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,50 @@
22
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
33
assert-property: (".sidebar", {"clientWidth": "200"})
44
show-text: true
5+
6+
// First, check the sidebar colors.
7+
define-function: (
8+
"check-colors",
9+
(theme, color, background_color),
10+
[
11+
("local-storage", {
12+
"rustdoc-theme": |theme|,
13+
"rustdoc-use-system-theme": "false",
14+
}),
15+
("reload"),
16+
// Checking results colors.
17+
("assert-css", (".sidebar", {
18+
"color": |color|,
19+
"background-color": |background_color|
20+
}, ALL)),
21+
],
22+
)
23+
24+
call-function: (
25+
"check-colors",
26+
{
27+
"theme": "ayu",
28+
"color": "rgb(197, 197, 197)",
29+
"background_color": "rgb(20, 25, 31)",
30+
}
31+
)
32+
call-function: (
33+
"check-colors",
34+
{
35+
"theme": "dark",
36+
"color": "rgb(221, 221, 221)",
37+
"background_color": "rgb(80, 80, 80)",
38+
}
39+
)
40+
call-function: (
41+
"check-colors",
42+
{
43+
"theme": "light",
44+
"color": "rgb(0, 0, 0)",
45+
"background_color": "rgb(245, 245, 245)",
46+
}
47+
)
48+
549
local-storage: {"rustdoc-theme": "light"}
650
// We reload the page so the local storage settings are being used.
751
reload:

0 commit comments

Comments
 (0)