Skip to content

Migrate test-arrow to CSS variables #104014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
@@ -1204,6 +1204,12 @@ a.test-arrow {
top: 5px;
right: 5px;
z-index: 1;
color: var(--test-arrow-color);
background-color: var(--test-arrow-background-color);
}
a.test-arrow:hover {
color: var(--test-arrow-hover-color);
background-color: var(--test-arrow-hover-background-color);
}
.example-wrap:hover .test-arrow {
visibility: visible;
16 changes: 4 additions & 12 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
@@ -58,6 +58,10 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--example-line-numbers-border-color: none;
--src-line-numbers-span-color: #5c6773;
--src-line-number-highlighted-background-color: rgba(255, 236, 164, 0.06);
--test-arrow-color: #788797;
--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);
}

.slider {
@@ -171,18 +175,6 @@ details.rustdoc-toggle > summary::before {
color: #788797;
}

a.test-arrow {
font-size: 100%;
color: #788797;
border-radius: 4px;
background-color: rgba(57, 175, 215, 0.09);
}

a.test-arrow:hover {
background-color: rgba(57, 175, 215, 0.368);
color: #c5c5c5;
}

:target {
background: rgba(255, 236, 164, 0.06);
border-right: 3px solid rgba(255, 180, 76, 0.85);
13 changes: 4 additions & 9 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
@@ -53,6 +53,10 @@
--example-line-numbers-border-color: #4a4949;
--src-line-numbers-span-color: #3b91e2;
--src-line-number-highlighted-background-color: #0a042f;
--test-arrow-color: #dedede;
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
--test-arrow-hover-color: #dedede;
--test-arrow-hover-background-color: #4e8bca;
}

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

a.test-arrow {
color: #dedede;
background-color: rgba(78, 139, 202, 0.2);
}

a.test-arrow:hover{
background-color: #4e8bca;
}

:target {
background-color: #494a3d;
border-right: 3px solid #bb7410;
13 changes: 4 additions & 9 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
@@ -53,6 +53,10 @@
--example-line-numbers-border-color: #c7c7c7;
--src-line-numbers-span-color: #c67e2d;
--src-line-number-highlighted-background-color: #fdffd3;
--test-arrow-color: #f5f5f5;
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
--test-arrow-hover-color: #f5f5f5;
--test-arrow-hover-background-color: #4e8bca;
}

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

a.test-arrow {
color: #f5f5f5;
background-color: rgba(78, 139, 202, 0.2);
}

a.test-arrow:hover{
background-color: #4e8bca;
}

:target {
background: #FDFFD3;
border-right: 3px solid #AD7C37;
55 changes: 51 additions & 4 deletions src/test/rustdoc-gui/run-on-hover.goml
Original file line number Diff line number Diff line change
@@ -1,7 +1,54 @@
// Example code blocks sometimes have a "Run" button to run them on the
// Playground. That button is hidden until the user hovers over the code block.
// This test checks that it is hidden, and that it shows on hover.
// This test checks that it is hidden, and that it shows on hover. It also
// checks for its color.
goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
assert-css: (".test-arrow", {"visibility": "hidden"})
move-cursor-to: ".example-wrap"
assert-css: (".test-arrow", {"visibility": "visible"})
show-text: true

define-function: (
"check-run-button",
(theme, color, background, hover_color, hover_background),
[
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
("reload"),
("assert-css", (".test-arrow", {"visibility": "hidden"})),
("move-cursor-to", ".example-wrap"),
("assert-css", (".test-arrow", {
"visibility": "visible",
"color": |color|,
"background-color": |background|,
"font-size": "22px",
"border-radius": "5px",
})),
("move-cursor-to", ".test-arrow"),
("assert-css", (".test-arrow:hover", {
"visibility": "visible",
"color": |hover_color|,
"background-color": |hover_background|,
"font-size": "22px",
"border-radius": "5px",
})),
],
)

call-function: ("check-run-button", {
"theme": "ayu",
"color": "rgb(120, 135, 151)",
"background": "rgba(57, 175, 215, 0.09)",
"hover_color": "rgb(197, 197, 197)",
"hover_background": "rgba(57, 175, 215, 0.37)",
})
call-function: ("check-run-button", {
"theme": "dark",
"color": "rgb(222, 222, 222)",
"background": "rgba(78, 139, 202, 0.2)",
"hover_color": "rgb(222, 222, 222)",
"hover_background": "rgb(78, 139, 202)",
})
call-function: ("check-run-button", {
"theme": "light",
"color": "rgb(245, 245, 245)",
"background": "rgba(78, 139, 202, 0.2)",
"hover_color": "rgb(245, 245, 245)",
"hover_background": "rgb(78, 139, 202)",
})