Skip to content

Commit e876275

Browse files
Remove theme picker button
1 parent 5e01ba3 commit e876275

File tree

10 files changed

+12
-199
lines changed

10 files changed

+12
-199
lines changed

src/librustdoc/html/markdown.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,6 @@ fn init_id_map() -> FxHashMap<Cow<'static, str>, usize> {
14481448
// used in tera template files).
14491449
map.insert("mainThemeStyle".into(), 1);
14501450
map.insert("themeStyle".into(), 1);
1451-
map.insert("theme-picker".into(), 1);
1452-
map.insert("theme-choices".into(), 1);
14531451
map.insert("settings-menu".into(), 1);
14541452
map.insert("help-button".into(), 1);
14551453
map.insert("main-content".into(), 1);

src/librustdoc/html/render/write_shared.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ pub(super) fn write_shared(
238238
write_toolchain("favicon-16x16.png", static_files::RUST_FAVICON_PNG_16)?;
239239
write_toolchain("favicon-32x32.png", static_files::RUST_FAVICON_PNG_32)?;
240240
}
241-
write_toolchain("brush.svg", static_files::BRUSH_SVG)?;
242241
write_toolchain("wheel.svg", static_files::WHEEL_SVG)?;
243242
write_toolchain("clipboard.svg", static_files::CLIPBOARD_SVG)?;
244243
write_toolchain("down-arrow.svg", static_files::DOWN_ARROW_SVG)?;

src/librustdoc/html/static/css/noscript.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,3 @@ rules.
1818
/* The search bar and related controls don't work without JS */
1919
display: none;
2020
}
21-
22-
#theme-picker {
23-
display: none;
24-
}

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

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,25 +1379,15 @@ pre.rust {
13791379
margin-bottom: 6px;
13801380
}
13811381

1382-
.theme-picker {
1383-
position: absolute;
1384-
left: -38px;
1385-
top: 4px;
1386-
}
1387-
1388-
.theme-picker button {
1389-
outline: none;
1390-
}
1391-
13921382
#settings-menu, #help-button {
13931383
margin-left: 4px;
13941384
outline: none;
13951385
}
13961386

1397-
#theme-picker, #copy-path {
1387+
#copy-path {
13981388
height: 34px;
13991389
}
1400-
#theme-picker, #settings-menu, #help-button, #copy-path {
1390+
#settings-menu > a, #help-button, #copy-path {
14011391
padding: 5px;
14021392
width: 33px;
14031393
border: 1px solid;
@@ -1422,7 +1412,7 @@ pre.rust {
14221412
transform: rotate(360deg);
14231413
}
14241414
}
1425-
#settings-menu.rotate img {
1415+
#settings-menu.rotate > a img {
14261416
animation: rotating 2s linear infinite;
14271417
}
14281418
#settings-menu #settings {
@@ -1871,12 +1861,6 @@ details.rustdoc-toggle[open] > summary.hideme::after {
18711861
margin-left: 32px;
18721862
}
18731863

1874-
/* Space is at a premium on mobile, so remove the theme-picker icon. */
1875-
#theme-picker {
1876-
display: none;
1877-
width: 0;
1878-
}
1879-
18801864
.content {
18811865
margin-left: 0px;
18821866
}

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -531,13 +531,13 @@ kbd {
531531
box-shadow: inset 0 -1px 0 #5c6773;
532532
}
533533

534-
#theme-picker, #settings-menu, #help-button {
534+
#settings-menu > a, #help-button {
535535
border-color: #5c6773;
536536
background-color: #0f1419;
537537
color: #fff;
538538
}
539539

540-
#theme-picker > img, #settings-menu > img {
540+
#settings-menu > a img {
541541
filter: invert(100);
542542
}
543543

@@ -555,8 +555,7 @@ kbd {
555555
filter: invert(100%);
556556
}
557557

558-
#theme-picker:hover, #theme-picker:focus,
559-
#settings-menu:hover, #settings-menu:focus,
558+
#settings-menu > a:hover, #settings-menu > a:focus,
560559
#help-button:hover, #help-button:focus {
561560
border-color: #e0e0e0;
562561
}
@@ -574,12 +573,6 @@ kbd {
574573
background-color: rgba(110, 110, 110, 0.33);
575574
}
576575

577-
@media (max-width: 700px) {
578-
#theme-picker {
579-
background: #0f1419;
580-
}
581-
}
582-
583576
.search-results .result-name span.alias {
584577
color: #c5c5c5;
585578
}

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,13 @@ kbd {
408408
box-shadow: inset 0 -1px 0 #c6cbd1;
409409
}
410410

411-
#theme-picker, #settings-menu, #help-button {
411+
#settings-menu > a, #help-button {
412412
border-color: #e0e0e0;
413413
background: #f0f0f0;
414414
color: #000;
415415
}
416416

417-
#theme-picker:hover, #theme-picker:focus,
418-
#settings-menu:hover, #settings-menu:focus,
417+
#settings-menu > a:hover, #settings-menu > a:focus,
419418
#help-button:hover, #help-button:focus {
420419
border-color: #ffb900;
421420
}
@@ -447,12 +446,6 @@ kbd {
447446
background-color: #4e4e4e;
448447
}
449448

450-
@media (max-width: 700px) {
451-
#theme-picker {
452-
background: #f0f0f0;
453-
}
454-
}
455-
456449
.search-results .result-name span.alias {
457450
color: #fff;
458451
}

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,12 @@ kbd {
394394
box-shadow: inset 0 -1px 0 #c6cbd1;
395395
}
396396

397-
#theme-picker, #settings-menu, #help-button {
397+
#settings-menu > a, #help-button {
398398
border-color: #e0e0e0;
399399
background-color: #fff;
400400
}
401401

402-
#theme-picker:hover, #theme-picker:focus,
403-
#settings-menu:hover, #settings-menu:focus,
402+
#settings-menu > a:hover, #settings-menu > a:focus,
404403
#help-button:hover, #help-button:focus {
405404
border-color: #717171;
406405
}
@@ -432,12 +431,6 @@ kbd {
432431
background-color: #eee;
433432
}
434433

435-
@media (max-width: 700px) {
436-
#theme-picker {
437-
background: #fff;
438-
}
439-
}
440-
441434
.search-results .result-name span.alias {
442435
color: #000;
443436
}

src/librustdoc/html/static/js/main.js

Lines changed: 2 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Local js definitions:
22
/* global addClass, getSettingValue, hasClass, searchState */
33
/* global onEach, onEachLazy, removeClass */
4-
/* global switchTheme, useSystemTheme */
54

65
"use strict";
76

@@ -109,21 +108,11 @@ function getVirtualKey(ev) {
109108
return String.fromCharCode(c);
110109
}
111110

112-
const THEME_PICKER_ELEMENT_ID = "theme-picker";
113-
const THEMES_ELEMENT_ID = "theme-choices";
114111
const MAIN_ID = "main-content";
115112
const SETTINGS_BUTTON_ID = "settings-menu";
116113
const ALTERNATIVE_DISPLAY_ID = "alternative-display";
117114
const NOT_DISPLAYED_ID = "not-displayed";
118115

119-
function getThemesElement() {
120-
return document.getElementById(THEMES_ELEMENT_ID);
121-
}
122-
123-
function getThemePickerElement() {
124-
return document.getElementById(THEME_PICKER_ELEMENT_ID);
125-
}
126-
127116
function getSettingsButton() {
128117
return document.getElementById(SETTINGS_BUTTON_ID);
129118
}
@@ -133,74 +122,10 @@ function getNakedUrl() {
133122
return window.location.href.split("?")[0].split("#")[0];
134123
}
135124

136-
function showThemeButtonState() {
137-
const themePicker = getThemePickerElement();
138-
const themeChoices = getThemesElement();
139-
140-
themeChoices.style.display = "block";
141-
themePicker.style.borderBottomRightRadius = "0";
142-
themePicker.style.borderBottomLeftRadius = "0";
143-
}
144-
145-
function hideThemeButtonState() {
146-
const themePicker = getThemePickerElement();
147-
const themeChoices = getThemesElement();
148-
149-
themeChoices.style.display = "none";
150-
themePicker.style.borderBottomRightRadius = "3px";
151-
themePicker.style.borderBottomLeftRadius = "3px";
152-
}
153-
154125
window.hideSettings = () => {
155126
// Does nothing by default.
156127
};
157128

158-
// Set up the theme picker list.
159-
(function () {
160-
if (!document.location.href.startsWith("file:///")) {
161-
return;
162-
}
163-
const themeChoices = getThemesElement();
164-
const themePicker = getThemePickerElement();
165-
const availableThemes = getVar("themes").split(",");
166-
167-
removeClass(themeChoices.parentElement, "hidden");
168-
169-
function switchThemeButtonState() {
170-
if (themeChoices.style.display === "block") {
171-
hideThemeButtonState();
172-
} else {
173-
showThemeButtonState();
174-
}
175-
}
176-
177-
function handleThemeButtonsBlur(e) {
178-
const active = document.activeElement;
179-
const related = e.relatedTarget;
180-
181-
if (active.id !== THEME_PICKER_ELEMENT_ID &&
182-
(!active.parentNode || active.parentNode.id !== THEMES_ELEMENT_ID) &&
183-
(!related ||
184-
(related.id !== THEME_PICKER_ELEMENT_ID &&
185-
(!related.parentNode || related.parentNode.id !== THEMES_ELEMENT_ID)))) {
186-
hideThemeButtonState();
187-
}
188-
}
189-
190-
themePicker.onclick = switchThemeButtonState;
191-
themePicker.onblur = handleThemeButtonsBlur;
192-
availableThemes.forEach(item => {
193-
const but = document.createElement("button");
194-
but.textContent = item;
195-
but.onclick = () => {
196-
switchTheme(window.currentTheme, window.mainTheme, item, true);
197-
useSystemTheme(false);
198-
};
199-
but.onblur = handleThemeButtonsBlur;
200-
themeChoices.appendChild(but);
201-
});
202-
}());
203-
204129
/**
205130
* This function inserts `newNode` after `referenceNode`. It doesn't work if `referenceNode`
206131
* doesn't have a parent node.
@@ -512,7 +437,7 @@ function loadCss(cssFileName) {
512437
ev.preventDefault();
513438
}
514439
searchState.defocus();
515-
hideThemeButtonState();
440+
window.hideSettings();
516441
}
517442

518443
const disableShortcuts = getSettingValue("disable-shortcuts") === "true";
@@ -522,8 +447,6 @@ function loadCss(cssFileName) {
522447
return;
523448
}
524449

525-
let themePicker;
526-
527450
if (document.activeElement.tagName === "INPUT") {
528451
switch (getVirtualKey(ev)) {
529452
case "Escape":
@@ -553,64 +476,9 @@ function loadCss(cssFileName) {
553476
displayHelp(true, ev);
554477
break;
555478

556-
case "t":
557-
case "T":
558-
displayHelp(false, ev);
559-
ev.preventDefault();
560-
themePicker = getThemePickerElement();
561-
themePicker.click();
562-
themePicker.focus();
563-
break;
564-
565479
default:
566-
if (getThemePickerElement().parentNode.contains(ev.target)) {
567-
handleThemeKeyDown(ev);
568-
}
569-
}
570-
}
571-
}
572-
573-
function handleThemeKeyDown(ev) {
574-
const active = document.activeElement;
575-
const themes = getThemesElement();
576-
switch (getVirtualKey(ev)) {
577-
case "ArrowUp":
578-
ev.preventDefault();
579-
if (active.previousElementSibling && ev.target.id !== THEME_PICKER_ELEMENT_ID) {
580-
active.previousElementSibling.focus();
581-
} else {
582-
showThemeButtonState();
583-
themes.lastElementChild.focus();
584-
}
585-
break;
586-
case "ArrowDown":
587-
ev.preventDefault();
588-
if (active.nextElementSibling && ev.target.id !== THEME_PICKER_ELEMENT_ID) {
589-
active.nextElementSibling.focus();
590-
} else {
591-
showThemeButtonState();
592-
themes.firstElementChild.focus();
593-
}
594-
break;
595-
case "Enter":
596-
case "Return":
597-
case "Space":
598-
if (ev.target.id === THEME_PICKER_ELEMENT_ID && themes.style.display === "none") {
599-
ev.preventDefault();
600-
showThemeButtonState();
601-
themes.firstElementChild.focus();
480+
break;
602481
}
603-
break;
604-
case "Home":
605-
ev.preventDefault();
606-
themes.firstElementChild.focus();
607-
break;
608-
case "End":
609-
ev.preventDefault();
610-
themes.lastElementChild.focus();
611-
break;
612-
// The escape key is handled in handleEscape, not here,
613-
// so that pressing escape will close the menu even if it isn't focused
614482
}
615483
}
616484

@@ -1006,7 +874,6 @@ function loadCss(cssFileName) {
1006874
const shortcuts = [
1007875
["?", "Show this help dialog"],
1008876
["S", "Focus the search field"],
1009-
["T", "Focus the theme picker menu"],
1010877
["↑", "Move up in search results"],
1011878
["↓", "Move down in search results"],
1012879
["← / →", "Switch result tab (when results focused)"],

src/librustdoc/html/static_files.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ crate static SCRAPE_EXAMPLES_JS: &str = include_str!("static/js/scrape-examples.
4141

4242
crate static SCRAPE_EXAMPLES_HELP_MD: &str = include_str!("static/scrape-examples-help.md");
4343

44-
/// The file contents of `brush.svg`, the icon used for the theme-switch button.
45-
crate static BRUSH_SVG: &[u8] = include_bytes!("static/images/brush.svg");
46-
4744
/// The file contents of `wheel.svg`, the icon used for the settings button.
4845
crate static WHEEL_SVG: &[u8] = include_bytes!("static/images/wheel.svg");
4946

src/librustdoc/html/templates/page.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,6 @@ <h2 class="location"></h2>
108108
{%- endif -%}
109109
</a> {#- -#}
110110
<nav class="sub"> {#- -#}
111-
<div class="theme-picker hidden"> {#- -#}
112-
<button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"> {#- -#}
113-
<img width="22" height="22" alt="Pick another theme!" {# -#}
114-
src="{{static_root_path|safe}}brush{{page.resource_suffix}}.svg"> {#- -#}
115-
</button> {#- -#}
116-
<div id="theme-choices" role="menu"></div> {#- -#}
117-
</div> {#- -#}
118111
<form class="search-form"> {#- -#}
119112
<div class="search-container"> {#- -#}
120113
<span></span> {#- This empty span is a hacky fix for Safari - See #93184 -#}

0 commit comments

Comments
 (0)