From 79cb2405c1e407c5d9d09d42d30c7852ad88d130 Mon Sep 17 00:00:00 2001 From: Maciej Setkowski <2069561+msetkowski@users.noreply.github.com> Date: Mon, 9 Nov 2026 23:36:20 +0100 Subject: [PATCH] Project pages: header and side navigation stay in place while scrolling The app header (breadcrumbs) is sticky on pages with the project workbench, and the side navigation is pinned below it with its own scroll when it is taller than the window. The page itself still scrolls, so wheel, keyboard, find-in-page and anchors behave as before; anchor targets now stop below the header. app.js keeps --header-h in sync with the header's height, which grows when breadcrumbs wrap. Narrow screens (720 px and below), where the navigation stacks above the content, keep the previous non-sticky layout. Co-Authored-By: Claude Opus 5.5 --- src/main/resources/static/css/app.css | 18 +++++++++++++++--- src/main/resources/static/js/app.js | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/resources/static/css/app.css b/src/main/resources/static/css/app.css index 198aad6..a48ebbd 100644 --- a/src/main/resources/static/css/app.css +++ b/src/main/resources/static/css/app.css @@ -178,6 +178,10 @@ code, kbd, .mono { font-family: var(--font-mono); } } .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; color: #fff; text-decoration: none; } .brand:hover { color: #fff; } +/* Project pages: header and side navigation stay in place while the page scrolls (not on narrow screens, + where the navigation stacks above the content). --header-h is set by app.js. */ +body:has(.workbench) .app-header { position: sticky; top: 0; z-index: 30; } + .crumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--chrome-text); font-size: 13px; } .crumbs a { color: var(--chrome-text); } .crumbs a:hover { color: #fff; } @@ -232,6 +236,10 @@ code, kbd, .mono { font-family: var(--font-mono); } .workbench > .rail { flex: 0 1 340px; padding: 28px 24px 48px 0; display: flex; flex-direction: column; gap: 16px; } .sidenav { padding: 20px 12px; background: var(--surface); border-right: 1px solid var(--line); } +.workbench > .sidenav { + position: sticky; top: var(--header-h, 60px); align-self: flex-start; + height: calc(100vh - var(--header-h, 60px)); overflow-y: auto; overscroll-behavior: contain; +} .sidenav nav { display: flex; flex-direction: column; gap: 2px; } .sidenav a { display: flex; justify-content: space-between; align-items: center; gap: 8px; @@ -361,9 +369,9 @@ table.data a.cell-link .name { font-weight: 600; } .link-list .kind { color: var(--muted); min-width: 96px; display: inline-block; } /* element document blocks */ -.doc-section { display: flex; flex-direction: column; gap: 12px; scroll-margin-top: 16px; } +.doc-section { display: flex; flex-direction: column; gap: 12px; scroll-margin-top: calc(var(--header-h, 0px) + 16px); } .doc-section > h2 { font-size: 20px; padding-bottom: 6px; border-bottom: 1px solid var(--line); } -.doc-element { padding: 16px; scroll-margin-top: 16px; } +.doc-element { padding: 16px; scroll-margin-top: calc(var(--header-h, 0px) + 16px); } .doc-element header { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; margin-bottom: 8px; } .doc-element header h3 { font-size: 16px; } .doc-element .traces { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); } @@ -404,7 +412,11 @@ table.data a.cell-link .name { font-weight: 600; } .app-header { padding: 12px 16px; } .workbench > .content { padding: 20px 16px; } .workbench > .rail { padding: 0 16px 32px; } - .workbench > .sidenav { flex-basis: 100%; border-right: 0; border-bottom: 1px solid var(--line); } + .workbench > .sidenav { + flex-basis: 100%; border-right: 0; border-bottom: 1px solid var(--line); + position: static; height: auto; overflow-y: visible; + } + body:has(.workbench) .app-header { position: static; } } @media print { diff --git a/src/main/resources/static/js/app.js b/src/main/resources/static/js/app.js index c186c65..b381439 100644 --- a/src/main/resources/static/js/app.js +++ b/src/main/resources/static/js/app.js @@ -1,4 +1,4 @@ -// Global behaviour shared by every page: CSRF for HTMX requests and Mermaid rendering. +// Global behaviour shared by every page: CSRF for HTMX requests, Mermaid rendering and the sticky project header. (function () { "use strict"; @@ -51,7 +51,21 @@ } window.reqlith = { renderMermaid: renderMermaid }; + // On project pages the header is sticky (except on narrow screens); --header-h tells the side navigation + // and anchor targets how much room it takes (it grows when the breadcrumbs wrap). + function trackHeaderHeight() { + var header = document.querySelector(".app-header"); + if (!header || !document.querySelector(".workbench")) return; + var update = function () { + var sticky = getComputedStyle(header).position === "sticky"; + document.documentElement.style.setProperty("--header-h", (sticky ? header.offsetHeight : 0) + "px"); + }; + update(); + if (window.ResizeObserver) new ResizeObserver(update).observe(header); + } + document.addEventListener("DOMContentLoaded", function () { + trackHeaderHeight(); renderMermaid(document).finally(function () { window.mermaidDone = true; }); }); document.addEventListener("htmx:afterSettle", function (event) {