From 54594350bd44c6aa801773f5474524d07c8b5fce Mon Sep 17 00:00:00 2001 From: dragonwocky Date: Wed, 24 Jan 2024 13:09:54 +1100 Subject: [PATCH] fix: no more menu skeleton fouc --- src/core/menu/islands/Footer.mjs | 24 ++++++++++++------------ src/core/menu/menu.css | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/core/menu/islands/Footer.mjs b/src/core/menu/islands/Footer.mjs index 154eb7a..49cbe1a 100644 --- a/src/core/menu/islands/Footer.mjs +++ b/src/core/menu/islands/Footer.mjs @@ -16,8 +16,7 @@ function Footer({ categories, transitionDuration = 150 }) { icon="refresh-cw" onclick=${reloadApp} style="display: none" - > - Reload & Apply Changes + >Reload & Apply Changes `, $categories = categories.map(({ id, title, mods }) => { return [ @@ -25,8 +24,7 @@ function Footer({ categories, transitionDuration = 150 }) { html`<${Button} icon="chevron-left" onclick=${() => setState({ transition: "slide-to-left", view: id })} - > - ${title} + >${title} `, ]; }); @@ -35,19 +33,21 @@ function Footer({ categories, transitionDuration = 150 }) { let [footerOpen] = useState(["databaseUpdated"]); footerOpen ||= $categories.some(([ids]) => ids.some((id) => id === view)); setState({ footerOpen }); - if (!footerOpen) return; - - // only toggle buttons if footer is open, - // otherwise leave as is during transition - for (const [ids, $btn] of $categories) { - const viewInCategory = ids.some((id) => id === view); - $btn.style.display = viewInCategory ? "" : "none"; - } }); useState(["databaseUpdated"], ([databaseUpdated]) => { $reload.style.display = databaseUpdated ? "" : "none"; if (databaseUpdated) setState({ footerOpen: true }); }); + useState(["footerOpen"], ([footerOpen]) => { + // only toggle buttons if footer is open, + // otherwise leave as is during transition + if (!footerOpen) return; + const [view] = useState(["view"]); + for (const [ids, $btn] of $categories) { + const viewInCategory = ids.some((id) => id === view); + $btn.style.display = viewInCategory ? "" : "none"; + } + }); return html`