Skip to content

Commit eca27a2

Browse files
authored
Rollup merge of #104169 - GuillaumeGomez:migrate-css-target, r=notriddle
Migrate `:target` rules to use CSS variables There should be no GUI changes. r? `@notriddle`
2 parents e9b4a84 + 149ab45 commit eca27a2

File tree

5 files changed

+43
-15
lines changed

5 files changed

+43
-15
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,8 @@ h3.variant {
12691269

12701270
:target {
12711271
padding-right: 3px;
1272+
background-color: var(--target-background-color);
1273+
border-right: 3px solid var(--target-border-color);
12721274
}
12731275

12741276
.notable-traits-tooltip {

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
6363
--test-arrow-background-color: rgba(57, 175, 215, 0.09);
6464
--test-arrow-hover-color: #c5c5c5;
6565
--test-arrow-hover-background-color: rgba(57, 175, 215, 0.368);
66+
--target-background-color: rgba(255, 236, 164, 0.06);
67+
--target-border-color: rgba(255, 180, 76, 0.85);
6668
--rust-logo-filter: drop-shadow(1px 0 0px #fff)
6769
drop-shadow(0 1px 0 #fff)
6870
drop-shadow(-1px 0 0 #fff)
@@ -168,11 +170,6 @@ details.rustdoc-toggle > summary::before {
168170
color: #788797;
169171
}
170172

171-
:target {
172-
background: rgba(255, 236, 164, 0.06);
173-
border-right: 3px solid rgba(255, 180, 76, 0.85);
174-
}
175-
176173
.search-failed a {
177174
color: #39AFD7;
178175
}

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
5959
--test-arrow-hover-color: #dedede;
6060
--test-arrow-hover-background-color: #4e8bca;
61+
--target-background-color: #494a3d;
62+
--target-border-color: #bb7410;
6163
--rust-logo-filter: drop-shadow(1px 0 0px #fff)
6264
drop-shadow(0 1px 0 #fff)
6365
drop-shadow(-1px 0 0 #fff)
@@ -90,11 +92,6 @@ details.rustdoc-toggle > summary::before {
9092
filter: invert(100%);
9193
}
9294

93-
:target {
94-
background-color: #494a3d;
95-
border-right: 3px solid #bb7410;
96-
}
97-
9895
.search-failed a {
9996
color: #0089ff;
10097
}

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
5959
--test-arrow-hover-color: #f5f5f5;
6060
--test-arrow-hover-background-color: #4e8bca;
61+
--target-background-color: #fdFfd3;
62+
--target-border-color: #ad7c37;
6163
--rust-logo-filter: initial;
6264
/* match border-color; uses https://codepen.io/sosuke/pen/Pjoqqp */
6365
--crate-search-div-filter: invert(100%) sepia(0%) saturate(4223%) hue-rotate(289deg)
@@ -83,11 +85,6 @@ body.source .example-wrap pre.rust a {
8385
background: #eee;
8486
}
8587

86-
:target {
87-
background: #FDFFD3;
88-
border-right: 3px solid #AD7C37;
89-
}
90-
9188
.search-failed a {
9289
color: #3873AD;
9390
}

src/test/rustdoc-gui/target.goml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Check that the targetted element has the expected styles.
2+
goto: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html#method.a_method"
3+
show-text: true
4+
5+
// Confirming that the method is the target.
6+
assert: "#method\.a_method:target"
7+
8+
define-function: (
9+
"check-style",
10+
(theme, background, border),
11+
[
12+
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
13+
("reload"),
14+
("assert-css", ("#method\.a_method:target", {
15+
"background-color": |background|,
16+
"border-right": "3px solid " + |border|,
17+
})),
18+
],
19+
)
20+
21+
call-function: ("check-style", {
22+
"theme": "ayu",
23+
"background": "rgba(255, 236, 164, 0.06)",
24+
"border": "rgba(255, 180, 76, 0.85)",
25+
})
26+
call-function: ("check-style", {
27+
"theme": "dark",
28+
"background": "rgb(73, 74, 61)",
29+
"border": "rgb(187, 116, 16)",
30+
})
31+
call-function: ("check-style", {
32+
"theme": "light",
33+
"background": "rgb(253, 255, 211)",
34+
"border": "rgb(173, 124, 55)",
35+
})

0 commit comments

Comments
 (0)