Website: use one navigation bar across pages
Co-Authored-By: OpenCode gpt-6.1-sol <noreply@opencode.ai>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// What every page with the site's top bar shares: the light and dark switch and the phone menu.
|
||||
// Used by main.js (the home page) and page.js (Releases, Benchmarks).
|
||||
// Used by Home, Releases, Benchmarks and Docs.
|
||||
const reducedMotion = matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||
|
||||
// The page follows the system; the toggle picks the other appearance and remembers it.
|
||||
@@ -27,7 +27,7 @@ export function setUpMenu() {
|
||||
const bar = document.querySelector(".nav");
|
||||
const button = document.querySelector(".menu-button");
|
||||
const menu = document.getElementById("menu");
|
||||
const main = document.getElementById("main");
|
||||
const content = document.querySelector("[data-menu-content]") || document.getElementById("main");
|
||||
if (!bar || !button || !menu) return;
|
||||
const label = button.querySelector(".menu-label");
|
||||
const items = [...menu.querySelectorAll("nav a")];
|
||||
@@ -38,7 +38,7 @@ export function setUpMenu() {
|
||||
button.setAttribute("aria-expanded", String(open));
|
||||
label.textContent = open ? "Close" : "Menu";
|
||||
bar.classList.toggle("is-menu", open);
|
||||
main.inert = open;
|
||||
content.inert = open;
|
||||
document.body.style.overflow = open ? "hidden" : "";
|
||||
if (open) {
|
||||
menu.hidden = false;
|
||||
@@ -57,7 +57,7 @@ export function setUpMenu() {
|
||||
button.focus();
|
||||
}
|
||||
});
|
||||
matchMedia("(min-width: 1120px)").addEventListener("change", (e) => e.matches && setOpen(false));
|
||||
matchMedia("(min-width: 1280px)").addEventListener("change", (e) => e.matches && setOpen(false));
|
||||
}
|
||||
|
||||
// GitHub answers, cached for ten minutes in the tab.
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// The Docs pages share the site's theme switch and phone menu.
|
||||
import { setUpMenu, setUpTheme } from "./chrome.js";
|
||||
|
||||
setUpTheme();
|
||||
setUpMenu();
|
||||
+6
-14
@@ -1,8 +1,8 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<html lang="en" class="no-js">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<title>{{DOC_TITLE}} · Horizon docs</title>
|
||||
<meta name="description" content="{{DOC_DESC}}">
|
||||
<meta name="theme-color" content="#ece7f7" media="(prefers-color-scheme: light)">
|
||||
@@ -19,22 +19,14 @@
|
||||
<meta property="og:url" content="https://playhorizon.dev{{DOC_PATH}}">
|
||||
<meta property="og:image" content="https://playhorizon.dev/og.png">
|
||||
<link rel="stylesheet" href="{{CSS}}">
|
||||
<script>try { const t = localStorage.getItem("theme"); if (t === "light" || t === "dark") document.documentElement.dataset.theme = t } catch {}</script>
|
||||
<script>document.documentElement.classList.replace("no-js", "js"); try { const t = localStorage.getItem("theme"); if (t === "light" || t === "dark") document.documentElement.dataset.theme = t } catch {}</script>
|
||||
<script type="module" src="{{DOCS_JS}}"></script>
|
||||
</head>
|
||||
<body class="docs-page">
|
||||
<a class="skip" href="#main">Skip to the content</a>
|
||||
<header class="docs-bar">
|
||||
<div class="docs-bar-inner">
|
||||
<a class="nav-mark" href="/" aria-label="Horizon, home"><svg class="mark" viewBox="0 0 16 16" aria-hidden="true"><path class="mark-stem" d="M4 3h2v4H4zM10 3h2v4h-2z"/><path class="mark-low" d="M4 8h2v4H4zM10 8h2v4h-2z"/><path class="mark-line" d="M1 7h14v1H1z"/></svg>Horizon</a>
|
||||
<a class="docs-bar-title" href="/docs/">Docs</a>
|
||||
<span class="docs-bar-end">
|
||||
<a class="docs-bar-link" href="https://github.com/ludovic111/horizon">GitHub</a>
|
||||
<a class="button primary small" href="/docs/install">Download</a>
|
||||
</span>
|
||||
</div>
|
||||
</header>
|
||||
{{SITE_NAV}}
|
||||
|
||||
<div class="docs">
|
||||
<div class="docs" data-menu-content>
|
||||
<details class="docs-nav-wrap" open>
|
||||
<summary>Docs menu</summary>
|
||||
<nav class="docs-nav" aria-label="Documentation">
|
||||
|
||||
+1
-41
@@ -35,47 +35,7 @@
|
||||
<body>
|
||||
<a class="skip" href="#main">Skip to the content</a>
|
||||
|
||||
<header class="nav" id="top">
|
||||
<div class="nav-inner">
|
||||
<a class="nav-mark" href="#top" aria-label="Horizon, back to the top"><svg class="mark" viewBox="0 0 16 16" aria-hidden="true"><path class="mark-stem" d="M4 3h2v4H4zM10 3h2v4h-2z"/><path class="mark-low" d="M4 8h2v4H4zM10 8h2v4h-2z"/><path class="mark-line" d="M1 7h14v1H1z"/></svg>Horizon</a>
|
||||
<nav class="nav-links" id="nav-links" aria-label="Sections">
|
||||
<a href="#about">About</a>
|
||||
<a href="#screenshots">In game</a>
|
||||
<a href="#parity">Parity</a>
|
||||
<a href="#launcher">Launcher</a>
|
||||
<a href="#recent">New</a>
|
||||
<a href="#community">Community</a>
|
||||
<a href="/releases">Releases</a>
|
||||
<a href="/benchmarks">Benchmarks</a>
|
||||
<a href="/docs/">Docs</a>
|
||||
</nav>
|
||||
<div class="nav-end">
|
||||
<button class="theme-toggle" type="button" aria-label="Switch between light and dark"><span data-theme-label>Dark</span></button>
|
||||
<a class="nav-github" href="https://github.com/ludovic111/horizon">GitHub</a>
|
||||
<a class="button primary small" data-download href="https://github.com/ludovic111/horizon/releases?q=launcher-v&expanded=true">Download</a>
|
||||
<button class="menu-button" type="button" aria-expanded="false" aria-controls="menu"><span class="menu-label">Menu</span><span class="menu-icon" aria-hidden="true"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="menu" id="menu" hidden>
|
||||
<nav aria-label="Sections">
|
||||
<a href="#about">About</a>
|
||||
<a href="#screenshots">In game</a>
|
||||
<a href="#parity">Parity</a>
|
||||
<a href="#launcher">Launcher</a>
|
||||
<a href="#recent">Recently added</a>
|
||||
<a href="#community">Community</a>
|
||||
<a href="#contributors" data-contributors{{CONTRIBUTORS_HIDDEN}}>Contributors</a>
|
||||
<a href="/releases">Releases</a>
|
||||
<a href="/benchmarks">Benchmarks</a>
|
||||
<a href="/docs/">Documentation</a>
|
||||
</nav>
|
||||
<div class="menu-foot">
|
||||
<a class="button secondary large" href="https://github.com/ludovic111/horizon">GitHub</a>
|
||||
<p>Not an official Minecraft product. Not approved by or associated with Mojang or Microsoft.</p>
|
||||
</div>
|
||||
</div>
|
||||
{{SITE_NAV}}
|
||||
|
||||
<main id="main">
|
||||
<section class="hero" aria-labelledby="hero-title">
|
||||
|
||||
+3
-5
@@ -135,14 +135,12 @@ async function setUpLive() {
|
||||
// --- Navigation ----------------------------------------------------------------------
|
||||
|
||||
function setUpNav() {
|
||||
const bar = document.querySelector(".nav");
|
||||
// The sections on this page (the nav also links to other pages, such as /server).
|
||||
const links = [...document.querySelectorAll('.nav-links a[href^="#"]')];
|
||||
const sections = links.map((a) => document.querySelector(a.getAttribute("href")));
|
||||
// The home sections use the same root-relative links in every page's header.
|
||||
const links = [...document.querySelectorAll('.nav-links a[href^="/#"]')];
|
||||
const sections = links.map((a) => document.querySelector(a.hash));
|
||||
|
||||
let current = null;
|
||||
const update = () => {
|
||||
bar.classList.toggle("is-scrolled", scrollY > 24);
|
||||
const line = innerHeight * 0.4;
|
||||
let index = -1;
|
||||
sections.forEach((s, i) => {
|
||||
|
||||
+14
-29
@@ -117,14 +117,11 @@ code {
|
||||
/* --- Navigation ------------------------------------------------------------------------- */
|
||||
|
||||
.nav {
|
||||
position: fixed; inset: 0 0 auto; z-index: 20; height: var(--nav);
|
||||
background: color-mix(in srgb, var(--page) 0%, transparent);
|
||||
transition: background-color var(--move) var(--ease-move), box-shadow var(--move) var(--ease-move);
|
||||
}
|
||||
.nav.is-scrolled, .nav.is-menu {
|
||||
position: fixed; inset: 0 0 auto; z-index: 20; height: var(--nav); max-width: 100vw;
|
||||
background: color-mix(in srgb, var(--page) 88%, transparent);
|
||||
-webkit-backdrop-filter: blur(16px) saturate(1.2); backdrop-filter: blur(16px) saturate(1.2);
|
||||
box-shadow: 0 1px 0 var(--rule);
|
||||
transition: background-color var(--move) var(--ease-move), box-shadow var(--move) var(--ease-move);
|
||||
}
|
||||
.nav-inner { display: flex; align-items: center; gap: 24px; height: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--g); }
|
||||
.nav-mark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 500; font-size: var(--text-label); }
|
||||
@@ -133,7 +130,7 @@ code {
|
||||
.mark-stem { fill: var(--ink); }
|
||||
.mark-low { fill: var(--ink); opacity: 0.36; }
|
||||
.mark-line { fill: var(--accent); }
|
||||
.nav-links { display: flex; gap: 2px; margin-left: auto; }
|
||||
.nav-links { display: flex; gap: 2px; margin-left: auto; white-space: nowrap; }
|
||||
.nav-links a, .nav-github, .theme-toggle {
|
||||
display: inline-flex; align-items: center; height: 32px; padding: 0 12px;
|
||||
border-radius: var(--radius-pill); color: var(--muted); font-size: var(--text-label);
|
||||
@@ -162,12 +159,12 @@ code {
|
||||
.is-menu .menu-icon::after { top: 4px; transform: rotate(-45deg); }
|
||||
|
||||
.menu {
|
||||
position: fixed; inset: var(--nav) 0 0; z-index: 19; display: flex; flex-direction: column;
|
||||
justify-content: space-between; padding: 24px var(--g) 32px; background: var(--page);
|
||||
position: fixed; inset: var(--nav) 0 0; z-index: 19; display: flex; flex-direction: column; max-width: 100vw;
|
||||
justify-content: space-between; gap: 24px; overflow-y: auto; padding: 24px var(--g) 32px; background: var(--page);
|
||||
opacity: 0; transition: opacity var(--move) var(--ease-move);
|
||||
}
|
||||
.menu.is-open { opacity: 1; }
|
||||
.menu nav { display: flex; flex-direction: column; }
|
||||
.menu nav { display: flex; flex-direction: column; flex-shrink: 0; }
|
||||
.menu nav a {
|
||||
display: flex; align-items: baseline; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule);
|
||||
color: var(--ink); font-size: var(--text-title); line-height: var(--text-title-line);
|
||||
@@ -176,12 +173,13 @@ code {
|
||||
transition: opacity var(--enter) var(--ease-enter), transform var(--enter) var(--ease-enter);
|
||||
}
|
||||
.menu.is-open nav a { opacity: 1; transform: none; }
|
||||
.menu-foot { display: flex; flex-direction: column; gap: 16px; }
|
||||
.menu-foot { display: flex; flex-direction: column; gap: 16px; flex-shrink: 0; }
|
||||
.menu-foot p { font-size: var(--text-caption); color: var(--muted); }
|
||||
|
||||
@media (max-width: 1119px) {
|
||||
@media (max-width: 1279px) {
|
||||
.nav-links, .nav-github { display: none; }
|
||||
.menu-button { display: inline-flex; }
|
||||
.nav-end { margin-left: auto; }
|
||||
}
|
||||
@media (max-width: 520px) {
|
||||
.nav-end .button { display: none; }
|
||||
@@ -426,22 +424,11 @@ figcaption span { font-family: var(--mono); font-size: var(--text-micro); letter
|
||||
|
||||
/* --- Documentation (/docs): a left navigation and one page at a time --------------------- */
|
||||
|
||||
.docs-bar {
|
||||
position: sticky; top: 0; z-index: 20; height: 56px;
|
||||
background: color-mix(in srgb, var(--page) 88%, transparent);
|
||||
-webkit-backdrop-filter: blur(16px) saturate(1.2); backdrop-filter: blur(16px) saturate(1.2);
|
||||
box-shadow: 0 1px 0 var(--rule);
|
||||
}
|
||||
.docs-bar-inner { display: flex; align-items: center; gap: 16px; height: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--g); }
|
||||
.docs-bar-title { padding-left: 16px; border-left: 1px solid var(--rule); color: var(--muted); font-size: var(--text-label); }
|
||||
.docs-bar-end { margin-left: auto; display: flex; align-items: center; gap: 16px; }
|
||||
.docs-bar-link { color: var(--muted); font-size: var(--text-label); }
|
||||
.docs-bar-link:hover { color: var(--ink); }
|
||||
.docs {
|
||||
display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: clamp(32px, 6vw, 96px);
|
||||
max-width: var(--max); margin: 0 auto; padding: 48px var(--g) 0; align-items: start;
|
||||
max-width: var(--max); margin: 0 auto; padding: calc(var(--nav) + 48px) var(--g) 0; align-items: start;
|
||||
}
|
||||
.docs-nav-wrap { position: sticky; top: 80px; max-height: calc(100vh - 104px); overflow-y: auto; padding-bottom: 24px; }
|
||||
.docs-nav-wrap { position: sticky; top: calc(var(--nav) + 24px); max-height: calc(100vh - var(--nav) - 48px); overflow-y: auto; padding-bottom: 24px; }
|
||||
.docs-nav-wrap summary { display: none; }
|
||||
.docs-nav-group { margin: 28px 0 8px; font: var(--text-micro) / var(--text-micro-line) var(--mono); letter-spacing: var(--text-micro-tracking); text-transform: uppercase; color: var(--muted); }
|
||||
.docs-nav-group:first-child { margin-top: 0; }
|
||||
@@ -478,7 +465,7 @@ figcaption span { font-family: var(--mono); font-size: var(--text-micro); letter
|
||||
.docs-main .disclaimer { margin-top: 24px; }
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.docs { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 12px; }
|
||||
.docs { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: calc(var(--nav) + 12px); }
|
||||
.docs-nav-wrap { position: static; max-height: none; overflow: visible; margin-bottom: 24px; border-bottom: 1px solid var(--rule); }
|
||||
.docs-nav-wrap summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 500; list-style: none; }
|
||||
.docs-nav-wrap summary::-webkit-details-marker { display: none; }
|
||||
@@ -486,10 +473,9 @@ figcaption span { font-family: var(--mono); font-size: var(--text-micro); letter
|
||||
.docs-nav-wrap[open] summary::after { content: "\2212"; }
|
||||
.docs-pager { grid-template-columns: minmax(0, 1fr); }
|
||||
.docs-pager-next { grid-column: 1; }
|
||||
.docs-bar-link { display: none; }
|
||||
}
|
||||
@media (pointer: coarse) {
|
||||
.docs-nav li a, .docs-toc a, .docs-bar-title, .docs-bar-link { display: flex; align-items: center; min-height: 44px; }
|
||||
.docs-nav li a, .docs-toc a { display: flex; align-items: center; min-height: 44px; }
|
||||
}
|
||||
|
||||
/* --- Blocks: the launcher's look on the page (docs/design-system.md, "Blocks") -------------
|
||||
@@ -548,7 +534,7 @@ code { border-radius: 0; background: var(--well); box-shadow: 0 0 0 1px var(--ou
|
||||
:focus-visible { border-radius: 0; }
|
||||
|
||||
/* The top bar: the sidebar colour with an outline under it, tabs with an accent underline. */
|
||||
.nav.is-scrolled, .nav.is-menu { background: var(--side); -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: 0 var(--block-outline) 0 var(--outline); }
|
||||
.nav { background: var(--side); -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: 0 var(--block-outline) 0 var(--outline); }
|
||||
.nav-links a, .nav-github, .theme-toggle { border-radius: 0; font-family: var(--pixel); font-weight: 500; font-size: 15px; }
|
||||
.nav-links a:hover, .nav-github:hover, .theme-toggle:hover { background: var(--raised); }
|
||||
.nav-links a[aria-current] { background: var(--raised); box-shadow: inset 0 -3px 0 var(--accent); }
|
||||
@@ -606,7 +592,6 @@ code { border-radius: 0; background: var(--well); box-shadow: 0 0 0 1px var(--ou
|
||||
}
|
||||
|
||||
/* Documentation. */
|
||||
.docs-bar { background: var(--side); -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: 0 var(--block-outline) 0 var(--outline); }
|
||||
.docs-nav li a { border-radius: 0; }
|
||||
.docs-nav li a[aria-current] { background: var(--raised); box-shadow: inset 4px 0 0 var(--accent); }
|
||||
.docs-toc a { border-radius: 0; background: var(--button); box-shadow: 0 0 0 var(--block-outline) var(--outline); }
|
||||
|
||||
Reference in New Issue
Block a user