Skip to content

Commit 3cebcba

Browse files
authored
Rollup merge of #100494 - GuillaumeGomez:cleanup-themes, r=jsha
Cleanup rustdoc themes This PR continues our work to simplify the rustdoc themes by relying more on CSS variables. Interestingly enough, this time it allowed me to realize that we were having a lot of different colors for borders even though the difference is unnoticeable. I used this opportunity to unify them. The live demo is [here](https://rustdoc.crud.net/imperio/cleanup-themes/std/index.html). r? `@jsha`
2 parents c4707ff + 09396fc commit 3cebcba

File tree

8 files changed

+275
-245
lines changed

8 files changed

+275
-245
lines changed

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

+20-49
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,13 @@ h2.location a {
693693
flex-grow: 1;
694694
margin: 0px;
695695
padding: 0px;
696+
/* We use overflow-wrap: break-word for Safari, which doesn't recognize
697+
`anywhere`: https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap */
696698
overflow-wrap: break-word;
699+
/* Then override it with `anywhere`, which is required to make non-Safari browsers break
700+
more aggressively when we want them to. */
697701
overflow-wrap: anywhere;
702+
background-color: var(--main-background-color);
698703
}
699704

700705
.in-band > code, .in-band > .code-header {
@@ -731,13 +736,13 @@ pre, .rustdoc.source .example-wrap {
731736

732737
.docblock table td {
733738
padding: .5em;
734-
border: 1px dashed;
739+
border: 1px dashed var(--border-color);
735740
}
736741

737742
.docblock table th {
738743
padding: .5em;
739744
text-align: left;
740-
border: 1px solid;
745+
border: 1px solid var(--border-color);
741746
}
742747

743748
.fields + table {
@@ -835,20 +840,6 @@ nav.sub {
835840
.source nav.sub {
836841
margin-left: 32px;
837842
}
838-
nav.main {
839-
padding: 20px 0;
840-
text-align: center;
841-
}
842-
nav.main .current {
843-
border-top: 1px solid;
844-
border-bottom: 1px solid;
845-
}
846-
nav.main .separator {
847-
border: 1px solid;
848-
display: inline-block;
849-
height: 23px;
850-
margin: 0 20px;
851-
}
852843
nav.sum { text-align: right; }
853844
nav.sub form { display: inline; }
854845

@@ -974,7 +965,7 @@ table,
974965
max-width: 100%;
975966
/* contents can overflow because of max-width limit, then show ellipsis */
976967
text-overflow: ellipsis;
977-
border: 1px solid;
968+
border: 1px solid var(--border-color);
978969
border-radius: 4px;
979970
outline: none;
980971
cursor: pointer;
@@ -1027,11 +1018,12 @@ so that we can apply CSS-filters to change the arrow color in themes */
10271018
-moz-box-sizing: border-box !important;
10281019
box-sizing: border-box !important;
10291020
outline: none;
1030-
border: 1px solid;
1021+
border: 1px solid var(--border-color);
10311022
border-radius: 2px;
10321023
padding: 8px;
10331024
font-size: 1rem;
10341025
width: 100%;
1026+
background-color: var(--button-background-color);
10351027
}
10361028

10371029
.search-results {
@@ -1087,7 +1079,7 @@ so that we can apply CSS-filters to change the arrow color in themes */
10871079
display: block;
10881080
margin-top: 7px;
10891081
border-radius: 3px;
1090-
border: 1px solid;
1082+
border: 1px solid var(--border-color);
10911083
font-size: 1rem;
10921084
}
10931085

@@ -1096,7 +1088,7 @@ so that we can apply CSS-filters to change the arrow color in themes */
10961088
content: '';
10971089
position: absolute;
10981090
right: 11px;
1099-
border: solid;
1091+
border: solid var(--border-color);
11001092
border-width: 1px 1px 0 0;
11011093
display: inline-block;
11021094
padding: 4px;
@@ -1132,13 +1124,13 @@ so that we can apply CSS-filters to change the arrow color in themes */
11321124
text-align: center;
11331125
display: block;
11341126
margin: 10px 0;
1135-
border-bottom: 1px solid;
1127+
border-bottom: 1px solid var(--border-color);
11361128
padding-bottom: 4px;
11371129
margin-bottom: 6px;
11381130
}
11391131
#help-button span.bottom {
11401132
clear: both;
1141-
border-top: 1px solid;
1133+
border-top: 1px solid var(--border-color);
11421134
}
11431135
.side-by-side {
11441136
text-align: initial;
@@ -1331,6 +1323,7 @@ h3.variant {
13311323
border-radius: 6px;
13321324
margin-left: 5px;
13331325
font-size: 1rem;
1326+
border: 1px solid var(--border-color);
13341327
}
13351328

13361329
.tooltip.ignore::after {
@@ -1496,7 +1489,7 @@ pre.rust {
14961489
#source-sidebar > .title {
14971490
font-size: 1.5rem;
14981491
text-align: center;
1499-
border-bottom: 1px solid;
1492+
border-bottom: 1px solid var(--border-color);
15001493
margin-bottom: 6px;
15011494
}
15021495
#sidebar-toggle > button {
@@ -1524,11 +1517,12 @@ pre.rust {
15241517

15251518
#copy-path {
15261519
height: 34px;
1520+
background-color: var(--main-background-color);
15271521
}
15281522
#settings-menu > a, #help-button > button, #copy-path {
15291523
padding: 5px;
15301524
width: 33px;
1531-
border: 1px solid;
1525+
border: 1px solid var(--border-color);
15321526
border-radius: 2px;
15331527
cursor: pointer;
15341528
}
@@ -1539,6 +1533,7 @@ pre.rust {
15391533
padding: 5px;
15401534
height: 100%;
15411535
display: block;
1536+
background-color: var(--button-background-color);
15421537
}
15431538

15441539
@keyframes rotating {
@@ -1588,37 +1583,13 @@ input:checked + .slider {
15881583
border: 0;
15891584
}
15901585

1591-
#theme-choices {
1592-
display: none;
1593-
position: absolute;
1594-
left: 0;
1595-
top: 28px;
1596-
border: 1px solid;
1597-
border-radius: 3px;
1598-
z-index: 1;
1599-
cursor: pointer;
1600-
}
1601-
1602-
#theme-choices > button {
1603-
border: none;
1604-
width: 100%;
1605-
padding: 4px 8px;
1606-
text-align: center;
1607-
background: rgba(0,0,0,0);
1608-
overflow-wrap: normal;
1609-
}
1610-
1611-
#theme-choices > button:not(:first-child) {
1612-
border-top: 1px solid;
1613-
}
1614-
16151586
kbd {
16161587
display: inline-block;
16171588
padding: 3px 5px;
16181589
font: 15px monospace;
16191590
line-height: 10px;
16201591
vertical-align: middle;
1621-
border: solid 1px;
1592+
border: solid 1px var(--border-color);
16221593
border-radius: 3px;
16231594
cursor: default;
16241595
}

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

+3-62
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
1414
--scrollbar-thumb-background-color: #5c6773;
1515
--scrollbar-color: #5c6773 #24292f;
1616
--headings-border-bottom-color: #5c6773;
17+
--border-color: #5c6773;
18+
--button-background-color: #141920;
1719
}
1820

1921
.slider {
@@ -36,10 +38,6 @@ h4 {
3638
border: none;
3739
}
3840

39-
.in-band {
40-
background-color: #0f1419;
41-
}
42-
4341
.docblock code {
4442
color: #ffb454;
4543
}
@@ -84,10 +82,6 @@ pre, .rustdoc.source .example-wrap {
8482
border-right: 1px solid #ffb44c;
8583
}
8684

87-
.docblock table td, .docblock table th {
88-
border-color: #5c6773;
89-
}
90-
9185
.search-results a:hover {
9286
background-color: #777;
9387
}
@@ -151,13 +145,6 @@ pre, .rustdoc.source .example-wrap {
151145
pre.rust .comment { color: #788797; }
152146
pre.rust .doccomment { color: #a1ac88; }
153147

154-
nav.main .current {
155-
border-top-color: #5c6773;
156-
border-bottom-color: #5c6773;
157-
}
158-
nav.main .separator {
159-
border: 1px solid #5c6773;
160-
}
161148
a {
162149
color: #39AFD7;
163150
}
@@ -182,17 +169,6 @@ details.rustdoc-toggle > summary::before {
182169
filter: invert(100%);
183170
}
184171

185-
.search-input {
186-
background-color: #141920;
187-
border-color: #424c57;
188-
}
189-
190-
#crate-search {
191-
/* Without the `!important`, the border-color is ignored for `<select>`...
192-
It cannot be in the group above because `.search-input` has a different border color on
193-
hover. */
194-
border-color: #5c6773 !important;
195-
}
196172
#crate-search-div::after {
197173
/* match border-color; uses https://codepen.io/sosuke/pen/Pjoqqp */
198174
filter: invert(41%) sepia(12%) saturate(487%) hue-rotate(171deg) brightness(94%) contrast(94%);
@@ -205,7 +181,7 @@ details.rustdoc-toggle > summary::before {
205181
}
206182

207183
.search-input {
208-
color: #ffffff;
184+
color: #fff;
209185
}
210186

211187
.module-item .stab,
@@ -333,7 +309,6 @@ pre.ignore:hover, .information:hover + pre.ignore {
333309
.tooltip::after {
334310
background-color: #314559;
335311
color: #c5c5c5;
336-
border: 1px solid #5c6773;
337312
}
338313

339314
.tooltip::before {
@@ -342,11 +317,6 @@ pre.ignore:hover, .information:hover + pre.ignore {
342317

343318
.notable-traits-tooltiptext {
344319
background-color: #314559;
345-
border-color: #5c6773;
346-
}
347-
348-
.notable-traits-tooltiptext .notable {
349-
border-bottom-color: #5c6773;
350320
}
351321

352322
#titles > button.selected {
@@ -449,35 +419,20 @@ a.result-keyword:focus {}
449419
.sidebar a.current.tymethod {}
450420
.sidebar a.current.keyword {}
451421

452-
@media (max-width: 700px) {
453-
.sidebar-elems {
454-
border-right-color: #5c6773;
455-
}
456-
}
457-
458422
kbd {
459423
color: #c5c5c5;
460424
background-color: #314559;
461-
border-color: #5c6773;
462-
border-bottom-color: #5c6773;
463425
box-shadow: inset 0 -1px 0 #5c6773;
464426
}
465427

466428
#settings-menu > a, #help-button > button {
467-
border-color: #5c6773;
468-
background-color: #0f1419;
469429
color: #fff;
470430
}
471431

472432
#settings-menu > a img {
473433
filter: invert(100);
474434
}
475435

476-
.popover, .popover::before,
477-
#help-button span.top, #help-button span.bottom {
478-
border-color: #5c6773;
479-
}
480-
481436
#copy-path {
482437
color: #fff;
483438
}
@@ -493,19 +448,6 @@ kbd {
493448
border-color: #e0e0e0;
494449
}
495450

496-
#theme-choices {
497-
border-color: #5c6773;
498-
background-color: #0f1419;
499-
}
500-
501-
#theme-choices > button:not(:first-child) {
502-
border-top-color: #5c6773;
503-
}
504-
505-
#theme-choices > button:hover, #theme-choices > button:focus {
506-
background-color: rgba(110, 110, 110, 0.33);
507-
}
508-
509451
.search-results .result-name span.alias {
510452
color: #c5c5c5;
511453
}
@@ -515,7 +457,6 @@ kbd {
515457

516458
#source-sidebar > .title {
517459
color: #fff;
518-
border-bottom-color: #5c6773;
519460
}
520461
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
521462
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {

0 commit comments

Comments
 (0)