Skip to content
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

Migrate scraped-examples top and bottom "borders" to CSS variables #107152

Merged
merged 2 commits into from
Jan 22, 2023
Merged
Show file tree
Hide file tree
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
Expand Up @@ -1907,9 +1907,15 @@ in storage.js
}
.scraped-example:not(.expanded) .code-wrapper:before {
top: 0;
background: linear-gradient(to bottom,
var(--scrape-example-code-wrapper-background-start),
var(--scrape-example-code-wrapper-background-end));
}
.scraped-example:not(.expanded) .code-wrapper:after {
bottom: 0;
background: linear-gradient(to top,
var(--scrape-example-code-wrapper-background-start),
var(--scrape-example-code-wrapper-background-end));
}

.scraped-example .code-wrapper .example-wrap {
Expand Down
9 changes: 2 additions & 7 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--scrape-example-help-color: #eee;
--scrape-example-help-hover-border-color: #fff;
--scrape-example-help-hover-color: #fff;
--scrape-example-code-wrapper-background-start: rgba(15, 20, 25, 1);
--scrape-example-code-wrapper-background-end: rgba(15, 20, 25, 0);
}

h1, h2, h3, h4 {
Expand Down Expand Up @@ -203,10 +205,3 @@ above the `@media (max-width: 700px)` rules due to a bug in the css checker */
#source-sidebar div.files > a.selected {
color: #ffb44c;
}

.scraped-example:not(.expanded) .code-wrapper::before {
background: linear-gradient(to bottom, rgba(15, 20, 25, 1), rgba(15, 20, 25, 0));
}
.scraped-example:not(.expanded) .code-wrapper::after {
background: linear-gradient(to top, rgba(15, 20, 25, 1), rgba(15, 20, 25, 0));
}
9 changes: 2 additions & 7 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
--scrape-example-help-color: #eee;
--scrape-example-help-hover-border-color: #fff;
--scrape-example-help-hover-color: #fff;
--scrape-example-code-wrapper-background-start: rgba(53, 53, 53, 1);
--scrape-example-code-wrapper-background-end: rgba(53, 53, 53, 0);
}

#search-tabs > button:not(.selected) {
Expand All @@ -103,10 +105,3 @@
border-top-color: #0089ff;
background-color: #353535;
}

.scraped-example:not(.expanded) .code-wrapper::before {
background: linear-gradient(to bottom, rgba(53, 53, 53, 1), rgba(53, 53, 53, 0));
}
.scraped-example:not(.expanded) .code-wrapper::after {
background: linear-gradient(to top, rgba(53, 53, 53, 1), rgba(53, 53, 53, 0));
}
9 changes: 2 additions & 7 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
--scrape-example-help-color: #333;
--scrape-example-help-hover-border-color: #000;
--scrape-example-help-hover-color: #000;
--scrape-example-code-wrapper-background-start: rgba(255, 255, 255, 1);
--scrape-example-code-wrapper-background-end: rgba(255, 255, 255, 0);
}

#search-tabs > button:not(.selected) {
Expand All @@ -100,10 +102,3 @@
background-color: #ffffff;
border-top-color: #0089ff;
}

.scraped-example:not(.expanded) .code-wrapper::before {
background: linear-gradient(to bottom, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
}
.scraped-example:not(.expanded) .code-wrapper::after {
background: linear-gradient(to top, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
}
36 changes: 36 additions & 0 deletions tests/rustdoc-gui/scrape-examples-color.goml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,39 @@ call-function: ("check-colors", {
"help_hover_border": "rgb(0, 0, 0)",
"help_hover_color": "rgb(0, 0, 0)",
})

// Now testing the top and bottom background in case there is only one scraped examples.
goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html"

define-function: (
"check-background",
(theme, background_color_start, background_color_end),
block {
local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", }
reload:
assert-css: (".scraped-example:not(.expanded) .code-wrapper::before", {
"background-image": "linear-gradient(" + |background_color_start| + ", " +
|background_color_end| + ")",
})
assert-css: (".scraped-example:not(.expanded) .code-wrapper::after", {
"background-image": "linear-gradient(to top, " + |background_color_start| + ", " +
|background_color_end| + ")",
})
},
)

call-function: ("check-background", {
"theme": "ayu",
"background_color_start": "rgb(15, 20, 25)",
"background_color_end": "rgba(15, 20, 25, 0)",
})
call-function: ("check-background", {
"theme": "dark",
"background_color_start": "rgb(53, 53, 53)",
"background_color_end": "rgba(53, 53, 53, 0)",
})
call-function: ("check-background", {
"theme": "light",
"background_color_start": "rgb(255, 255, 255)",
"background_color_end": "rgba(255, 255, 255, 0)",
})