Skip to content

Commit 8f9bc6d

Browse files
Migrate crate-search element to CSS variables
1 parent 0aaad9e commit 8f9bc6d

File tree

4 files changed

+27
-34
lines changed

4 files changed

+27
-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-927217e04c7463ac.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;

0 commit comments

Comments
 (0)