diff --git a/web/static/css/app.css b/web/static/css/app.css index 87ccaff..0356bfb 100644 --- a/web/static/css/app.css +++ b/web/static/css/app.css @@ -67,6 +67,28 @@ code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; bac .topnav-form { margin: 0; } @media (max-width: 520px) { .topnav a span { display: none; } } +/* Home page, signed in: the bar drops down from a small tab. */ +.topbar-tab { + position: fixed; top: 0; left: 50%; z-index: 30; transform: translateX(-50%); + display: grid; place-items: center; width: 44px; height: 20px; + list-style: none; cursor: pointer; color: var(--faint); + background: color-mix(in srgb, var(--surface) 88%, transparent); + border: 1px solid var(--border); border-top: 0; border-radius: 0 0 10px 10px; + backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); + opacity: 0.7; transition: opacity 0.15s, color 0.15s, top 0.2s; +} +.topbar-tab::-webkit-details-marker { display: none; } +.topbar-tab .icon { width: 14px; height: 14px; transition: transform 0.2s; } +.topbar-tab:hover, .topbar-tab:focus-visible { opacity: 1; color: var(--text); } +.topbar-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } +.topbar-drawer .topbar { position: fixed; left: 0; right: 0; animation: topbar-drop 0.2s ease-out; } +.topbar-drawer[open] .topbar-tab { top: 60px; opacity: 1; } +.topbar-drawer[open] .topbar-tab .icon { transform: rotate(180deg); } +@keyframes topbar-drop { from { transform: translateY(-100%); } } +@media (prefers-reduced-motion: reduce) { + .topbar-drawer .topbar { animation: none; } +} + /* ---------- footer ---------- */ .footer { margin-top: 72px; border-top: 1px solid var(--border); color: var(--faint); font-size: 13px; } .footer-inner { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-top: 22px; padding-bottom: 28px; } diff --git a/web/static/js/common.js b/web/static/js/common.js index 102c8db..4dbab5c 100644 --- a/web/static/js/common.js +++ b/web/static/js/common.js @@ -189,3 +189,16 @@ document.addEventListener("click", (e) => { if (!d.contains(e.target) || e.target.closest(".menu-pop a")) d.open = false; } }); + +// The home page's drop-down top bar closes on Escape or a click outside it. +document.addEventListener("click", (e) => { + const d = document.querySelector("details.topbar-drawer[open]"); + if (d && !d.contains(e.target)) d.open = false; +}); +document.addEventListener("keydown", (e) => { + const d = document.querySelector("details.topbar-drawer[open]"); + if (e.key === "Escape" && d) { + d.open = false; + d.querySelector("summary").focus(); + } +}); diff --git a/web/templates/layout.html b/web/templates/layout.html index 476e042..27bee16 100644 --- a/web/templates/layout.html +++ b/web/templates/layout.html @@ -15,6 +15,31 @@
Skip to content +{{- if ne .Path "/"}} +{{template "topbar" .}} +{{- else if .LoggedIn}} +{{- /* The home page is the public face, so even signed in the bar stays + tucked away behind a small tab until it's wanted. */}} + +{{- end}} +