Hide the top bar on the home page
Visitors see the home page with no top bar at all. Signed in, the bar sits behind a small tab at the top center that drops it down; Escape or a click outside closes it. Every other page keeps the regular bar. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f3185ba7bd
commit
0d4bbe8c8a
3 files changed
+61
-13
No files matched your search
@@ -67,6 +67,28 @@ code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; bac
|
|||||||
.topnav-form { margin: 0; }
|
.topnav-form { margin: 0; }
|
||||||
@media (max-width: 520px) { .topnav a span { display: none; } }
|
@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 ---------- */
|
||||||
.footer { margin-top: 72px; border-top: 1px solid var(--border); color: var(--faint); font-size: 13px; }
|
.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; }
|
.footer-inner { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-top: 22px; padding-bottom: 28px; }
|
||||||
|
|||||||
@@ -189,3 +189,16 @@ document.addEventListener("click", (e) => {
|
|||||||
if (!d.contains(e.target) || e.target.closest(".menu-pop a")) d.open = false;
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
+26
-13
@@ -15,6 +15,31 @@
|
|||||||
</head>
|
</head>
|
||||||
<body class="{{block "bodyclass" .}}{{end}}">
|
<body class="{{block "bodyclass" .}}{{end}}">
|
||||||
<a class="skip-link" href="#main">Skip to content</a>
|
<a class="skip-link" href="#main">Skip to content</a>
|
||||||
|
{{- 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. */}}
|
||||||
|
<details class="topbar-drawer">
|
||||||
|
<summary class="topbar-tab" aria-label="Show menu" title="Menu">{{icon "chevron-down"}}</summary>
|
||||||
|
{{template "topbar" .}}
|
||||||
|
</details>
|
||||||
|
{{- end}}
|
||||||
|
<main id="main">
|
||||||
|
{{block "content" .}}{{end}}
|
||||||
|
</main>
|
||||||
|
<footer class="footer">
|
||||||
|
<div class="container footer-inner">
|
||||||
|
<span>{{if .Site.OwnerName}}Curated by {{.Site.OwnerName}}{{else}}{{.Site.Title}}{{end}}</span>
|
||||||
|
<span class="footer-sep" aria-hidden="true">·</span>
|
||||||
|
<span>Powered by <a href="https://git.iamchrisama.com/cdnutter/canon" rel="noopener">Canon</a></span>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
{{block "scripts" .}}{{end}}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
{{define "topbar"}}
|
||||||
<header class="topbar">
|
<header class="topbar">
|
||||||
<div class="topbar-inner container">
|
<div class="topbar-inner container">
|
||||||
<a class="brand" href="/">
|
<a class="brand" href="/">
|
||||||
@@ -32,16 +57,4 @@
|
|||||||
{{- end}}
|
{{- end}}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<main id="main">
|
{{end}}
|
||||||
{{block "content" .}}{{end}}
|
|
||||||
</main>
|
|
||||||
<footer class="footer">
|
|
||||||
<div class="container footer-inner">
|
|
||||||
<span>{{if .Site.OwnerName}}Curated by {{.Site.OwnerName}}{{else}}{{.Site.Title}}{{end}}</span>
|
|
||||||
<span class="footer-sep" aria-hidden="true">·</span>
|
|
||||||
<span>Powered by <a href="https://git.iamchrisama.com/cdnutter/canon" rel="noopener">Canon</a></span>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
{{block "scripts" .}}{{end}}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Reference in new issue
Block a user