Skip to content

Commit 7eed25b

Browse files
authored
Rollup merge of #101348 - GuillaumeGomez:cleanup-css-theme, r=notriddle
Cleanup css theme Follow-up of #100494. The change for the border color of the search input in the dark mode was actually a weird case: the search input border was unique, it didn't share the same variable with other items with borders. This weird case being unique to the dark theme, I removed it, hence the modification in the GUI test. Live demo is [here](https://rustdoc.crud.net/imperio/cleanup-css-theme/std/index.html). cc `@jsha` r? `@notriddle`
2 parents 9ed2deb + 30bdf54 commit 7eed25b

File tree

6 files changed

+49
-93
lines changed

6 files changed

+49
-93
lines changed

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

+26
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,9 @@ so that we can apply CSS-filters to change the arrow color in themes */
987987
width: 100%;
988988
background-color: var(--button-background-color);
989989
}
990+
.search-input:focus {
991+
border-color: var(--search-input-focused-border-color);
992+
}
990993

991994
.search-results {
992995
display: none;
@@ -1167,6 +1170,12 @@ so that we can apply CSS-filters to change the arrow color in themes */
11671170
float: right;
11681171
}
11691172

1173+
.rightside:not(a),
1174+
.out-of-band {
1175+
color: var(--right-side-color);
1176+
}
1177+
1178+
11701179
.impl-items .srclink, .impl .srclink, .methods .srclink {
11711180
/* Override header settings otherwise it's too bold */
11721181
font-weight: normal;
@@ -1205,6 +1214,7 @@ a.test-arrow:hover {
12051214

12061215
.code-attribute {
12071216
font-weight: 300;
1217+
color: var(--code-attribute-color);
12081218
}
12091219

12101220
.item-spacer {
@@ -1478,6 +1488,16 @@ pre.rust {
14781488
background-color: var(--button-background-color);
14791489
}
14801490

1491+
#copy-path {
1492+
color: var(--copy-path-button-color);
1493+
}
1494+
#copy-path > img {
1495+
filter: var(--copy-path-img-filter);
1496+
}
1497+
#copy-path:hover > img {
1498+
filter: var(--copy-path-img-hover-filter);
1499+
}
1500+
14811501
@keyframes rotating {
14821502
from {
14831503
transform: rotate(0deg);
@@ -1601,6 +1621,12 @@ details.rustdoc-toggle > summary::before {
16011621
opacity: .5;
16021622
}
16031623

1624+
details.rustdoc-toggle > summary.hideme > span,
1625+
details.rustdoc-toggle > summary::before,
1626+
.more-examples-toggle summary, .more-examples-toggle .hide-more {
1627+
color: var(--toggles-color);
1628+
}
1629+
16041630
/* Screen readers see the text version at the end the line.
16051631
Visual readers see the icon at the start of the line, but small and transparent. */
16061632
details.rustdoc-toggle > summary::after {

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

+7-28
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ Original by Dempfi (https://github.com/dempfi/ayu)
1616
--headings-border-bottom-color: #5c6773;
1717
--border-color: #5c6773;
1818
--button-background-color: #141920;
19+
--right-side-color: grey;
20+
--code-attribute-color: #999;
21+
--toggles-color: #999;
22+
--search-input-focused-border-color: #5c6773; /* Same as `--border-color`. */
23+
--copy-path-button-color: #fff;
24+
--copy-path-img-filter: invert(70%);
25+
--copy-path-img-hover-filter: invert(100%);
1926
}
2027

2128
.slider {
@@ -158,11 +165,6 @@ body.source .example-wrap pre.rust a {
158165
background: #333;
159166
}
160167

161-
details.rustdoc-toggle > summary.hideme > span,
162-
details.rustdoc-toggle > summary::before {
163-
color: #999;
164-
}
165-
166168
details.rustdoc-toggle > summary::before {
167169
filter: invert(100%);
168170
}
@@ -197,11 +199,6 @@ details.rustdoc-toggle > summary::before {
197199
background: none;
198200
}
199201

200-
.rightside:not(a),
201-
.out-of-band {
202-
color: grey;
203-
}
204-
205202
.result-name .primitive > i, .result-name .keyword > i {
206203
color: #788797;
207204
}
@@ -242,10 +239,6 @@ a.test-arrow:hover {
242239
color: #c5c5c5;
243240
}
244241

245-
.code-attribute {
246-
color: #999;
247-
}
248-
249242
:target {
250243
background: rgba(255, 236, 164, 0.06);
251244
border-right: 3px solid rgba(255, 180, 76, 0.85);
@@ -341,7 +334,6 @@ individually rather than as a group) */
341334
/* FIXME: these rules should be at the bottom of the file but currently must be
342335
above the `@media (max-width: 700px)` rules due to a bug in the css checker */
343336
/* see https://github.com/rust-lang/rust/pull/71237#issuecomment-618170143 */
344-
.search-input:focus {}
345337
.content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive,
346338
.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro {}
347339
.content span.struct,.content a.struct,.block a.current.struct {}
@@ -428,16 +420,6 @@ kbd {
428420
filter: invert(100);
429421
}
430422

431-
#copy-path {
432-
color: #fff;
433-
}
434-
#copy-path > img {
435-
filter: invert(70%);
436-
}
437-
#copy-path:hover > img {
438-
filter: invert(100%);
439-
}
440-
441423
#settings-menu > a:hover, #settings-menu > a:focus,
442424
#help-button > button:hover, #help-button > button:focus {
443425
border-color: #e0e0e0;
@@ -471,9 +453,6 @@ kbd {
471453
border-color: white;
472454
color: white;
473455
}
474-
.more-examples-toggle summary, .more-examples-toggle .hide-more {
475-
color: #999;
476-
}
477456
.scraped-example .example-wrap .rust span.highlight {
478457
background: rgb(91, 59, 1);
479458
}

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

+7-32
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
--headings-border-bottom-color: #d2d2d2;
1212
--border-color: #e0e0e0;
1313
--button-background-color: #f0f0f0;
14+
--right-side-color: grey;
15+
--code-attribute-color: #999;
16+
--toggles-color: #999;
17+
--search-input-focused-border-color: #008dfd;
18+
--copy-path-button-color: #999;
19+
--copy-path-img-filter: invert(50%);
20+
--copy-path-img-hover-filter: invert(65%);
1421
}
1522

1623
.slider {
@@ -129,18 +136,12 @@ body.source .example-wrap pre.rust a {
129136
background: #333;
130137
}
131138

132-
details.rustdoc-toggle > summary.hideme > span,
133-
details.rustdoc-toggle > summary::before {
134-
color: #999;
135-
}
136-
137139
details.rustdoc-toggle > summary::before {
138140
filter: invert(100%);
139141
}
140142

141143
.search-input {
142144
color: #111;
143-
border-color: #f0f0f0;
144145
}
145146

146147
#crate-search-div::after {
@@ -154,22 +155,13 @@ details.rustdoc-toggle > summary::before {
154155
filter: invert(69%) sepia(60%) saturate(6613%) hue-rotate(184deg) brightness(100%) contrast(91%);
155156
}
156157

157-
.search-input:focus {
158-
border-color: #008dfd;
159-
}
160-
161158
.stab { background: #314559; }
162159

163160
.stab.portability > code {
164161
color: #e6e1cf;
165162
background: none;
166163
}
167164

168-
.rightside:not(a),
169-
.out-of-band {
170-
color: grey;
171-
}
172-
173165
.line-numbers :target { background-color: transparent; }
174166

175167
/* Code highlighting */
@@ -197,10 +189,6 @@ a.test-arrow:hover{
197189
background-color: #4e8bca;
198190
}
199191

200-
.code-attribute {
201-
color: #999;
202-
}
203-
204192
:target {
205193
background-color: #494a3d;
206194
border-right: 3px solid #bb7410;
@@ -301,16 +289,6 @@ kbd {
301289
border-color: #ffb900;
302290
}
303291

304-
#copy-path {
305-
color: #999;
306-
}
307-
#copy-path > img {
308-
filter: invert(50%);
309-
}
310-
#copy-path:hover > img {
311-
filter: invert(65%);
312-
}
313-
314292
.search-results .result-name span.alias {
315293
color: #fff;
316294
}
@@ -334,9 +312,6 @@ kbd {
334312
border-color: white;
335313
color: white;
336314
}
337-
.more-examples-toggle summary, .more-examples-toggle .hide-more {
338-
color: #999;
339-
}
340315
.scraped-example .example-wrap .rust span.highlight {
341316
background: rgb(91, 59, 1);
342317
}

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

+7-31
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
--headings-border-bottom-color: #ddd;
1212
--border-color: #e0e0e0;
1313
--button-background-color: #fff;
14+
--right-side-color: grey;
15+
--code-attribute-color: #999;
16+
--toggles-color: #999;
17+
--search-input-focused-border-color: #66afe9;
18+
--copy-path-button-color: #999;
19+
--copy-path-img-filter: invert(50%);
20+
--copy-path-img-hover-filter: invert(35%);
1421
}
1522

1623
.slider {
@@ -125,11 +132,6 @@ body.source .example-wrap pre.rust a {
125132
background: #eee;
126133
}
127134

128-
details.rustdoc-toggle > summary.hideme > span,
129-
details.rustdoc-toggle > summary::before {
130-
color: #999;
131-
}
132-
133135
#crate-search-div::after {
134136
/* match border-color; uses https://codepen.io/sosuke/pen/Pjoqqp */
135137
filter: invert(100%) sepia(0%) saturate(4223%) hue-rotate(289deg) brightness(114%) contrast(76%);
@@ -141,18 +143,9 @@ details.rustdoc-toggle > summary::before {
141143
filter: invert(44%) sepia(18%) saturate(23%) hue-rotate(317deg) brightness(96%) contrast(93%);
142144
}
143145

144-
.search-input:focus {
145-
border-color: #66afe9;
146-
}
147-
148146
.stab { background: #FFF5D6; border-color: #FFC600; }
149147
.stab.portability > code { background: none; }
150148

151-
.rightside:not(a),
152-
.out-of-band {
153-
color: grey;
154-
}
155-
156149
.line-numbers :target { background-color: transparent; }
157150

158151
/* Code highlighting */
@@ -182,10 +175,6 @@ a.test-arrow:hover{
182175
background-color: #4e8bca;
183176
}
184177

185-
.code-attribute {
186-
color: #999;
187-
}
188-
189178
:target {
190179
background: #FDFFD3;
191180
border-right: 3px solid #AD7C37;
@@ -281,16 +270,6 @@ kbd {
281270
border-color: #717171;
282271
}
283272

284-
#copy-path {
285-
color: #999;
286-
}
287-
#copy-path > img {
288-
filter: invert(50%);
289-
}
290-
#copy-path:hover > img {
291-
filter: invert(35%);
292-
}
293-
294273
.search-results .result-name span.alias {
295274
color: #000;
296275
}
@@ -313,9 +292,6 @@ kbd {
313292
border-color: black;
314293
color: black;
315294
}
316-
.more-examples-toggle summary, .more-examples-toggle .hide-more {
317-
color: #999;
318-
}
319295
.scraped-example .example-wrap .rust span.highlight {
320296
background: #fcffd6;
321297
}

src/test/rustdoc-gui/search-form-elements.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ reload:
9292
assert-css: (
9393
".search-input",
9494
{
95-
"border-color": "rgb(240, 240, 240)",
95+
"border-color": "rgb(224, 224, 224)",
9696
"background-color": "rgb(240, 240, 240)",
9797
"color": "rgb(17, 17, 17)",
9898
},

src/test/rustdoc-gui/search-input.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ goto: file://|DOC_PATH|/test_docs/index.html
33
local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"}
44
reload:
55

6-
assert-css: (".search-input", {"border-color": "rgb(240, 240, 240)"})
6+
assert-css: (".search-input", {"border-color": "rgb(224, 224, 224)"})
77
click: ".search-input"
88
assert-css: (".search-input", {"border-color": "rgb(0, 141, 253)"})
99

0 commit comments

Comments
 (0)