Skip to content

Commit 69d3966

Browse files
authored
Rollup merge of rust-lang#104115 - GuillaumeGomez:migrate-crate-search-div, r=notriddle
Migrate crate-search element to CSS variables There should no UI changes. r? `@notriddle`
2 parents dbfb971 + 47a7170 commit 69d3966

File tree

5 files changed

+67
-34
lines changed

5 files changed

+67
-34
lines changed

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,9 @@ table,
830830
line-height: 1.5;
831831
font-weight: 500;
832832
}
833+
#crate-search:hover, #crate-search:focus {
834+
border-color: var(--crate-search-hover-border);
835+
}
833836
/* cancel stylistic differences in padding in firefox
834837
for "appearance: none"-style (or equivalent) <select>s */
835838
@-moz-document url-prefix() {
@@ -853,8 +856,13 @@ so that we can apply CSS-filters to change the arrow color in themes */
853856
background-repeat: no-repeat;
854857
background-size: 20px;
855858
background-position: calc(100% - 2px) 56%;
856-
/* image is black color, themes should apply a "filter" property to change the color */
859+
/* image is black color */
857860
background-image: url("down-arrow-2d685a4bae708e15.svg");
861+
/* changes the arrow image color */
862+
filter: var(--crate-search-div-filter);
863+
}
864+
#crate-search-div:hover::after, #crate-search-div:focus-within::after {
865+
filter: var(--crate-search-div-hover-filter);
858866
}
859867
#crate-search > option {
860868
font-size: 1rem;

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

+6-11
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ Original by Dempfi (https://github.com/dempfi/ayu)
6767
drop-shadow(0 1px 0 #fff)
6868
drop-shadow(-1px 0 0 #fff)
6969
drop-shadow(0 -1px 0 #fff);
70+
/* match border-color; uses https://codepen.io/sosuke/pen/Pjoqqp */
71+
--crate-search-div-filter: invert(41%) sepia(12%) saturate(487%) hue-rotate(171deg)
72+
brightness(94%) contrast(94%);
73+
--crate-search-div-hover-filter: invert(98%) sepia(12%) saturate(81%) hue-rotate(343deg)
74+
brightness(113%) contrast(76%);
75+
--crate-search-hover-border: #e0e0e0;
7076
}
7177

7278
.slider {
@@ -153,17 +159,6 @@ details.rustdoc-toggle > summary::before {
153159
filter: invert(100%);
154160
}
155161

156-
#crate-search-div::after {
157-
/* match border-color; uses https://codepen.io/sosuke/pen/Pjoqqp */
158-
filter: invert(41%) sepia(12%) saturate(487%) hue-rotate(171deg) brightness(94%) contrast(94%);
159-
}
160-
#crate-search:hover, #crate-search:focus {
161-
border-color: #e0e0e0 !important;
162-
}
163-
#crate-search-div:hover::after, #crate-search-div:focus-within::after {
164-
filter: invert(98%) sepia(12%) saturate(81%) hue-rotate(343deg) brightness(113%) contrast(76%);
165-
}
166-
167162
.module-item .stab,
168163
.import-item .stab {
169164
color: #000;

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

+6-11
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
drop-shadow(0 1px 0 #fff)
6363
drop-shadow(-1px 0 0 #fff)
6464
drop-shadow(0 -1px 0 #fff);
65+
/* match border-color; uses https://codepen.io/sosuke/pen/Pjoqqp */
66+
--crate-search-div-filter: invert(94%) sepia(0%) saturate(721%) hue-rotate(255deg)
67+
brightness(90%) contrast(90%);
68+
--crate-search-div-hover-filter: invert(69%) sepia(60%) saturate(6613%) hue-rotate(184deg)
69+
brightness(100%) contrast(91%);
70+
--crate-search-hover-border: #2196f3;
6571
}
6672

6773
.slider {
@@ -84,17 +90,6 @@ details.rustdoc-toggle > summary::before {
8490
filter: invert(100%);
8591
}
8692

87-
#crate-search-div::after {
88-
/* match border-color; uses https://codepen.io/sosuke/pen/Pjoqqp */
89-
filter: invert(94%) sepia(0%) saturate(721%) hue-rotate(255deg) brightness(90%) contrast(90%);
90-
}
91-
#crate-search:hover, #crate-search:focus {
92-
border-color: #2196f3 !important;
93-
}
94-
#crate-search-div:hover::after, #crate-search-div:focus-within::after {
95-
filter: invert(69%) sepia(60%) saturate(6613%) hue-rotate(184deg) brightness(100%) contrast(91%);
96-
}
97-
9893
:target {
9994
background-color: #494a3d;
10095
border-right: 3px solid #bb7410;

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

+6-11
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@
5959
--test-arrow-hover-color: #f5f5f5;
6060
--test-arrow-hover-background-color: #4e8bca;
6161
--rust-logo-filter: initial;
62+
/* match border-color; uses https://codepen.io/sosuke/pen/Pjoqqp */
63+
--crate-search-div-filter: invert(100%) sepia(0%) saturate(4223%) hue-rotate(289deg)
64+
brightness(114%) contrast(76%);
65+
--crate-search-div-hover-filter: invert(44%) sepia(18%) saturate(23%) hue-rotate(317deg)
66+
brightness(96%) contrast(93%);
67+
--crate-search-hover-border: #717171;
6268
}
6369

6470
.slider {
@@ -77,17 +83,6 @@ body.source .example-wrap pre.rust a {
7783
background: #eee;
7884
}
7985

80-
#crate-search-div::after {
81-
/* match border-color; uses https://codepen.io/sosuke/pen/Pjoqqp */
82-
filter: invert(100%) sepia(0%) saturate(4223%) hue-rotate(289deg) brightness(114%) contrast(76%);
83-
}
84-
#crate-search:hover, #crate-search:focus {
85-
border-color: #717171 !important;
86-
}
87-
#crate-search-div:hover::after, #crate-search-div:focus-within::after {
88-
filter: invert(44%) sepia(18%) saturate(23%) hue-rotate(317deg) brightness(96%) contrast(93%);
89-
}
90-
9186
:target {
9287
background: #FDFFD3;
9388
border-right: 3px solid #AD7C37;

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

+40
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,43 @@ assert-css: ("#crate-search", {"width": "527px"})
3535
assert-css: (".search-results-title", {"height": "44px", "width": "640px"})
3636
// And we check that the `<select>` isn't bigger than its container (".search-results-title").
3737
assert-css: ("#search", {"width": "640px"})
38+
39+
// Now checking that the crate filter is working as expected too.
40+
show-text: true
41+
define-function: (
42+
"check-filter",
43+
(theme, border, filter, hover_border, hover_filter),
44+
[
45+
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
46+
("reload"),
47+
("wait-for", "#crate-search"),
48+
("assert-css", ("#crate-search", {"border": "1px solid " + |border|})),
49+
("assert-css", ("#crate-search-div::after", {"filter": |filter|})),
50+
("move-cursor-to", "#crate-search"),
51+
("assert-css", ("#crate-search", {"border": "1px solid " + |hover_border|})),
52+
("assert-css", ("#crate-search-div::after", {"filter": |hover_filter|})),
53+
("move-cursor-to", ".search-input"),
54+
],
55+
)
56+
57+
call-function: ("check-filter", {
58+
"theme": "ayu",
59+
"border": "rgb(92, 103, 115)",
60+
"filter": "invert(0.41) sepia(0.12) saturate(4.87) hue-rotate(171deg) brightness(0.94) contrast(0.94)",
61+
"hover_border": "rgb(224, 224, 224)",
62+
"hover_filter": "invert(0.98) sepia(0.12) saturate(0.81) hue-rotate(343deg) brightness(1.13) contrast(0.76)",
63+
})
64+
call-function: ("check-filter", {
65+
"theme": "dark",
66+
"border": "rgb(224, 224, 224)",
67+
"filter": "invert(0.94) sepia(0) saturate(7.21) hue-rotate(255deg) brightness(0.9) contrast(0.9)",
68+
"hover_border": "rgb(33, 150, 243)",
69+
"hover_filter": "invert(0.69) sepia(0.6) saturate(66.13) hue-rotate(184deg) brightness(1) contrast(0.91)",
70+
})
71+
call-function: ("check-filter", {
72+
"theme": "light",
73+
"border": "rgb(224, 224, 224)",
74+
"filter": "invert(1) sepia(0) saturate(42.23) hue-rotate(289deg) brightness(1.14) contrast(0.76)",
75+
"hover_border": "rgb(113, 113, 113)",
76+
"hover_filter": "invert(0.44) sepia(0.18) saturate(0.23) hue-rotate(317deg) brightness(0.96) contrast(0.93)",
77+
})

0 commit comments

Comments
 (0)