Skip to content

Commit 43b9268

Browse files
committed
Rustdoc style cleanups
- Make "since" version numbers grey again (regressed in rust-lang#92602). - Remove unneeded selectors for when crate filter dropdown is a sibling of search-input. - Crate filter dropdown doesn't need to be 100% width on mobile. - Only build crate filter dropdown when there is more than one crate. - Remove unused addCrateDropdown.
1 parent ee5d8d3 commit 43b9268

File tree

6 files changed

+21
-46
lines changed

6 files changed

+21
-46
lines changed

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -934,11 +934,6 @@ h2.small-section-header > .anchor {
934934
width: 100%;
935935
}
936936

937-
#crate-search + .search-input {
938-
border-radius: 0 1px 1px 0;
939-
width: calc(100% - 32px);
940-
}
941-
942937
.search-input:focus {
943938
border-radius: 2px;
944939
border: 0;
@@ -2070,16 +2065,10 @@ details.rustdoc-toggle[open] > summary.hideme::after {
20702065
}
20712066

20722067
#crate-search {
2073-
width: 100%;
20742068
border-radius: 4px;
20752069
border: 0;
20762070
}
20772071

2078-
#crate-search + .search-input {
2079-
width: calc(100% + 71px);
2080-
margin-left: -36px;
2081-
}
2082-
20832072
#theme-picker, #settings-menu {
20842073
padding: 5px;
20852074
width: 31px;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ details.undocumented > summary::before {
299299
border-color: #5c6773;
300300
}
301301

302-
.since {
302+
.rightside,
303+
.out-of-band {
303304
color: grey;
304305
}
305306

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ details.undocumented > summary::before {
256256
background: rgba(0,0,0,0);
257257
}
258258

259-
.since {
259+
.rightside,
260+
.out-of-band {
260261
color: grey;
261262
}
262263

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ details.undocumented > summary::before {
243243
border-color: #bfbfbf;
244244
}
245245

246+
.rightside,
247+
.out-of-band {
248+
color: grey;
249+
}
250+
246251
.result-name .primitive > i, .result-name .keyword > i {
247252
color: black;
248253
}

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,6 @@ function hideThemeButtonState() {
283283
loadSearch();
284284
}
285285

286-
// `crates{version}.js` should always be loaded before this script, so we can use it
287-
// safely.
288-
searchState.addCrateDropdown(window.ALL_CRATES);
289286
var params = searchState.getQueryStringParams();
290287
if (params.search !== undefined) {
291288
var search = searchState.outputElement();
@@ -295,30 +292,6 @@ function hideThemeButtonState() {
295292
loadSearch();
296293
}
297294
},
298-
addCrateDropdown: function(crates) {
299-
var elem = document.getElementById("crate-search");
300-
301-
if (!elem) {
302-
return;
303-
}
304-
var savedCrate = getSettingValue("saved-filter-crate");
305-
for (var i = 0, len = crates.length; i < len; ++i) {
306-
var option = document.createElement("option");
307-
option.value = crates[i];
308-
option.innerText = crates[i];
309-
elem.appendChild(option);
310-
// Set the crate filter from saved storage, if the current page has the saved crate
311-
// filter.
312-
//
313-
// If not, ignore the crate filter -- we want to support filtering for crates on
314-
// sites like doc.rust-lang.org where the crates may differ from page to page while
315-
// on the
316-
// same domain.
317-
if (crates[i] === savedCrate) {
318-
elem.value = savedCrate;
319-
}
320-
}
321-
},
322295
};
323296

324297
function getPageId() {

src/librustdoc/html/static/js/search.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,15 +1126,18 @@ window.initSearch = function(rawSearchIndex) {
11261126
}
11271127
}
11281128

1129-
let crates = `<select id="crate-search"><option value="All crates">All crates</option>`;
1130-
for (let c of window.ALL_CRATES) {
1131-
crates += `<option value="${c}" ${c == filterCrates && "selected"}>${c}</option>`;
1129+
let crates = "";
1130+
if (window.ALL_CRATES.length > 1) {
1131+
crates = ` in <select id="crate-search"><option value="All crates">All crates</option>`;
1132+
for (let c of window.ALL_CRATES) {
1133+
crates += `<option value="${c}" ${c == filterCrates && "selected"}>${c}</option>`;
1134+
}
1135+
crates += `</select>`;
11321136
}
1133-
crates += `</select>`;
11341137
var output = `<div id="search-settings">
11351138
<h1 class="search-results-title">Results for ${escape(query.query)} ` +
11361139
(query.type ? " (type: " + escape(query.type) + ")" : "") + "</h1>" +
1137-
` in ${crates} ` +
1140+
crates +
11381141
`</div><div id="titles">` +
11391142
makeTabHeader(0, "In Names", ret_others[1]) +
11401143
makeTabHeader(1, "In Parameters", ret_in_args[1]) +
@@ -1148,7 +1151,10 @@ window.initSearch = function(rawSearchIndex) {
11481151
resultsElem.appendChild(ret_returned[0]);
11491152

11501153
search.innerHTML = output;
1151-
document.getElementById("crate-search").addEventListener("input", updateCrate);
1154+
let crateSearch = document.getElementById("crate-search");
1155+
if (crateSearch) {
1156+
crateSearch.addEventListener("input", updateCrate);
1157+
}
11521158
search.appendChild(resultsElem);
11531159
// Reset focused elements.
11541160
searchState.focusedByTab = [null, null, null];

0 commit comments

Comments
 (0)