Skip to content

Commit 4cf26f8

Browse files
committed
Auto merge of #47686 - GuillaumeGomez:theme-fixes, r=QuietMisdreavus
Few fixes for multiple themes support feature r? @QuietMisdreavus Fixes #47695.
2 parents 247835a + e78f139 commit 4cf26f8

File tree

5 files changed

+47
-23
lines changed

5 files changed

+47
-23
lines changed

src/librustdoc/html/layout.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ r##"<!DOCTYPE html>
7474
{sidebar}
7575
</nav>
7676
77-
<button id="theme-picker">
78-
<img src="{root_path}brush.svg" width="18" alt="Pick another theme!">
77+
<div class="theme-picker">
78+
<button id="theme-picker" aria-label="Pick another theme!">
79+
<img src="{root_path}brush.svg" width="18" alt="Pick another theme!">
80+
</button>
7981
<div id="theme-choices"></div>
80-
</button>
82+
</div>
8183
<script src="{root_path}theme.js"></script>
8284
<nav class="sub">
8385
<form class="search-form js-only">

src/librustdoc/html/render.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -918,12 +918,12 @@ themePicker.onclick = function() {{
918918
}}
919919
}};
920920
[{}].forEach(function(item) {{
921-
var div = document.createElement('div');
922-
div.innerHTML = item;
923-
div.onclick = function(el) {{
921+
var but = document.createElement('button');
922+
but.innerHTML = item;
923+
but.onclick = function(el) {{
924924
switchTheme(currentTheme, mainTheme, item);
925925
}};
926-
themes.appendChild(div);
926+
themes.appendChild(but);
927927
}});
928928
"#, themes.iter()
929929
.map(|s| format!("\"{}\"", s))

src/librustdoc/html/static/rustdoc.css

+20-7
Original file line numberDiff line numberDiff line change
@@ -1141,13 +1141,19 @@ kbd {
11411141
border: solid 1px;
11421142
border-radius: 3px;
11431143
box-shadow: inset 0 -1px 0;
1144+
cursor: default;
11441145
}
11451146

1146-
#theme-picker {
1147+
.theme-picker {
11471148
position: absolute;
11481149
left: 211px;
1149-
top: 17px;
1150+
top: 19px;
1151+
}
1152+
1153+
#theme-picker {
11501154
padding: 4px;
1155+
width: 27px;
1156+
height: 29px;
11511157
border: 1px solid;
11521158
border-radius: 3px;
11531159
cursor: pointer;
@@ -1156,21 +1162,28 @@ kbd {
11561162
#theme-choices {
11571163
display: none;
11581164
position: absolute;
1159-
left: -1px;
1160-
top: 30px;
1165+
left: 0;
1166+
top: 28px;
11611167
border: 1px solid;
11621168
border-radius: 3px;
11631169
z-index: 1;
1170+
cursor: pointer;
11641171
}
11651172

1166-
#theme-choices > div {
1167-
border-top: 1px solid;
1173+
#theme-choices > button {
1174+
border: none;
1175+
width: 100%;
11681176
padding: 4px;
11691177
text-align: center;
1178+
background: rgba(0,0,0,0);
1179+
}
1180+
1181+
#theme-choices > button:not(:first-child) {
1182+
border-top: 1px solid;
11701183
}
11711184

11721185
@media (max-width: 700px) {
1173-
#theme-picker {
1186+
.theme-picker {
11741187
left: 109px;
11751188
top: 7px;
11761189
z-index: 1;

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

+9-5
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ a.test-arrow {
197197

198198
#help dt {
199199
border-color: #bfbfbf;
200-
background: #fff;
200+
background: rgba(0,0,0,0);
201201
color: black;
202202
}
203203

@@ -352,7 +352,7 @@ pre.ignore:hover, .information:hover + pre.ignore {
352352
}
353353

354354
kbd {
355-
color: #444d56;
355+
color: #000;
356356
background-color: #fafbfc;
357357
border-color: #d1d5da;
358358
border-bottom-color: #c6cbd1;
@@ -364,16 +364,20 @@ kbd {
364364
background: #f0f0f0;
365365
}
366366

367+
#theme-picker:hover, #theme-picker:focus {
368+
border-color: #ffb900;
369+
}
370+
367371
#theme-choices {
368372
border-color: #e0e0e0;
369373
background-color: #353535;
370374
}
371375

372-
#theme-choices > div {
373-
border-top: #e0e0e0;
376+
#theme-choices > button:not(:first-child) {
377+
border-top-color: #e0e0e0;
374378
}
375379

376-
#theme-choices > div:hover {
380+
#theme-choices > button:hover, #theme-choices > button:focus {
377381
background-color: #444;
378382
}
379383

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

+9-4
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ pre.ignore:hover, .information:hover + pre.ignore {
345345
}
346346

347347
kbd {
348-
color: #444d56;
348+
color: #000;
349349
background-color: #fafbfc;
350350
border-color: #d1d5da;
351351
border-bottom-color: #c6cbd1;
@@ -354,18 +354,23 @@ kbd {
354354

355355
#theme-picker {
356356
border-color: #e0e0e0;
357+
background-color: #fff;
358+
}
359+
360+
#theme-picker:hover, #theme-picker:focus {
361+
border-color: #717171;
357362
}
358363

359364
#theme-choices {
360365
border-color: #ccc;
361366
background-color: #fff;
362367
}
363368

364-
#theme-choices > div {
365-
border-top: #e0e0e0;
369+
#theme-choices > button:not(:first-child) {
370+
border-top-color: #e0e0e0;
366371
}
367372

368-
#theme-choices > div:hover {
373+
#theme-choices > button:hover, #theme-choices > button:focus {
369374
background-color: #eee;
370375
}
371376

0 commit comments

Comments
 (0)