Skip to content

Commit

Permalink
fix: smooth loading + fixed empty select (web)
Browse files Browse the repository at this point in the history
  • Loading branch information
g0ldyy committed Jul 3, 2024
1 parent 9f25081 commit f9dd917
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 49 deletions.
21 changes: 19 additions & 2 deletions comet/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
}

body {
opacity: 0;
display: flex;
flex-direction: column;
justify-content: center;
Expand All @@ -33,6 +34,11 @@
font-weight: 400;
}

body.ready {
opacity: 1;
transition: 0.25s opacity;
}

::-webkit-scrollbar {
overflow: hidden;
}
Expand Down Expand Up @@ -506,17 +512,28 @@
let defaultLanguages = [];
let defaultResolutions = [];

document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMContentLoaded", async () => {
await Promise.allSettled([
customElements.whenDefined("sl-button"),
customElements.whenDefined("sl-alert"),
customElements.whenDefined("sl-select"),
customElements.whenDefined("sl-input"),
customElements.whenDefined("sl-option"),
customElements.whenDefined("sl-icon")
]);

const webConfig = {{webConfig|tojson}};
populateSelect("indexers", webConfig.indexers);
populateSelect("languages", webConfig.languages);
populateSelect("resolutions", webConfig.resolutions);

document.body.classList.add("ready");

defaultLanguages = webConfig.languages;
defaultResolutions = webConfig.resolutions;
});

function populateSelect(selectId, options) {
async function populateSelect(selectId, options) {
const selectElement = document.getElementById(selectId);
options.forEach(option => {
const optionElement = document.createElement("sl-option");
Expand Down
99 changes: 52 additions & 47 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f9dd917

Please sign in to comment.