Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/design-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Pages swap in place: the old page fades out and the new one in (React's `<ViewTr
Links never prefetch, whether in view or hovered (lead's choice, 2026-10-19). A page loads only once it's opened, and the fade covers the wait. `e2e/navigation.e2e.ts` checks that following a link doesn't reload the page.

## Layout shell (`web/src/features/site/`)
Header, page and footer sit on the sheet. The header is one sticky bar: wordmark, sections, search (`/`), Steam sign-in; footer: one line, community logos. Phones: menu, wordmark, search, account. Account and current section sit in `<Suspense>`, so every shell stays static. Search lives on the Players page.
Header, page and footer sit on the sheet. The header is one sticky bar: wordmark, sections, search (`/`), Discord, Steam sign-in; footer: one line, community logos. Phones: wordmark, search, account, menu. Account and current section sit in `<Suspense>`, so every shell stays static. Search lives on the Players page.

## Screenshot tests
`npm run test:ui` (part of `just check`) screenshots `/dev/ui` wide, on a phone, with the menu open and with the dialog open, and fails on any pixel change. After an intended visual change:
Expand Down
25 changes: 25 additions & 0 deletions web/e2e/navigation.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,28 @@ test("styles switch in place, and a run opens in a dialog without leaving the pa
await page.evaluate(() => (window as { stillHere?: boolean }).stillHere),
).toBe(true);
});

test("the shared header stays seamless at the top and becomes fixed with blur on every route", async ({
page,
}) => {
let footer = "";
for (const route of ["/", "/maps", "/players"]) {
await page.goto(route);
const header = page.getByRole("banner");
await expect(header).toHaveCount(1);
await expect(header).toHaveAttribute("data-scrolled", "false");
await expect(header).toHaveCSS("background-color", "rgba(0, 0, 0, 0)");
const mark = header.getByRole("link", { name: "SourceJump", exact: true });
await expect(mark).toHaveText("SOURCEJUMP");
expect(
await mark.evaluate((e) => getComputedStyle(e).fontFamily),
).toContain("Play");
const text = await page.getByRole("contentinfo").innerText();
if (footer) expect(text).toBe(footer);
footer = text;
await page.evaluate(() => scrollTo(0, 400));
await expect(header).toHaveAttribute("data-scrolled", "true");
await expect(header).toHaveCSS("backdrop-filter", "blur(18px)");
expect((await header.boundingBox())!.y).toBe(0);
}
});
Binary file modified web/e2e/style-guide.e2e.ts-snapshots/desktop-chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web/e2e/style-guide.e2e.ts-snapshots/dialog-chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web/e2e/style-guide.e2e.ts-snapshots/menu-chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web/e2e/style-guide.e2e.ts-snapshots/phone-chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions web/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/* Taps show the site's own pressed and hover states, not the browser's grey flash, and act without the
double-tap zoom delay. */
html {
--site-header-height: 80px;
-webkit-tap-highlight-color: transparent;
}
a,
Expand Down Expand Up @@ -49,3 +50,14 @@
background: var(--color-accent-soft);
}
}

@media (max-width: 900px) {
html {
--site-header-height: 68px;
}
}
@media (max-width: 600px) {
html {
--site-header-height: 64px;
}
}
11 changes: 8 additions & 3 deletions web/src/features/site/HeaderSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,14 @@ export function HeaderSearch() {
setActive(-1);
}

function go(href: string) {
function leave() {
close();
setExpanded(false);
input.current?.blur();
}

function go(href: string) {
leave();
router.push(href);
}

Expand Down Expand Up @@ -338,7 +343,7 @@ export function HeaderSearch() {
id={optionId(index)}
href={targets[index]!}
active={active === index}
onPick={close}
onPick={leave}
picture={
<Avatar
name={player.name}
Expand Down Expand Up @@ -373,7 +378,7 @@ export function HeaderSearch() {
id={optionId(index)}
href={targets[index]!}
active={active === index}
onPick={close}
onPick={leave}
picture={
map.image ? (
// eslint-disable-next-line @next/next/no-img-element -- the API serves the thumbnail at its size
Expand Down
52 changes: 52 additions & 0 deletions web/src/features/site/HeaderShell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"use client";

import { useEffect, useRef, type ReactNode } from "react";
import styles from "./SiteHeader.module.css";

export function HeaderShell({ children }: { children: ReactNode }) {
const header = useRef<HTMLElement>(null);
useEffect(() => {
const element = header.current!;
const scroll = () => {
element.dataset.scrolled = String(scrollY > 16);
};
function dismiss(event: PointerEvent) {
const menu = element.querySelector<HTMLDetailsElement>("details[open]");
if (menu && event.target instanceof Node && !menu.contains(event.target))
menu.open = false;
}
function escape(event: KeyboardEvent) {
if (event.key !== "Escape") return;
const menu = element.querySelector<HTMLDetailsElement>("details[open]");
if (menu) {
menu.open = false;
menu.querySelector("summary")?.focus();
}
}
scroll();
window.addEventListener("scroll", scroll, { passive: true });
document.addEventListener("pointerdown", dismiss);
document.addEventListener("keydown", escape);
return () => {
window.removeEventListener("scroll", scroll);
document.removeEventListener("pointerdown", dismiss);
document.removeEventListener("keydown", escape);
};
}, []);
return (
<header
ref={header}
className={styles.header}
style={{ viewTransitionName: "site-header" }}
onClick={(event) => {
if (event.target instanceof Element && event.target.closest("a")) {
const menu =
header.current?.querySelector<HTMLDetailsElement>("details[open]");
if (menu) menu.open = false;
}
}}
>
{children}
</header>
);
}
Loading