Skip to content

Commit

Permalink
Rollup merge of #104169 - GuillaumeGomez:migrate-css-target, r=notriddle
Browse files Browse the repository at this point in the history
Migrate `:target` rules to use CSS variables

There should be no GUI changes.

r? `@notriddle`
  • Loading branch information
Dylan-DPC authored Nov 11, 2022
2 parents e9b4a84 + 149ab45 commit eca27a2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,8 @@ h3.variant {

:target {
padding-right: 3px;
background-color: var(--target-background-color);
border-right: 3px solid var(--target-border-color);
}

.notable-traits-tooltip {
Expand Down
7 changes: 2 additions & 5 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--test-arrow-background-color: rgba(57, 175, 215, 0.09);
--test-arrow-hover-color: #c5c5c5;
--test-arrow-hover-background-color: rgba(57, 175, 215, 0.368);
--target-background-color: rgba(255, 236, 164, 0.06);
--target-border-color: rgba(255, 180, 76, 0.85);
--rust-logo-filter: drop-shadow(1px 0 0px #fff)
drop-shadow(0 1px 0 #fff)
drop-shadow(-1px 0 0 #fff)
Expand Down Expand Up @@ -168,11 +170,6 @@ details.rustdoc-toggle > summary::before {
color: #788797;
}

:target {
background: rgba(255, 236, 164, 0.06);
border-right: 3px solid rgba(255, 180, 76, 0.85);
}

.search-failed a {
color: #39AFD7;
}
Expand Down
7 changes: 2 additions & 5 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
--test-arrow-hover-color: #dedede;
--test-arrow-hover-background-color: #4e8bca;
--target-background-color: #494a3d;
--target-border-color: #bb7410;
--rust-logo-filter: drop-shadow(1px 0 0px #fff)
drop-shadow(0 1px 0 #fff)
drop-shadow(-1px 0 0 #fff)
Expand Down Expand Up @@ -90,11 +92,6 @@ details.rustdoc-toggle > summary::before {
filter: invert(100%);
}

:target {
background-color: #494a3d;
border-right: 3px solid #bb7410;
}

.search-failed a {
color: #0089ff;
}
Expand Down
7 changes: 2 additions & 5 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
--test-arrow-hover-color: #f5f5f5;
--test-arrow-hover-background-color: #4e8bca;
--target-background-color: #fdFfd3;
--target-border-color: #ad7c37;
--rust-logo-filter: initial;
/* match border-color; uses https://codepen.io/sosuke/pen/Pjoqqp */
--crate-search-div-filter: invert(100%) sepia(0%) saturate(4223%) hue-rotate(289deg)
Expand All @@ -83,11 +85,6 @@ body.source .example-wrap pre.rust a {
background: #eee;
}

:target {
background: #FDFFD3;
border-right: 3px solid #AD7C37;
}

.search-failed a {
color: #3873AD;
}
Expand Down
35 changes: 35 additions & 0 deletions src/test/rustdoc-gui/target.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Check that the targetted element has the expected styles.
goto: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html#method.a_method"
show-text: true

// Confirming that the method is the target.
assert: "#method\.a_method:target"

define-function: (
"check-style",
(theme, background, border),
[
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
("reload"),
("assert-css", ("#method\.a_method:target", {
"background-color": |background|,
"border-right": "3px solid " + |border|,
})),
],
)

call-function: ("check-style", {
"theme": "ayu",
"background": "rgba(255, 236, 164, 0.06)",
"border": "rgba(255, 180, 76, 0.85)",
})
call-function: ("check-style", {
"theme": "dark",
"background": "rgb(73, 74, 61)",
"border": "rgb(187, 116, 16)",
})
call-function: ("check-style", {
"theme": "light",
"background": "rgb(253, 255, 211)",
"border": "rgb(173, 124, 55)",
})

0 comments on commit eca27a2

Please sign in to comment.