Skip to content

Migrate toggle-line-inner background to CSS variable #106110

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
Dec 24, 2022
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
5 changes: 5 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,11 @@ in storage.js
.toggle-line-inner {
min-width: 2px;
height: 100%;
background: var(--scrape-example-toggle-line-background);
}

.toggle-line:hover .toggle-line-inner {
background: var(--scrape-example-toggle-line-hover-background);
}

.more-scraped-examples .scraped-example, .example-links {
Expand Down
8 changes: 2 additions & 6 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--source-sidebar-background-hover: #14191f;
--table-alt-row-background-color: #191f26;
--codeblock-link-background: #333;
--scrape-example-toggle-line-background: #999;
--scrape-example-toggle-line-hover-background: #c5c5c5;
}

h1, h2, h3, h4 {
Expand Down Expand Up @@ -221,9 +223,3 @@ pre.rust .kw-2, pre.rust .prelude-ty {}
.scraped-example:not(.expanded) .code-wrapper::after {
background: linear-gradient(to top, rgba(15, 20, 25, 1), rgba(15, 20, 25, 0));
}
.toggle-line-inner {
background: #999;
}
.toggle-line:hover .toggle-line-inner {
background: #c5c5c5;
}
8 changes: 2 additions & 6 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
--source-sidebar-background-hover: #444;
--table-alt-row-background-color: #2A2A2A;
--codeblock-link-background: #333;
--scrape-example-toggle-line-background: #999;
--scrape-example-toggle-line-hover-background: #c5c5c5;
}

#titles > button:not(.selected) {
Expand Down Expand Up @@ -117,9 +119,3 @@
.scraped-example:not(.expanded) .code-wrapper::after {
background: linear-gradient(to top, rgba(53, 53, 53, 1), rgba(53, 53, 53, 0));
}
.toggle-line-inner {
background: #999;
}
.toggle-line:hover .toggle-line-inner {
background: #c5c5c5;
}
8 changes: 2 additions & 6 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
--source-sidebar-background-hover: #e0e0e0;
--table-alt-row-background-color: #F5F5F5;
--codeblock-link-background: #eee;
--scrape-example-toggle-line-background: #ccc;
--scrape-example-toggle-line-hover-background: #999;
}

#titles > button:not(.selected) {
Expand Down Expand Up @@ -114,9 +116,3 @@
.scraped-example:not(.expanded) .code-wrapper::after {
background: linear-gradient(to top, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
}
.toggle-line-inner {
background: #ccc;
}
.toggle-line:hover .toggle-line-inner {
background: #999;
}
44 changes: 40 additions & 4 deletions src/test/rustdoc-gui/scrape-examples-toggle.goml
Original file line number Diff line number Diff line change
@@ -1,9 +1,45 @@
goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"

// Clicking "More examples..." will open additional examples
assert-attribute-false: (".more-examples-toggle", {"open": ""})
click: ".more-examples-toggle"
assert-attribute: (".more-examples-toggle", {"open": ""})
// Checking the color of the toggle line.
show-text: true
define-function: (
"check-color",
(theme, toggle_line_color, toggle_line_hover_color),
[
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
("reload"),

// Clicking "More examples..." will open additional examples
("assert-attribute-false", (".more-examples-toggle", {"open": ""})),
("click", ".more-examples-toggle"),
("assert-attribute", (".more-examples-toggle", {"open": ""})),

("assert-css", (".toggle-line-inner", {"background-color": |toggle_line_color|}, ALL)),
("move-cursor-to", ".toggle-line"),
("assert-css", (
".toggle-line:hover .toggle-line-inner",
{"background-color": |toggle_line_hover_color|},
)),
// Moving cursor away from the toggle line to prevent disrupting next test.
("move-cursor-to", ".search-input"),
],
)

call-function: ("check-color", {
"theme": "ayu",
"toggle_line_color": "rgb(153, 153, 153)",
"toggle_line_hover_color": "rgb(197, 197, 197)",
})
call-function: ("check-color", {
"theme": "dark",
"toggle_line_color": "rgb(153, 153, 153)",
"toggle_line_hover_color": "rgb(197, 197, 197)",
})
call-function: ("check-color", {
"theme": "light",
"toggle_line_color": "rgb(204, 204, 204)",
"toggle_line_hover_color": "rgb(153, 153, 153)",
})

// Toggling all docs will close additional examples
click: "#toggle-all-docs"
Expand Down