Skip to content

Commit 46160e6

Browse files
committed
Auto merge of rust-lang#106110 - GuillaumeGomez:toggle-line-background, r=notriddle
Migrate toggle-line-inner background to CSS variable r? `@notriddle`
2 parents 7e4f466 + 457f6c8 commit 46160e6

File tree

5 files changed

+51
-22
lines changed

5 files changed

+51
-22
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,11 @@ in storage.js
19931993
.toggle-line-inner {
19941994
min-width: 2px;
19951995
height: 100%;
1996+
background: var(--scrape-example-toggle-line-background);
1997+
}
1998+
1999+
.toggle-line:hover .toggle-line-inner {
2000+
background: var(--scrape-example-toggle-line-hover-background);
19962001
}
19972002

19982003
.more-scraped-examples .scraped-example, .example-links {

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
8989
--source-sidebar-background-hover: #14191f;
9090
--table-alt-row-background-color: #191f26;
9191
--codeblock-link-background: #333;
92+
--scrape-example-toggle-line-background: #999;
93+
--scrape-example-toggle-line-hover-background: #c5c5c5;
9294
}
9395

9496
h1, h2, h3, h4 {
@@ -220,9 +222,3 @@ pre.rust .kw-2, pre.rust .prelude-ty {}
220222
.scraped-example:not(.expanded) .code-wrapper::after {
221223
background: linear-gradient(to top, rgba(15, 20, 25, 1), rgba(15, 20, 25, 0));
222224
}
223-
.toggle-line-inner {
224-
background: #999;
225-
}
226-
.toggle-line:hover .toggle-line-inner {
227-
background: #c5c5c5;
228-
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@
8484
--source-sidebar-background-hover: #444;
8585
--table-alt-row-background-color: #2A2A2A;
8686
--codeblock-link-background: #333;
87+
--scrape-example-toggle-line-background: #999;
88+
--scrape-example-toggle-line-hover-background: #c5c5c5;
8789
}
8890

8991
#titles > button:not(.selected) {
@@ -116,9 +118,3 @@
116118
.scraped-example:not(.expanded) .code-wrapper::after {
117119
background: linear-gradient(to top, rgba(53, 53, 53, 1), rgba(53, 53, 53, 0));
118120
}
119-
.toggle-line-inner {
120-
background: #999;
121-
}
122-
.toggle-line:hover .toggle-line-inner {
123-
background: #c5c5c5;
124-
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@
8181
--source-sidebar-background-hover: #e0e0e0;
8282
--table-alt-row-background-color: #F5F5F5;
8383
--codeblock-link-background: #eee;
84+
--scrape-example-toggle-line-background: #ccc;
85+
--scrape-example-toggle-line-hover-background: #999;
8486
}
8587

8688
#titles > button:not(.selected) {
@@ -113,9 +115,3 @@
113115
.scraped-example:not(.expanded) .code-wrapper::after {
114116
background: linear-gradient(to top, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
115117
}
116-
.toggle-line-inner {
117-
background: #ccc;
118-
}
119-
.toggle-line:hover .toggle-line-inner {
120-
background: #999;
121-
}

src/test/rustdoc-gui/scrape-examples-toggle.goml

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,46 @@
11
// This tests checks that the "scraped examples" toggle is working as expected.
22
goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
33

4-
// Clicking "More examples..." will open additional examples
5-
assert-attribute-false: (".more-examples-toggle", {"open": ""})
6-
click: ".more-examples-toggle"
7-
assert-attribute: (".more-examples-toggle", {"open": ""})
4+
// Checking the color of the toggle line.
5+
show-text: true
6+
define-function: (
7+
"check-color",
8+
(theme, toggle_line_color, toggle_line_hover_color),
9+
[
10+
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
11+
("reload"),
12+
13+
// Clicking "More examples..." will open additional examples
14+
("assert-attribute-false", (".more-examples-toggle", {"open": ""})),
15+
("click", ".more-examples-toggle"),
16+
("assert-attribute", (".more-examples-toggle", {"open": ""})),
17+
18+
("assert-css", (".toggle-line-inner", {"background-color": |toggle_line_color|}, ALL)),
19+
("move-cursor-to", ".toggle-line"),
20+
("assert-css", (
21+
".toggle-line:hover .toggle-line-inner",
22+
{"background-color": |toggle_line_hover_color|},
23+
)),
24+
// Moving cursor away from the toggle line to prevent disrupting next test.
25+
("move-cursor-to", ".search-input"),
26+
],
27+
)
28+
29+
call-function: ("check-color", {
30+
"theme": "ayu",
31+
"toggle_line_color": "rgb(153, 153, 153)",
32+
"toggle_line_hover_color": "rgb(197, 197, 197)",
33+
})
34+
call-function: ("check-color", {
35+
"theme": "dark",
36+
"toggle_line_color": "rgb(153, 153, 153)",
37+
"toggle_line_hover_color": "rgb(197, 197, 197)",
38+
})
39+
call-function: ("check-color", {
40+
"theme": "light",
41+
"toggle_line_color": "rgb(204, 204, 204)",
42+
"toggle_line_hover_color": "rgb(153, 153, 153)",
43+
})
844

945
// Toggling all docs will close additional examples
1046
click: "#toggle-all-docs"

0 commit comments

Comments
 (0)