Update Layout

This commit is contained in:
2026-05-17 11:04:52 +02:00
parent d3e896d74e
commit fe3522b93b
5 changed files with 54 additions and 71 deletions
+3
View File
@@ -29,9 +29,12 @@
{{end}} {{end}}
{{block "headerActions" .}}{{end}} {{block "headerActions" .}}{{end}}
</header> </header>
<div class="page-wrap">
<main> <main>
{{block "content" .}}{{end}} {{block "content" .}}{{end}}
</main> </main>
<aside class="sidebar">{{block "sidebar" .}}{{end}}</aside>
</div>
<footer> <footer>
<span class="muted">Request: {{.RenderMS}} ms</span> <span class="muted">Request: {{.RenderMS}} ms</span>
{{block "footerExtras" .}}{{end}} {{block "footerExtras" .}}{{end}}
+8 -15
View File
@@ -1,4 +1,4 @@
{{define "headScripts"}}<script src="/_/page/actions.js"></script><script src="/_/page/right-rail.js" defer></script>{{end}} {{define "headScripts"}}<script src="/_/page/actions.js"></script>{{end}}
{{define "content"}} {{define "content"}}
{{if .Content}} {{if .Content}}
@@ -34,20 +34,13 @@
{{end}} {{end}}
{{end}} {{end}}
{{define "extras"}} {{define "sidebar"}}{{if .CanEdit}}<nav class="actions">
<div class="right-rail">
{{if .CanEdit}}
<nav class="actions">
<div class="panel-header">ACTIONS</div> <div class="panel-header">ACTIONS</div>
<button class="btn btn-block" onclick="newPage()" title="New page (N)">NEW</button> <button class="btn btn-block" onclick="newPage()" title="New page (N)">NEW PAGE</button>
<a class="btn btn-block" href="?edit" title="Edit page (E)">EDIT</a> <a class="btn btn-block" href="?edit" title="Edit page (E)">EDIT PAGE</a>
<button class="btn btn-block" data-companion-reveal hidden title="Reveal in file manager">REVEAL</button> <button class="btn btn-block" data-companion-reveal hidden title="Reveal in file manager">REVEAL ON CLIENT</button>
{{if not .IsRoot}} {{if not .IsRoot}}
<button class="btn btn-block" onclick="movePage()" title="Move page (M)">MOVE</button> <button class="btn btn-block" onclick="movePage()" title="Move page (M)">MOVE PAGE</button>
<button class="btn btn-block danger" onclick="deletePage()" title="Delete page">DELETE</button> <button class="btn btn-block danger" onclick="deletePage()" title="Delete page">DELETE PAGE</button>
{{end}} {{end}}
</nav> </nav>{{end}}{{if .SidebarWidget}}{{.SidebarWidget}}{{end}}{{end}}
{{end}}
{{if .SidebarWidget}}{{.SidebarWidget}}{{end}}
</div>
{{end}}
-17
View File
@@ -1,17 +0,0 @@
document.addEventListener("DOMContentLoaded", function () {
var rail = document.querySelector(".right-rail");
if (!rail) return;
var header = document.querySelector("header");
if (!header) return;
function updateTop() {
if (getComputedStyle(rail).position !== "fixed") {
rail.style.top = "";
return;
}
var rect = header.getBoundingClientRect();
rail.style.top = Math.max(8, rect.bottom + 8) + "px";
}
window.addEventListener("scroll", updateTop, { passive: true });
window.addEventListener("resize", updateTop);
updateTop();
});
+1 -6
View File
@@ -28,12 +28,7 @@ document.addEventListener("DOMContentLoaded", function () {
}); });
nav.appendChild(list); nav.appendChild(list);
var rail = document.querySelector(".right-rail"); var rail = document.querySelector("aside.sidebar");
if (!rail) {
rail = document.createElement("div");
rail.className = "right-rail";
document.body.appendChild(rail);
}
rail.appendChild(nav); rail.appendChild(nav);
var fab = document.createElement("button"); var fab = document.createElement("button");
+37 -28
View File
@@ -145,13 +145,28 @@ header {
color: var(--danger-hover); color: var(--danger-hover);
} }
/* === Page wrap ===
Note: sticky positioning on .sidebar depends on no ancestor having
overflow: auto/hidden. If you add scroll containment above this, sticky
will silently break. */
.page-wrap {
display: grid;
grid-template-columns: minmax(0, 1fr) 14rem;
gap: 1.5rem;
max-width: 1280px;
margin: 0 auto;
padding: 0 1rem;
width: 100%;
flex: 1;
align-items: start;
}
/* === Main === */ /* === Main === */
main { main {
max-width: 860px;
margin: 0 auto;
padding: 1.5rem 1rem; padding: 1.5rem 1rem;
width: 100%; width: 100%;
flex: 1; flex: 1;
min-width: 0;
} }
/* === Markdown content === */ /* === Markdown content === */
@@ -392,7 +407,7 @@ button.fab {
flex-direction: column; flex-direction: column;
} }
body.editor-wide main { body.editor-wide .page-wrap {
max-width: none; max-width: none;
} }
@@ -546,24 +561,27 @@ hr {
background: var(--primary-hover); background: var(--primary-hover);
} }
/* === Right rail === */ /* === Sidebar === */
.right-rail { .sidebar {
position: fixed; position: sticky;
top: 1rem; top: 1rem;
right: 1rem; align-self: start;
width: 14rem;
max-height: calc(100vh - 2rem); max-height: calc(100vh - 2rem);
overflow-y: auto; overflow-y: auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 1rem; gap: 1rem;
z-index: 10; margin-top: 1.5rem;
} }
/* Panels share visual treatment when inside the rail */ aside.sidebar:empty {
display: none;
}
/* Panels share visual treatment when inside the sidebar */
.actions, .actions,
.right-rail .toc, .sidebar .toc,
.right-rail .diary-cal { .sidebar .diary-cal {
position: static; position: static;
top: auto; top: auto;
left: auto; left: auto;
@@ -795,17 +813,6 @@ hr {
} }
/* === Diary Calendar === */ /* === Diary Calendar === */
.diary-cal {
position: fixed;
top: 1rem;
left: 1rem;
width: 13rem;
border: 1px solid var(--secondary);
background: var(--bg);
padding: 0.5rem 0.75rem;
font-size: 0.85rem;
}
.diary-cal-nav { .diary-cal-nav {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -874,12 +881,14 @@ hr {
/* === Responsive === */ /* === Responsive === */
@media (max-width: 1100px) { @media (max-width: 1100px) {
.right-rail { .page-wrap {
grid-template-columns: 1fr;
}
.sidebar {
display: contents;
position: static; position: static;
width: auto;
max-height: none; max-height: none;
overflow: visible; overflow: visible;
display: contents;
} }
button.fab { button.fab {
display: inline-flex; display: inline-flex;
@@ -922,7 +931,7 @@ hr {
display: block; display: block;
} }
/* TOC on mobile is a floating overlay toggled by the FAB. */ /* TOC on mobile is a floating overlay toggled by the FAB. */
.right-rail .toc, .sidebar .toc,
.toc { .toc {
position: fixed; position: fixed;
bottom: 5rem; bottom: 5rem;
@@ -936,7 +945,7 @@ hr {
display: none; display: none;
z-index: 60; z-index: 60;
} }
.right-rail .toc.is-open, .sidebar .toc.is-open,
.toc.is-open { .toc.is-open {
display: block; display: block;
} }