Skip to content

Commit b20dcf6

Browse files
authored
Rollup merge of #104849 - GuillaumeGomez:source-code-sidebar-css-migration, r=notriddle
Migrate source code elements style to CSS variables r? `@notriddle`
2 parents 11d840c + e6a4008 commit b20dcf6

File tree

5 files changed

+50
-28
lines changed

5 files changed

+50
-28
lines changed

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

+7
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,13 @@ a.test-arrow:hover {
13431343
border-bottom: 1px solid var(--border-color);
13441344
margin-bottom: 6px;
13451345
}
1346+
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
1347+
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
1348+
background-color: var(--source-sidebar-background-hover);
1349+
}
1350+
#source-sidebar div.files > a.selected {
1351+
background-color: var(--source-sidebar-background-selected);
1352+
}
13461353
#sidebar-toggle > button {
13471354
font-size: inherit;
13481355
font-weight: bold;

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
8484
--crate-search-div-hover-filter: invert(98%) sepia(12%) saturate(81%) hue-rotate(343deg)
8585
brightness(113%) contrast(76%);
8686
--crate-search-hover-border: #e0e0e0;
87+
--source-sidebar-background-selected: #14191f;
88+
--source-sidebar-background-hover: #14191f;
8789
}
8890

8991
h1, h2, h3, h4 {
@@ -208,12 +210,8 @@ pre.rust .kw-2, pre.rust .prelude-ty {}
208210
color: #fff;
209211
}
210212
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
211-
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
212-
background-color: #14191f;
213-
color: #ffb44c;
214-
}
213+
#source-sidebar div.files > a:focus, details.dir-entry summary:focus,
215214
#source-sidebar div.files > a.selected {
216-
background-color: #14191f;
217215
color: #ffb44c;
218216
}
219217

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

+2-8
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
--crate-search-div-hover-filter: invert(69%) sepia(60%) saturate(6613%) hue-rotate(184deg)
8080
brightness(100%) contrast(91%);
8181
--crate-search-hover-border: #2196f3;
82+
--source-sidebar-background-selected: #333;
83+
--source-sidebar-background-hover: #444;
8284
}
8385

8486
.content .item-info::before { color: #ccc; }
@@ -105,14 +107,6 @@ details.rustdoc-toggle > summary::before {
105107
color: #888;
106108
}
107109

108-
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
109-
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
110-
background-color: #444;
111-
}
112-
#source-sidebar div.files > a.selected {
113-
background-color: #333;
114-
}
115-
116110
.scraped-example-list .scrape-help {
117111
border-color: #aaa;
118112
color: #eee;

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

+2-7
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
--crate-search-div-hover-filter: invert(44%) sepia(18%) saturate(23%) hue-rotate(317deg)
7777
brightness(96%) contrast(93%);
7878
--crate-search-hover-border: #717171;
79+
--source-sidebar-background-selected: #fff;
80+
--source-sidebar-background-hover: #e0e0e0;
7981
}
8082

8183
.content .item-info::before { color: #ccc; }
@@ -98,13 +100,6 @@ body.source .example-wrap pre.rust a {
98100
color: #888;
99101
}
100102

101-
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
102-
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
103-
background-color: #E0E0E0;
104-
}
105-
#source-sidebar div.files > a.selected {
106-
background-color: #fff;
107-
}
108103
.scraped-example-list .scrape-help {
109104
border-color: #555;
110105
color: #333;

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

+36-8
Original file line numberDiff line numberDiff line change
@@ -43,49 +43,77 @@ define-function: (
4343
"#source-sidebar details[open] > .files a.selected",
4444
{"color": |color_hover|, "background-color": |background|},
4545
)),
46+
4647
// Without hover or focus.
4748
("assert-css", ("#sidebar-toggle > button", {"background-color": |background_toggle|})),
4849
// With focus.
4950
("focus", "#sidebar-toggle > button"),
50-
("assert-css", ("#sidebar-toggle > button", {"background-color": |background_toggle_hover|})),
51+
("assert-css", (
52+
"#sidebar-toggle > button:focus",
53+
{"background-color": |background_toggle_hover|},
54+
)),
5155
("focus", ".search-input"),
5256
// With hover.
5357
("move-cursor-to", "#sidebar-toggle > button"),
54-
("assert-css", ("#sidebar-toggle > button", {"background-color": |background_toggle_hover|})),
55-
// Without hover.
58+
("assert-css", (
59+
"#sidebar-toggle > button:hover",
60+
{"background-color": |background_toggle_hover|},
61+
)),
62+
63+
// Without hover or focus.
5664
("assert-css", (
5765
"#source-sidebar details[open] > .files a:not(.selected)",
5866
{"color": |color|, "background-color": |background_toggle|},
5967
)),
6068
// With focus.
6169
("focus", "#source-sidebar details[open] > .files a:not(.selected)"),
6270
("wait-for-css", (
63-
"#source-sidebar details[open] > .files a:not(.selected)",
71+
"#source-sidebar details[open] > .files a:not(.selected):focus",
6472
{"color": |color_hover|, "background-color": |background_hover|},
6573
)),
6674
("focus", ".search-input"),
6775
// With hover.
6876
("move-cursor-to", "#source-sidebar details[open] > .files a:not(.selected)"),
6977
("assert-css", (
70-
"#source-sidebar details[open] > .files a:not(.selected)",
78+
"#source-sidebar details[open] > .files a:not(.selected):hover",
7179
{"color": |color_hover|, "background-color": |background_hover|},
7280
)),
73-
// Without hover.
81+
82+
// Without hover or focus.
83+
("assert-css", (
84+
"#source-sidebar .dir-entry summary",
85+
{"color": |color|, "background-color": |background_toggle|},
86+
)),
87+
// With focus.
88+
("focus", "#source-sidebar .dir-entry summary"),
89+
("wait-for-css", (
90+
"#source-sidebar .dir-entry summary:focus",
91+
{"color": |color_hover|, "background-color": |background_hover|},
92+
)),
93+
("focus", ".search-input"),
94+
// With hover.
95+
("move-cursor-to", "#source-sidebar .dir-entry summary"),
96+
("assert-css", (
97+
"#source-sidebar .dir-entry summary:hover",
98+
{"color": |color_hover|, "background-color": |background_hover|},
99+
)),
100+
101+
// Without hover or focus.
74102
("assert-css", (
75103
"#source-sidebar details[open] > .folders > details > summary",
76104
{"color": |color|, "background-color": |background_toggle|},
77105
)),
78106
// With focus.
79107
("focus", "#source-sidebar details[open] > .folders > details > summary"),
80108
("wait-for-css", (
81-
"#source-sidebar details[open] > .folders > details > summary",
109+
"#source-sidebar details[open] > .folders > details > summary:focus",
82110
{"color": |color_hover|, "background-color": |background_hover|},
83111
)),
84112
("focus", ".search-input"),
85113
// With hover.
86114
("move-cursor-to", "#source-sidebar details[open] > .folders > details > summary"),
87115
("assert-css", (
88-
"#source-sidebar details[open] > .folders > details > summary",
116+
"#source-sidebar details[open] > .folders > details > summary:hover",
89117
{"color": |color_hover|, "background-color": |background_hover|},
90118
)),
91119
],

0 commit comments

Comments
 (0)