weirsoe-ui.js: publish measured fixed-navbar height as --wt-nav-height

So content can clear a fixed top navbar exactly instead of guessing (CSS guesses
overlapped on mobile when the bar was taller). Measured on load/resize/orientation
from .navbar.is-fixed-top (or [data-wt-fixed-nav]); consumers use
padding-top: calc(var(--wt-nav-height) + gap).
This commit is contained in:
Asger Geel Weirsøe
2026-06-14 19:45:00 +02:00
parent 437b4fadd2
commit 1c9292e22d
+11
View File
@@ -182,6 +182,17 @@
document.querySelectorAll('[data-wt-sortable]').forEach(initSortable);
}
// Publish the real fixed-navbar height as --wt-nav-height so content can clear
// it exactly (CSS guesses overlap when the navbar is taller than assumed).
function setNavHeight() {
var nav = document.querySelector('[data-wt-fixed-nav], .navbar.is-fixed-top');
if (nav) document.documentElement.style.setProperty('--wt-nav-height', nav.offsetHeight + 'px');
}
setNavHeight();
window.addEventListener('load', setNavHeight);
window.addEventListener('resize', setNavHeight);
window.addEventListener('orientationchange', setNavHeight);
document.addEventListener('click', function (e) {
var btn = e.target.closest && e.target.closest('[data-copy-link]');
if (!btn) return;