Skip to content

Commit ef0d79f

Browse files
authored
Rollup merge of #104014 - GuillaumeGomez:run-button-css-var, r=notriddle
Migrate test-arrow to CSS variables There should be no UI changes. I kept both `color` and `background-color` properties even though only the ayu theme is actually completely making use of them on hover. r? ``@notriddle``
2 parents d93b520 + 8e2956d commit ef0d79f

File tree

5 files changed

+69
-34
lines changed

5 files changed

+69
-34
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,12 @@ a.test-arrow {
12041204
top: 5px;
12051205
right: 5px;
12061206
z-index: 1;
1207+
color: var(--test-arrow-color);
1208+
background-color: var(--test-arrow-background-color);
1209+
}
1210+
a.test-arrow:hover {
1211+
color: var(--test-arrow-hover-color);
1212+
background-color: var(--test-arrow-hover-background-color);
12071213
}
12081214
.example-wrap:hover .test-arrow {
12091215
visibility: visible;

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

+4-12
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ Original by Dempfi (https://github.com/dempfi/ayu)
5959
--example-line-numbers-border-color: none;
6060
--src-line-numbers-span-color: #5c6773;
6161
--src-line-number-highlighted-background-color: rgba(255, 236, 164, 0.06);
62+
--test-arrow-color: #788797;
63+
--test-arrow-background-color: rgba(57, 175, 215, 0.09);
64+
--test-arrow-hover-color: #c5c5c5;
65+
--test-arrow-hover-background-color: rgba(57, 175, 215, 0.368);
6266
}
6367

6468
.slider {
@@ -172,18 +176,6 @@ details.rustdoc-toggle > summary::before {
172176
color: #788797;
173177
}
174178

175-
a.test-arrow {
176-
font-size: 100%;
177-
color: #788797;
178-
border-radius: 4px;
179-
background-color: rgba(57, 175, 215, 0.09);
180-
}
181-
182-
a.test-arrow:hover {
183-
background-color: rgba(57, 175, 215, 0.368);
184-
color: #c5c5c5;
185-
}
186-
187179
:target {
188180
background: rgba(255, 236, 164, 0.06);
189181
border-right: 3px solid rgba(255, 180, 76, 0.85);

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

+4-9
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
--example-line-numbers-border-color: #4a4949;
5555
--src-line-numbers-span-color: #3b91e2;
5656
--src-line-number-highlighted-background-color: #0a042f;
57+
--test-arrow-color: #dedede;
58+
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
59+
--test-arrow-hover-color: #dedede;
60+
--test-arrow-hover-background-color: #4e8bca;
5761
}
5862

5963
.slider {
@@ -94,15 +98,6 @@ details.rustdoc-toggle > summary::before {
9498
filter: invert(69%) sepia(60%) saturate(6613%) hue-rotate(184deg) brightness(100%) contrast(91%);
9599
}
96100

97-
a.test-arrow {
98-
color: #dedede;
99-
background-color: rgba(78, 139, 202, 0.2);
100-
}
101-
102-
a.test-arrow:hover{
103-
background-color: #4e8bca;
104-
}
105-
106101
:target {
107102
background-color: #494a3d;
108103
border-right: 3px solid #bb7410;

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

+4-9
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
--example-line-numbers-border-color: #c7c7c7;
5555
--src-line-numbers-span-color: #c67e2d;
5656
--src-line-number-highlighted-background-color: #fdffd3;
57+
--test-arrow-color: #f5f5f5;
58+
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
59+
--test-arrow-hover-color: #f5f5f5;
60+
--test-arrow-hover-background-color: #4e8bca;
5761
}
5862

5963
.slider {
@@ -89,15 +93,6 @@ body.source .example-wrap pre.rust a {
8993
filter: invert(44%) sepia(18%) saturate(23%) hue-rotate(317deg) brightness(96%) contrast(93%);
9094
}
9195

92-
a.test-arrow {
93-
color: #f5f5f5;
94-
background-color: rgba(78, 139, 202, 0.2);
95-
}
96-
97-
a.test-arrow:hover{
98-
background-color: #4e8bca;
99-
}
100-
10196
:target {
10297
background: #FDFFD3;
10398
border-right: 3px solid #AD7C37;
+51-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,54 @@
11
// Example code blocks sometimes have a "Run" button to run them on the
22
// Playground. That button is hidden until the user hovers over the code block.
3-
// This test checks that it is hidden, and that it shows on hover.
3+
// This test checks that it is hidden, and that it shows on hover. It also
4+
// checks for its color.
45
goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
5-
assert-css: (".test-arrow", {"visibility": "hidden"})
6-
move-cursor-to: ".example-wrap"
7-
assert-css: (".test-arrow", {"visibility": "visible"})
6+
show-text: true
7+
8+
define-function: (
9+
"check-run-button",
10+
(theme, color, background, hover_color, hover_background),
11+
[
12+
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
13+
("reload"),
14+
("assert-css", (".test-arrow", {"visibility": "hidden"})),
15+
("move-cursor-to", ".example-wrap"),
16+
("assert-css", (".test-arrow", {
17+
"visibility": "visible",
18+
"color": |color|,
19+
"background-color": |background|,
20+
"font-size": "22px",
21+
"border-radius": "5px",
22+
})),
23+
("move-cursor-to", ".test-arrow"),
24+
("assert-css", (".test-arrow:hover", {
25+
"visibility": "visible",
26+
"color": |hover_color|,
27+
"background-color": |hover_background|,
28+
"font-size": "22px",
29+
"border-radius": "5px",
30+
})),
31+
],
32+
)
33+
34+
call-function: ("check-run-button", {
35+
"theme": "ayu",
36+
"color": "rgb(120, 135, 151)",
37+
"background": "rgba(57, 175, 215, 0.09)",
38+
"hover_color": "rgb(197, 197, 197)",
39+
"hover_background": "rgba(57, 175, 215, 0.37)",
40+
})
41+
call-function: ("check-run-button", {
42+
"theme": "dark",
43+
"color": "rgb(222, 222, 222)",
44+
"background": "rgba(78, 139, 202, 0.2)",
45+
"hover_color": "rgb(222, 222, 222)",
46+
"hover_background": "rgb(78, 139, 202)",
47+
})
48+
call-function: ("check-run-button", {
49+
"theme": "light",
50+
"color": "rgb(245, 245, 245)",
51+
"background": "rgba(78, 139, 202, 0.2)",
52+
"hover_color": "rgb(245, 245, 245)",
53+
"hover_background": "rgb(78, 139, 202)",
54+
})

0 commit comments

Comments
 (0)