Inital attempt

This commit is contained in:
2026-05-15 11:26:07 +02:00
parent a9519f747e
commit 3e765aa54f
6 changed files with 134 additions and 76 deletions
+5 -14
View File
@@ -2,6 +2,8 @@
var cal = document.querySelector(".diary-cal");
if (!cal) return;
cal.querySelectorAll(".dropdown > button").forEach(wireDropdown);
var toggle = document.createElement("button");
toggle.type = "button";
toggle.className = "panel-toggle";
@@ -13,20 +15,9 @@
});
var main = document.querySelector("main");
if (main) {
main.parentNode.insertBefore(toggle, main);
if (!main) return;
main.parentNode.insertBefore(toggle, main);
if (window.matchMedia("(max-width: 1100px)").matches) {
main.parentNode.insertBefore(cal, main);
}
cal.querySelectorAll(".dropdown > button").forEach(wireDropdown);
var pageHeader = document.querySelector("header");
function updateTop() {
if (!pageHeader || getComputedStyle(cal).position !== "fixed") return;
var rect = pageHeader.getBoundingClientRect();
cal.style.top = Math.max(8, rect.bottom + 8) + "px";
}
window.addEventListener("scroll", updateTop, { passive: true });
window.addEventListener("resize", updateTop);
updateTop();
})();