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 alias search result to CSS variables #104666

Merged
merged 2 commits into from
Nov 22, 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
7 changes: 7 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,13 @@ so that we can apply CSS-filters to change the arrow color in themes */
background-color: var(--search-result-link-focus-background-color);
}

.search-results .result-name span.alias {
color: var(--search-results-alias-color);
}
.search-results .result-name span.grey {
color: var(--search-results-grey-color);
}

.popover {
position: absolute;
right: 0;
Expand Down
11 changes: 3 additions & 8 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--sidebar-current-link-background-color: transparent;
--search-result-link-focus-background-color: #3c3c3c;
--search-result-border-color: #aaa3;
--search-color: #fff;
--search-results-alias-color: #c5c5c5;
--search-results-grey-color: #999;
--stab-background-color: #314559;
--stab-code-color: #e6e1cf;
--search-color: #fff;
--code-highlight-kw-color: #ff7733;
--code-highlight-kw-2-color: #ff7733;
--code-highlight-lifetime-color: #ff7733;
Expand Down Expand Up @@ -202,13 +204,6 @@ pre.rust .kw-2, pre.rust .prelude-ty {}
filter: invert(100);
}

.search-results .result-name span.alias {
color: #c5c5c5;
}
.search-results .result-name span.grey {
color: #999;
}

#source-sidebar > .title {
color: #fff;
}
Expand Down
11 changes: 3 additions & 8 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
--sidebar-current-link-background-color: #444;
--search-result-link-focus-background-color: #616161;
--search-result-border-color: #aaa3;
--search-color: #111;
--search-results-alias-color: #fff;
--search-results-grey-color: #ccc;
--stab-background-color: #314559;
--stab-code-color: #e6e1cf;
--search-color: #111;
--code-highlight-kw-color: #ab8ac1;
--code-highlight-kw-2-color: #769acb;
--code-highlight-lifetime-color: #d97f26;
Expand Down Expand Up @@ -103,13 +105,6 @@ details.rustdoc-toggle > summary::before {
color: #888;
}

.search-results .result-name span.alias {
color: #fff;
}
.search-results .result-name span.grey {
color: #ccc;
}

#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
background-color: #444;
Expand Down
11 changes: 3 additions & 8 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
--sidebar-current-link-background-color: #fff;
--search-result-link-focus-background-color: #ccc;
--search-result-border-color: #aaa3;
--search-color: #000;
--search-results-alias-color: #000;
--search-results-grey-color: #999;
--stab-background-color: #fff5d6;
--stab-code-color: #000;
--search-color: #000;
--code-highlight-kw-color: #8959a8;
--code-highlight-kw-2-color: #4271ae;
--code-highlight-lifetime-color: #b76514;
Expand Down Expand Up @@ -96,13 +98,6 @@ body.source .example-wrap pre.rust a {
color: #888;
}

.search-results .result-name span.alias {
color: #000;
}
.search-results .result-name span.grey {
color: #999;
}

#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
background-color: #E0E0E0;
Expand Down
53 changes: 36 additions & 17 deletions src/test/rustdoc-gui/search-result-color.goml
Original file line number Diff line number Diff line change
Expand Up @@ -366,23 +366,42 @@ assert-css: (
{"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"},
)

// Check the alias more specifically in the dark theme.
// Check the alias.
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
// We set the theme so we're sure that the correct values will be used, whatever the computer
// this test is running on.
local-storage: {
"rustdoc-theme": "dark",
"rustdoc-use-system-theme": "false",
}
// If the text isn't displayed, the browser doesn't compute color style correctly...
show-text: true
// We reload the page so the local storage settings are being used.
reload:
write: (".search-input", "thisisanalias")
// To be SURE that the search will be run.
press-key: 'Enter'
// Waiting for the search results to appear...
wait-for: "#titles"
// Checking that the colors for the alias element are the ones expected.
assert-css: (".result-name > .alias", {"color": "rgb(255, 255, 255)"})
assert-css: (".result-name > .alias > .grey", {"color": "rgb(204, 204, 204)"})

define-function: (
"check-alias",
(theme, alias, grey),
[
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
("reload"),
("write", (".search-input", "thisisanalias")),
// To be SURE that the search will be run.
("press-key", 'Enter'),
// Waiting for the search results to appear...
("wait-for", "#titles"),
// Checking that the colors for the alias element are the ones expected.
("assert-css", (".result-name > .alias", {"color": |alias|})),
("assert-css", (".result-name > .alias > .grey", {"color": |grey|})),
// Leave the search results to prevent reloading with an already filled search input.
("press-key", "Escape"),
],
)

call-function: ("check-alias", {
"theme": "ayu",
"alias": "rgb(197, 197, 197)",
"grey": "rgb(153, 153, 153)",
})
call-function: ("check-alias", {
"theme": "dark",
"alias": "rgb(255, 255, 255)",
"grey": "rgb(204, 204, 204)",
})
call-function: ("check-alias", {
"theme": "light",
"alias": "rgb(0, 0, 0)",
"grey": "rgb(153, 153, 153)",
})