From 1c9292e22d07ae485689e63cad6b820ec8ebf50c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asger=20Geel=20Weirs=C3=B8e?= Date: Sun, 14 Jun 2026 19:45:00 +0200 Subject: [PATCH] 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). --- weirsoe-ui.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/weirsoe-ui.js b/weirsoe-ui.js index 9a74b26..fe7a53d 100644 --- a/weirsoe-ui.js +++ b/weirsoe-ui.js @@ -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;