Skip to content

Commit 96d0b7f

Browse files
authored
Rollup merge of #104666 - GuillaumeGomez:migrate-alias-search-result, r=notriddle
Migrate alias search result to CSS variables r? `@notriddle`
2 parents 78cbe9c + 90d7beb commit 96d0b7f

File tree

5 files changed

+52
-41
lines changed

5 files changed

+52
-41
lines changed

src/librustdoc/html/static/css/rustdoc.css

+7
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,13 @@ so that we can apply CSS-filters to change the arrow color in themes */
907907
background-color: var(--search-result-link-focus-background-color);
908908
}
909909

910+
.search-results .result-name span.alias {
911+
color: var(--search-results-alias-color);
912+
}
913+
.search-results .result-name span.grey {
914+
color: var(--search-results-grey-color);
915+
}
916+
910917
.popover {
911918
position: absolute;
912919
right: 0;

src/librustdoc/html/static/css/themes/ayu.css

+3-8
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ Original by Dempfi (https://github.com/dempfi/ayu)
4141
--sidebar-current-link-background-color: transparent;
4242
--search-result-link-focus-background-color: #3c3c3c;
4343
--search-result-border-color: #aaa3;
44+
--search-color: #fff;
45+
--search-results-alias-color: #c5c5c5;
46+
--search-results-grey-color: #999;
4447
--stab-background-color: #314559;
4548
--stab-code-color: #e6e1cf;
46-
--search-color: #fff;
4749
--code-highlight-kw-color: #ff7733;
4850
--code-highlight-kw-2-color: #ff7733;
4951
--code-highlight-lifetime-color: #ff7733;
@@ -202,13 +204,6 @@ pre.rust .kw-2, pre.rust .prelude-ty {}
202204
filter: invert(100);
203205
}
204206

205-
.search-results .result-name span.alias {
206-
color: #c5c5c5;
207-
}
208-
.search-results .result-name span.grey {
209-
color: #999;
210-
}
211-
212207
#source-sidebar > .title {
213208
color: #fff;
214209
}

src/librustdoc/html/static/css/themes/dark.css

+3-8
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@
3636
--sidebar-current-link-background-color: #444;
3737
--search-result-link-focus-background-color: #616161;
3838
--search-result-border-color: #aaa3;
39+
--search-color: #111;
40+
--search-results-alias-color: #fff;
41+
--search-results-grey-color: #ccc;
3942
--stab-background-color: #314559;
4043
--stab-code-color: #e6e1cf;
41-
--search-color: #111;
4244
--code-highlight-kw-color: #ab8ac1;
4345
--code-highlight-kw-2-color: #769acb;
4446
--code-highlight-lifetime-color: #d97f26;
@@ -103,13 +105,6 @@ details.rustdoc-toggle > summary::before {
103105
color: #888;
104106
}
105107

106-
.search-results .result-name span.alias {
107-
color: #fff;
108-
}
109-
.search-results .result-name span.grey {
110-
color: #ccc;
111-
}
112-
113108
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
114109
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
115110
background-color: #444;

src/librustdoc/html/static/css/themes/light.css

+3-8
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@
3636
--sidebar-current-link-background-color: #fff;
3737
--search-result-link-focus-background-color: #ccc;
3838
--search-result-border-color: #aaa3;
39+
--search-color: #000;
40+
--search-results-alias-color: #000;
41+
--search-results-grey-color: #999;
3942
--stab-background-color: #fff5d6;
4043
--stab-code-color: #000;
41-
--search-color: #000;
4244
--code-highlight-kw-color: #8959a8;
4345
--code-highlight-kw-2-color: #4271ae;
4446
--code-highlight-lifetime-color: #b76514;
@@ -96,13 +98,6 @@ body.source .example-wrap pre.rust a {
9698
color: #888;
9799
}
98100

99-
.search-results .result-name span.alias {
100-
color: #000;
101-
}
102-
.search-results .result-name span.grey {
103-
color: #999;
104-
}
105-
106101
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
107102
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
108103
background-color: #E0E0E0;

src/test/rustdoc-gui/search-result-color.goml

+36-17
Original file line numberDiff line numberDiff line change
@@ -366,23 +366,42 @@ assert-css: (
366366
{"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"},
367367
)
368368

369-
// Check the alias more specifically in the dark theme.
369+
// Check the alias.
370370
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
371-
// We set the theme so we're sure that the correct values will be used, whatever the computer
372-
// this test is running on.
373-
local-storage: {
374-
"rustdoc-theme": "dark",
375-
"rustdoc-use-system-theme": "false",
376-
}
377371
// If the text isn't displayed, the browser doesn't compute color style correctly...
378372
show-text: true
379-
// We reload the page so the local storage settings are being used.
380-
reload:
381-
write: (".search-input", "thisisanalias")
382-
// To be SURE that the search will be run.
383-
press-key: 'Enter'
384-
// Waiting for the search results to appear...
385-
wait-for: "#titles"
386-
// Checking that the colors for the alias element are the ones expected.
387-
assert-css: (".result-name > .alias", {"color": "rgb(255, 255, 255)"})
388-
assert-css: (".result-name > .alias > .grey", {"color": "rgb(204, 204, 204)"})
373+
374+
define-function: (
375+
"check-alias",
376+
(theme, alias, grey),
377+
[
378+
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
379+
("reload"),
380+
("write", (".search-input", "thisisanalias")),
381+
// To be SURE that the search will be run.
382+
("press-key", 'Enter'),
383+
// Waiting for the search results to appear...
384+
("wait-for", "#titles"),
385+
// Checking that the colors for the alias element are the ones expected.
386+
("assert-css", (".result-name > .alias", {"color": |alias|})),
387+
("assert-css", (".result-name > .alias > .grey", {"color": |grey|})),
388+
// Leave the search results to prevent reloading with an already filled search input.
389+
("press-key", "Escape"),
390+
],
391+
)
392+
393+
call-function: ("check-alias", {
394+
"theme": "ayu",
395+
"alias": "rgb(197, 197, 197)",
396+
"grey": "rgb(153, 153, 153)",
397+
})
398+
call-function: ("check-alias", {
399+
"theme": "dark",
400+
"alias": "rgb(255, 255, 255)",
401+
"grey": "rgb(204, 204, 204)",
402+
})
403+
call-function: ("check-alias", {
404+
"theme": "light",
405+
"alias": "rgb(0, 0, 0)",
406+
"grey": "rgb(153, 153, 153)",
407+
})

0 commit comments

Comments
 (0)