From 81ce440269a29d70de5c806f03d064b0897cf7db Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Thu, 12 Jun 2025 22:23:55 -0500 Subject: integrate tailwind more and a few other minor features --- src/pages.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/pages.js') diff --git a/src/pages.js b/src/pages.js index 0576684..f6a8b9b 100644 --- a/src/pages.js +++ b/src/pages.js @@ -1,3 +1,5 @@ +const menu = document.querySelector("#menu") + export default class Page { static pages = {} static currentPage = null @@ -33,9 +35,20 @@ export default class Page { } setVisible(visible) { - this.pageContainer.style.display = visible ? null : "none" + this.pageContainer.classList.toggle("hidden!", !visible) this.visible = visible - if (visible && !this.initialized && this.initialize) - this.initialized = this.initialize(this.pageContainer) + if (this.visible) { + /* initialize page */ + if (!this.initialized && this.initialize) + this.initialized = this.initialize(this.pageContainer) + + /* set selected attribute on the link */ + for (const a of menu.querySelectorAll("a")) { + if (this.endpoints.includes(a.getAttribute("href"))) + a.dataset.selected = "1" + else + delete a.dataset.selected + } + } } } -- cgit v1.2.3