Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 11 additions & 23 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ summary.hideme,
.scraped-example-list,
.rustdoc-breadcrumbs,
.search-switcher,
.search-throbber,
/* This selector is for the items listed in the "all items" page. */
ul.all-items {
font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif;
Expand Down Expand Up @@ -1987,12 +1988,10 @@ a.tooltip:hover::after {
color: inherit;
}
#search-tabs button:not(.selected) {
--search-tab-button-background: var(--search-tab-button-not-selected-background);
background-color: var(--search-tab-button-not-selected-background);
border-top-color: var(--search-tab-button-not-selected-border-top-color);
}
#search-tabs button:hover, #search-tabs button.selected {
--search-tab-button-background: var(--search-tab-button-selected-background);
background-color: var(--search-tab-button-selected-background);
border-top-color: var(--search-tab-button-selected-border-top-color);
}
Expand All @@ -2008,18 +2007,19 @@ a.tooltip:hover::after {
color: transparent;
}

.search-form.loading {
--search-tab-button-background: var(--button-background-color);
.search-throbber {
position: relative;
height: 34px;
}

#search-tabs .count.loading::before,
.search-throbber::before,
.search-form.loading::before
{
width: 16px;
height: 16px;
border-radius: 16px;
background: radial-gradient(
var(--search-tab-button-background) 0 50%,
var(--button-background-color) 0 50%,
transparent 50% 100%
), conic-gradient(
var(--code-highlight-kw-color) 0deg 30deg,
Expand All @@ -2037,37 +2037,25 @@ a.tooltip:hover::after {
);
content: "";
position: absolute;
left: 2px;
top: 2px;
right: 9px;
top: 8px;
animation: rotating 1.25s linear infinite;
}
#search-tabs .count.loading::after,
.search-throbber::after,
.search-form.loading::after
{
width: 18px;
height: 18px;
border-radius: 18px;
background: conic-gradient(
var(--search-tab-button-background) 0deg 180deg,
var(--button-background-color) 0deg 180deg,
transparent 270deg 360deg
);
content: "";
position: absolute;
left: 1px;
top: 1px;
animation: rotating 0.66s linear infinite;
}

.search-form.loading::before {
left: auto;
right: 9px;
top: 8px;
}

.search-form.loading::after {
left: auto;
right: 8px;
top: 8px;
animation: rotating 0.66s linear infinite;
}

#search .error code {
Expand Down
19 changes: 16 additions & 3 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -4701,6 +4701,11 @@ async function addTab(results, query, display, finishedCallback, isTypeSearch) {
let output = document.createElement("ul");
output.className = "search-results " + extraClass;

const throbber = document.createElement("div");
throbber.className = "search-throbber";
throbber.innerHTML = "Loading...";
output.appendChild(throbber);

let count = 0;

/** @type {Promise<string|null>[]} */
Expand Down Expand Up @@ -4807,7 +4812,7 @@ ${obj.displayPath}<span class="${type}">${name}</span>\
}

link.appendChild(description);
output.appendChild(link);
output.insertBefore(link, throbber);

results.next().then(async nextResult => {
if (nextResult.value) {
Expand All @@ -4816,7 +4821,10 @@ ${obj.displayPath}<span class="${type}">${name}</span>\
await Promise.all(descList);
// need to make sure the element is shown before
// running this callback
yieldToBrowser().then(() => finishedCallback(count, output));
yieldToBrowser().then(() => {
finishedCallback(count, output);
throbber.remove();
});
}
});
};
Expand Down Expand Up @@ -5012,9 +5020,14 @@ async function showResults(docSearch, results, goToFirst, filterCrates) {
resultsElem.id = "results";

search.innerHTML = "";
for (const [tab, output] of tabs) {
for (const [tabNb, [tab, output]] of tabs.entries()) {
tabsElem.appendChild(tab);
const isCurrentTab = window.searchState.currentTab === tabNb;
const placeholder = document.createElement("div");
placeholder.className = isCurrentTab ?
"search-throbber search-results active" :
"search-throbber search-results";
placeholder.innerHTML = "Loading...";
output.then(output => {
if (placeholder.parentElement) {
placeholder.parentElement.replaceChild(output, placeholder);
Expand Down
Loading