Skip to content

Commit 2d968a1

Browse files
Simplify rustdoc themes by relying more on CSS variables
1 parent 9c20b2a commit 2d968a1

File tree

4 files changed

+30
-228
lines changed

4 files changed

+30
-228
lines changed

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

Lines changed: 23 additions & 38 deletions
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 {
@@ -840,11 +845,11 @@ nav.main {
840845
text-align: center;
841846
}
842847
nav.main .current {
843-
border-top: 1px solid;
844-
border-bottom: 1px solid;
848+
border-top: 1px solid var(--border-color);
849+
border-bottom: 1px solid var(--border-color);
845850
}
846851
nav.main .separator {
847-
border: 1px solid;
852+
border: 1px solid var(--border-color);
848853
display: inline-block;
849854
height: 23px;
850855
margin: 0 20px;
@@ -974,7 +979,7 @@ table,
974979
max-width: 100%;
975980
/* contents can overflow because of max-width limit, then show ellipsis */
976981
text-overflow: ellipsis;
977-
border: 1px solid;
982+
border: 1px solid var(--border-color);
978983
border-radius: 4px;
979984
outline: none;
980985
cursor: pointer;
@@ -1027,11 +1032,12 @@ so that we can apply CSS-filters to change the arrow color in themes */
10271032
-moz-box-sizing: border-box !important;
10281033
box-sizing: border-box !important;
10291034
outline: none;
1030-
border: 1px solid;
1035+
border: 1px solid var(--border-color);
10311036
border-radius: 2px;
10321037
padding: 8px;
10331038
font-size: 1rem;
10341039
width: 100%;
1040+
background-color: var(--button-background-color);
10351041
}
10361042

10371043
.search-results {
@@ -1087,7 +1093,7 @@ so that we can apply CSS-filters to change the arrow color in themes */
10871093
display: block;
10881094
margin-top: 7px;
10891095
border-radius: 3px;
1090-
border: 1px solid;
1096+
border: 1px solid var(--border-color);
10911097
font-size: 1rem;
10921098
}
10931099

@@ -1096,7 +1102,7 @@ so that we can apply CSS-filters to change the arrow color in themes */
10961102
content: '';
10971103
position: absolute;
10981104
right: 11px;
1099-
border: solid;
1105+
border: solid var(--border-color);
11001106
border-width: 1px 1px 0 0;
11011107
display: inline-block;
11021108
padding: 4px;
@@ -1132,13 +1138,13 @@ so that we can apply CSS-filters to change the arrow color in themes */
11321138
text-align: center;
11331139
display: block;
11341140
margin: 10px 0;
1135-
border-bottom: 1px solid;
1141+
border-bottom: 1px solid var(--border-color);
11361142
padding-bottom: 4px;
11371143
margin-bottom: 6px;
11381144
}
11391145
#help-button span.bottom {
11401146
clear: both;
1141-
border-top: 1px solid;
1147+
border-top: 1px solid var(--border-color);
11421148
}
11431149
.side-by-side {
11441150
text-align: initial;
@@ -1331,6 +1337,7 @@ h3.variant {
13311337
border-radius: 6px;
13321338
margin-left: 5px;
13331339
font-size: 1rem;
1340+
border: 1px solid var(--border-color);
13341341
}
13351342

13361343
.tooltip.ignore::after {
@@ -1496,7 +1503,7 @@ pre.rust {
14961503
#source-sidebar > .title {
14971504
font-size: 1.5rem;
14981505
text-align: center;
1499-
border-bottom: 1px solid;
1506+
border-bottom: 1px solid var(--border-color);
15001507
margin-bottom: 6px;
15011508
}
15021509
#sidebar-toggle > button {
@@ -1524,11 +1531,12 @@ pre.rust {
15241531

15251532
#copy-path {
15261533
height: 34px;
1534+
background-color: var(--main-background-color);
15271535
}
15281536
#settings-menu > a, #help-button > button, #copy-path {
15291537
padding: 5px;
15301538
width: 33px;
1531-
border: 1px solid;
1539+
border: 1px solid var(--border-color);
15321540
border-radius: 2px;
15331541
cursor: pointer;
15341542
}
@@ -1539,6 +1547,7 @@ pre.rust {
15391547
padding: 5px;
15401548
height: 100%;
15411549
display: block;
1550+
background-color: var(--button-background-color);
15421551
}
15431552

15441553
@keyframes rotating {
@@ -1588,37 +1597,13 @@ input:checked + .slider {
15881597
border: 0;
15891598
}
15901599

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-
16151600
kbd {
16161601
display: inline-block;
16171602
padding: 3px 5px;
16181603
font: 15px monospace;
16191604
line-height: 10px;
16201605
vertical-align: middle;
1621-
border: solid 1px;
1606+
border: solid 1px var(--border-color);
16221607
border-radius: 3px;
16231608
cursor: default;
16241609
}

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

Lines changed: 3 additions & 62 deletions
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)