Skip to content

Commit 808be91

Browse files
committed
Auto merge of #106262 - GuillaumeGomez:migrate-more-scraped-examples-css, r=notriddle
Migrate more scraped examples CSS rules to CSS variables It's based on #106218 so it will need to wait for it to be merged first. r? `@notriddle`
2 parents 973a4db + 4b5c092 commit 808be91

File tree

5 files changed

+47
-25
lines changed

5 files changed

+47
-25
lines changed

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

+8
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,14 @@ in storage.js
19591959
.scraped-example .example-wrap .rust span.highlight.focus {
19601960
background: var(--scrape-example-code-line-highlight-focus);
19611961
}
1962+
.scraped-example-list .scrape-help {
1963+
border-color: var(--scrape-example-help-border-color);
1964+
color: var(--scrape-example-help-color);
1965+
}
1966+
.scraped-example-list .scrape-help:hover {
1967+
border-color: var(--scrape-example-help-hover-border-color);
1968+
color: var(--scrape-example-help-hover-color);
1969+
}
19621970

19631971
.more-examples-toggle {
19641972
max-width: calc(100% + 25px);

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

+4-8
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ Original by Dempfi (https://github.com/dempfi/ayu)
9393
--scrape-example-toggle-line-hover-background: #c5c5c5;
9494
--scrape-example-code-line-highlight: rgb(91, 59, 1);
9595
--scrape-example-code-line-highlight-focus: rgb(124, 75, 15);
96+
--scrape-example-help-border-color: #aaa;
97+
--scrape-example-help-color: #eee;
98+
--scrape-example-help-hover-border-color: #fff;
99+
--scrape-example-help-hover-color: #fff;
96100
}
97101

98102
h1, h2, h3, h4 {
@@ -200,14 +204,6 @@ above the `@media (max-width: 700px)` rules due to a bug in the css checker */
200204
color: #ffb44c;
201205
}
202206

203-
.scraped-example-list .scrape-help {
204-
border-color: #aaa;
205-
color: #eee;
206-
}
207-
.scraped-example-list .scrape-help:hover {
208-
border-color: white;
209-
color: white;
210-
}
211207
.scraped-example:not(.expanded) .code-wrapper::before {
212208
background: linear-gradient(to bottom, rgba(15, 20, 25, 1), rgba(15, 20, 25, 0));
213209
}

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

+4-8
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
--scrape-example-toggle-line-hover-background: #c5c5c5;
8989
--scrape-example-code-line-highlight: rgb(91, 59, 1);
9090
--scrape-example-code-line-highlight-focus: rgb(124, 75, 15);
91+
--scrape-example-help-border-color: #aaa;
92+
--scrape-example-help-color: #eee;
93+
--scrape-example-help-hover-border-color: #fff;
94+
--scrape-example-help-hover-color: #fff;
9195
}
9296

9397
#search-tabs > button:not(.selected) {
@@ -100,14 +104,6 @@
100104
background-color: #353535;
101105
}
102106

103-
.scraped-example-list .scrape-help {
104-
border-color: #aaa;
105-
color: #eee;
106-
}
107-
.scraped-example-list .scrape-help:hover {
108-
border-color: white;
109-
color: white;
110-
}
111107
.scraped-example:not(.expanded) .code-wrapper::before {
112108
background: linear-gradient(to bottom, rgba(53, 53, 53, 1), rgba(53, 53, 53, 0));
113109
}

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

+4-8
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@
8585
--scrape-example-toggle-line-hover-background: #999;
8686
--scrape-example-code-line-highlight: #fcffd6;
8787
--scrape-example-code-line-highlight-focus: #f6fdb0;
88+
--scrape-example-help-border-color: #555;
89+
--scrape-example-help-color: #333;
90+
--scrape-example-help-hover-border-color: #000;
91+
--scrape-example-help-hover-color: #000;
8892
}
8993

9094
#search-tabs > button:not(.selected) {
@@ -97,14 +101,6 @@
97101
border-top-color: #0089ff;
98102
}
99103

100-
.scraped-example-list .scrape-help {
101-
border-color: #555;
102-
color: #333;
103-
}
104-
.scraped-example-list .scrape-help:hover {
105-
border-color: black;
106-
color: black;
107-
}
108104
.scraped-example:not(.expanded) .code-wrapper::before {
109105
background: linear-gradient(to bottom, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
110106
}

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

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Check that scrape example code blocks have the expected colors.
22
goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
3+
show-text: true
34

45
define-function: (
56
"check-colors",
6-
(theme, highlight, highlight_focus),
7+
(theme, highlight, highlight_focus, help_border, help_color, help_hover_border,
8+
help_hover_color),
79
[
810
("local-storage", { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", }),
911
("reload"),
@@ -14,21 +16,45 @@ define-function: (
1416
("assert-css", (".scraped-example .example-wrap .rust span.highlight.focus", {
1517
"background-color": |highlight_focus|,
1618
}, ALL)),
19+
20+
("assert-css", (".scraped-example-list .scrape-help", {
21+
"border-color": |help_border|,
22+
"color": |help_color|,
23+
})),
24+
("move-cursor-to", ".scraped-example-list .scrape-help"),
25+
("assert-css", (".scraped-example-list .scrape-help:hover", {
26+
"border-color": |help_hover_border|,
27+
"color": |help_hover_color|,
28+
})),
29+
// Moving the cursor to another item to not break next runs.
30+
("move-cursor-to", ".search-input"),
1731
]
1832
)
1933

2034
call-function: ("check-colors", {
2135
"theme": "ayu",
2236
"highlight": "rgb(91, 59, 1)",
2337
"highlight_focus": "rgb(124, 75, 15)",
38+
"help_border": "rgb(170, 170, 170)",
39+
"help_color": "rgb(238, 238, 238)",
40+
"help_hover_border": "rgb(255, 255, 255)",
41+
"help_hover_color": "rgb(255, 255, 255)",
2442
})
2543
call-function: ("check-colors", {
2644
"theme": "dark",
2745
"highlight": "rgb(91, 59, 1)",
2846
"highlight_focus": "rgb(124, 75, 15)",
47+
"help_border": "rgb(170, 170, 170)",
48+
"help_color": "rgb(238, 238, 238)",
49+
"help_hover_border": "rgb(255, 255, 255)",
50+
"help_hover_color": "rgb(255, 255, 255)",
2951
})
3052
call-function: ("check-colors", {
3153
"theme": "light",
3254
"highlight": "rgb(252, 255, 214)",
3355
"highlight_focus": "rgb(246, 253, 176)",
56+
"help_border": "rgb(85, 85, 85)",
57+
"help_color": "rgb(51, 51, 51)",
58+
"help_hover_border": "rgb(0, 0, 0)",
59+
"help_hover_color": "rgb(0, 0, 0)",
3460
})

0 commit comments

Comments
 (0)