Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
46c56ab
Copy design system v121: one header, footer, and theme for every surface
lwwmanning Nov 4, 2026
6ad0f4e
Give the site and bench one header, footer, 404, favicon, and theme
lwwmanning Nov 4, 2026
cfe59f9
Keep the home page and the 404s Dark, and fit bench to the site's frame
lwwmanning Nov 4, 2026
f4bb4a8
Let the home page and the 404s follow the theme again
lwwmanning Nov 4, 2026
86ef802
Show the home page's dot field behind the 404 and the blog
lwwmanning Nov 4, 2026
ddec6d3
Fade the dot field toward every edge and keep it out of the blog's te…
lwwmanning Nov 4, 2026
5f3b748
Keep the blog's margin dots at full strength
lwwmanning Nov 4, 2026
de0cde6
Take the dot field off the blog; keep it on the 404
lwwmanning Nov 4, 2026
34a5893
Draw the mark's pointer trail in two blues in Light, as in Dark
lwwmanning Nov 4, 2026
98938c9
Make the trail's core the lighter blue in Light, as in Dark
lwwmanning Nov 4, 2026
b241d89
Copy the design system's DotField move into chrome
lwwmanning Nov 4, 2026
4871605
Fit the footer's small print in two lines on a wide screen
lwwmanning Nov 4, 2026
3270a8f
Fit the hero to the shared header, and test the theme on every page
lwwmanning Nov 4, 2026
c79d56a
Keep a theme chosen on bench before the shared switch
lwwmanning Nov 4, 2026
979559e
Default every page to Dark until a reader chooses a theme
lwwmanning Nov 4, 2026
5eec3bd
Copy a stored theme choice into the shared cookie, and keep bench's o…
lwwmanning Nov 4, 2026
a24742e
Give bench's 404 one h1, its code
lwwmanning Nov 4, 2026
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
3 changes: 1 addition & 2 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ path = [
"src/assets/vortex_wordmark_dark_theme.svg",
"public/bench/Vortex_Black_NoBG.svg",
"public/bench/Vortex_White_NoBG.svg",
"public/bench/icon-dark.png",
"public/bench/icon-light.png",
"public/bench/favicon.ico",
]
SPDX-FileCopyrightText = "Copyright the Vortex contributors"
SPDX-License-Identifier = "CC-BY-4.0"
Expand Down
Binary file added public/bench/favicon.ico
Binary file not shown.
Binary file removed public/bench/icon-dark.png
Binary file not shown.
Binary file removed public/bench/icon-light.png
Binary file not shown.
5 changes: 2 additions & 3 deletions src/app/(bench)/bench/[...notFound]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import { notFound } from 'next/navigation';
/**
* Every bench URL no other bench route matches. The app has two root layouts,
* and an unmatched URL gets the marketing site's 404 (src/app/global-not-found.tsx).
* This route keeps bench's unmatched paths out of the site's 404. bench has no
* not-found.tsx, so Next.js answers with its default 404 document: it carries
* bench's metadata, but not bench's layout, header, or `lang`.
* This route keeps bench's unmatched paths out of the site's 404: they get
* bench's not-found.tsx, the same 404 body in bench's layout.
*/
export default function UnmatchedBenchPath(): never {
notFound();
Expand Down
55 changes: 29 additions & 26 deletions src/app/(bench)/bench/layout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ vi.mock('@/styles/vortex.css', () => ({}));
// The site's footer, as a stand-in that shows the props bench gives it. Each page renders the
// header (BenchHeader), because the filter dropdown takes the page's data.
vi.mock('@/components/layout/footer', () => ({
Footer: ({ origin, solid }: { origin: string; solid: boolean }) =>
createElement('footer', { 'data-origin': origin, 'data-solid': String(solid) }),
Footer: ({ origin }: { origin: string }) => createElement('footer', { 'data-origin': origin }),
}));
// next/font is a build step; its classes set the design system's --vx-face-* variables.
vi.mock('@/lib/fonts', () => ({ FONT_CLASSES: 'face-sans face-mono' }));
Expand All @@ -31,40 +30,54 @@ vi.mock('next/headers', () => ({ headers: async () => requestHeaders }));
const html = renderToStaticMarkup(await RootLayout({ children: createElement('main') }));

/** Load the layout's markup in a browser-like document, scripts on or off. */
function load(runScripts: boolean, theme?: string): Document {
function load(runScripts: boolean, theme?: string, cookie?: string, prefersDark = true): Document {
return new JSDOM(`<!DOCTYPE html>${html}`, {
url: 'https://bench.vortex.dev/',
...(runScripts ? { runScripts: 'dangerously' as const } : {}),
beforeParse(window) {
// jsdom has no matchMedia: an OS set to Dark, unless the test says Light.
Object.assign(window, { matchMedia: () => ({ matches: prefersDark }) });
if (theme !== undefined) {
window.localStorage.setItem('bench-theme', theme);
window.localStorage.setItem('vx-theme', theme);
}
if (cookie !== undefined) {
window.document.cookie = cookie;
}
},
}).window.document;
}

describe('RootLayout', () => {
it('renders the root as no-js, which only a script swaps for js', () => {
expect(html).toMatch(/^<html lang="en" data-theme="system" class="no-js /);
expect(html).toMatch(/^<html lang="en" data-theme="dark" class="no-js /);
expect(load(false).documentElement.classList.contains('no-js')).toBe(true);
expect(load(true).documentElement.classList.contains('js')).toBe(true);
expect(load(true).documentElement.classList.contains('no-js')).toBe(false);
});

it('still applies a stored theme before first paint', () => {
const doc = load(true, 'dark');
it('applies a stored theme before first paint', () => {
const doc = load(true, 'light');
expect(doc.documentElement.classList.contains('js')).toBe(true);
expect(doc.documentElement.dataset.theme).toBe('dark');
expect(doc.documentElement.dataset.theme).toBe('light');
});

// The choice made on vortex.dev, the docs or the Explorer holds here (design system DECISIONS 37).
it('applies the choice that the vortex.dev cookie shares before storage', () => {
expect(load(true, 'dark', 'vx-theme=light').documentElement.dataset.theme).toBe('light');
});

it("self-hosts the system's faces, as the site does, with no request to Google Fonts", () => {
expect(load(false).documentElement.className).toBe('no-js face-sans face-mono');
expect(html).not.toMatch(/googleapis|gstatic/);
});

it('follows the OS until a reader chooses a theme', () => {
expect(load(true).documentElement.dataset.theme).toBe('system');
expect(load(false).documentElement.dataset.theme).toBe('system');
// Will, 4 Nov 2026: "shared cookie should be respected! but if no other info, dark" (design
// system DECISIONS 43).
it('is Dark until a reader chooses a theme, even when the OS prefers Light', () => {
const page = load(true, undefined, undefined, false);
expect(page.documentElement.dataset.theme).toBe('dark');
expect(page.documentElement.dataset.themeChoice).toBe('dark');
expect(load(false).documentElement.dataset.theme).toBe('dark');
});
});

Expand All @@ -80,9 +93,9 @@ describe("the layout's skip link", () => {
});

describe("the layout's frame", () => {
it("puts every page above the site's footer, pointed at the site, with a solid rule", () => {
it("puts every page above the site's one footer, pointed at the site", () => {
expect(html).toMatch(
/<div class="bench-frame"><main><\/main><footer data-origin="https:\/\/vortex.dev" data-solid="true"><\/footer><\/div>/,
/<div class="bench-frame"><main><\/main><footer data-origin="https:\/\/vortex.dev"><\/footer><\/div>/,
);
});
});
Expand All @@ -92,27 +105,17 @@ describe("the layout's icons", () => {
requestHeaders.set('host', host);
try {
const { icons } = await generateMetadata();
return JSON.stringify(icons).match(/"url":"[^"]*"|"apple":"[^"]*"/g);
return JSON.stringify(icons).match(/"url":"[^"]*"/g);
} finally {
requestHeaders.set('host', 'bench.vortex.dev');
}
};

it('are at the root of bench.vortex.dev', async () => {
expect(await iconUrls('bench.vortex.dev')).toEqual([
'"url":"/icon-light.png"',
'"url":"/icon-dark.png"',
'"url":"/icon-dark.png"',
'"apple":"/icon-dark.png"',
]);
expect(await iconUrls('bench.vortex.dev')).toEqual(['"url":"/favicon.ico"']);
});

it('are under /bench on any other host', async () => {
expect(await iconUrls('localhost:3000')).toEqual([
'"url":"/bench/icon-light.png"',
'"url":"/bench/icon-dark.png"',
'"url":"/bench/icon-dark.png"',
'"apple":"/bench/icon-dark.png"',
]);
expect(await iconUrls('localhost:3000')).toEqual(['"url":"/bench/favicon.ico"']);
});
});
53 changes: 16 additions & 37 deletions src/app/(bench)/bench/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import { benchPath } from '@/bench/lib/base-path';
import { requestBenchBase } from '@/bench/lib/request-base';
import { BENCH_DESCRIPTION, BENCH_URL, openGraph } from '@/bench/lib/site-files';
import { Footer } from '@/components/layout/footer';
import { RouteTheme } from '@/components/route-theme';
import { FONT_CLASSES } from '@/lib/fonts';
import { BENCH_THEME_BOOTSTRAP } from '@/lib/theme';

// The Vortex design system's colour roles and scales, which globals.css reads,
// and its components, for the site's header and footer.
Expand All @@ -26,17 +28,10 @@ export async function generateMetadata(): Promise<Metadata> {
// in full. No `metadataBase`: it would also resolve the icons' paths, which
// belong to the host serving the page, against bench.vortex.dev.
openGraph: openGraph('Benchmarks | Vortex', BENCH_DESCRIPTION, `${BENCH_URL}/`),
// Theme-aware favicons, ported from `render.rs::favicon_links`: the black
// sigil on light-mode tabs, the white sigil on dark-mode tabs, with the dark
// sigil as the unmediated fallback (and the apple-touch icon). The files are
// in public/bench: the root of bench.vortex.dev.
// The site's favicon (the system's DECISIONS 36: one set on every
// surface), copied into public/bench, the root of bench.vortex.dev.
icons: {
icon: [
{ url: benchPath(base, '/icon-light.png'), media: '(prefers-color-scheme: light)' },
{ url: benchPath(base, '/icon-dark.png'), media: '(prefers-color-scheme: dark)' },
{ url: benchPath(base, '/icon-dark.png') },
],
apple: benchPath(base, '/icon-dark.png'),
icon: { url: benchPath(base, '/favicon.ico'), sizes: '256x256', type: 'image/x-icon' },
},
};
}
Expand All @@ -46,25 +41,13 @@ export const viewport: Viewport = {
initialScale: 1,
};

// The pre-paint bootstrap. Its first statement swaps the root's server-rendered
// `no-js` class for `js`, so `.no-js [data-requires-js]` (globals.css) hides
// the controls that do nothing without JavaScript only when no script runs.
// The rest is ported verbatim from `render.rs::theme_bootstrap_script`: apply
// any stored theme choice before first paint so a dark-mode visitor never
// flashes the light theme. Inline (not a module) and in `<head>` so it runs
// before the body renders, and a constant that builds no code from a value.
// The class and the stored theme (a `data-theme` attribute) differ from what
// the server rendered, so the root `<html>` carries `suppressHydrationWarning`
// (attribute-level, one element deep) to keep dev hydration checks quiet. The
// theme part's bare catch is deliberate and v3-byte-identical: localStorage
// access throws in some private-browsing modes, and the correct fallback is
// silently keeping the default prefers-color-scheme theme.
const THEME_BOOTSTRAP =
'(function(){' +
'document.documentElement.className=document.documentElement.className.replace("no-js","js");' +
'try{var t=localStorage.getItem("bench-theme");if(t==="light"||t==="dark"){document.documentElement.dataset.theme=t;}}catch(e){}' +
'})();';

// The pre-paint bootstrap, the site's (`lib/theme.ts`): its first statement
// swaps the root's server-rendered `no-js` class for `js`, so `.no-js
// [data-requires-js]` (globals.css) hides the controls that do nothing without
// JavaScript only when no script runs. The rest sets the reader's theme from
// the `vx-theme` cookie that vortex.dev's subdomains share (else storage, else
// Dark) before first paint. The class and the theme differ from what the
// server rendered, so the root `<html>` carries `suppressHydrationWarning`.
/**
* Root layout: the `<html>`/`<body>` shell plus the global stylesheet, the
* pre-paint theme bootstrap, and the design system's faces, self-hosted as the
Expand All @@ -78,17 +61,13 @@ const THEME_BOOTSTRAP =
export default async function RootLayout({ children }: { children: ReactNode }) {
const base = await requestBenchBase();
return (
<html
lang="en"
data-theme="system"
className={`no-js ${FONT_CLASSES}`}
suppressHydrationWarning
>
<html lang="en" data-theme="dark" className={`no-js ${FONT_CLASSES}`} suppressHydrationWarning>
<head>
{/* biome-ignore lint/security/noDangerouslySetInnerHtml: a constant script that sets the theme before first paint. */}
<script dangerouslySetInnerHTML={{ __html: THEME_BOOTSTRAP }} />
<script dangerouslySetInnerHTML={{ __html: BENCH_THEME_BOOTSTRAP }} />
</head>
<body>
<RouteTheme />
{/* The first tab stop. Each page's <main> has the id and takes focus
(tabIndex -1). A fragment-only href works on either base. */}
<a className="vx-skip-link" href="#main">
Expand All @@ -97,7 +76,7 @@ export default async function RootLayout({ children }: { children: ReactNode })
<BenchBaseProvider base={base}>
<div className="bench-frame">
{children}
<Footer origin="https://vortex.dev" solid />
<Footer origin="https://vortex.dev" />
</div>
</BenchBaseProvider>
</body>
Expand Down
37 changes: 37 additions & 0 deletions src/app/(bench)/bench/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

import type { Metadata } from 'next';

import { BenchHeader } from '@/bench/components/BenchHeader';
import { NotFoundStatus } from '@/components/not-found';

const TITLE = 'Page not found | Vortex';
const SENTENCE = 'There is no page at this address.';

// The site's 404 metadata (src/app/(site)/not-found.tsx). The Open Graph
// object replaces the layout's, so the page has no og:url: a missing page is
// not bench's home.
export const metadata: Metadata = {
title: TITLE,
description: SENTENCE,
openGraph: { title: TITLE, description: SENTENCE, siteName: 'Vortex', type: 'website' },
};

/**
* bench's 404, for the paths the catch-all route hands to `notFound()`: the
* site's 404 body, in bench's layout under the shared header, with a 404
* status. The 404's code is the page's one h1, so the header leaves out its
* own. Its links point back to vortex.dev, because bench is served from its
* own host.
*/
export default function BenchNotFound() {
return (
<>
<BenchHeader heading={false} />
<main id="main" tabIndex={-1} className="bench-status">
<NotFoundStatus origin="https://vortex.dev" />
</main>
</>
);
}
6 changes: 6 additions & 0 deletions src/app/(site)/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
:root[data-theme="light"] .ascii-mark-still {
filter: invert(1);
}
/* With no script the root stays "system", which follows the OS. */
@media (prefers-color-scheme: light) {
:root[data-theme="system"] .ascii-mark-still {
filter: invert(1);
}
}

/* ------------------------------------------------------------------ blog
The blog's page frame, and the parts the design system has no card for. */
Expand Down
5 changes: 3 additions & 2 deletions src/app/(site)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ export default function RootLayout({
</>
);

// Dark is the server-rendered default; THEME_BOOTSTRAP corrects it before
// first paint on the blog, so React must not flag the attribute it changed.
// Dark is the server-rendered default, as it is the default choice;
// THEME_BOOTSTRAP sets the reader's choice before first paint, so React must
// not flag the attribute it changed.
// It also swaps `no-js` for `js` first, so controls that need JavaScript
// hide only when no script runs (globals.css).
return (
Expand Down
33 changes: 3 additions & 30 deletions src/app/(site)/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Metadata } from "next";
import NextLink from "next/link";
import { AsciiMark } from "@/components/ascii-mark";
import { NotFoundStatus } from "@/components/not-found";

const TITLE = "Page not found | Vortex";
// The page's description for search and link previews. The page itself
Expand All @@ -22,33 +21,7 @@ export const metadata: Metadata = {
}
};

/**
* The 404 page: the design system's Status card with the mark. The words
* follow Writing › Site errors. It is Dark, as every page outside the blog
* is. Under /blog it follows the reader's theme, and the mark draws in Light
* too.
*/
/** The 404 page: the body every surface shares (`NotFoundStatus`). */
export default function NotFound() {
return (
<div className="vx-status has-mark">
<div className="vx-status-text">
<h1 className="vx-status-code">404</h1>
<p className="vx-status-sentence">Page not found.</p>
<div className="vx-btn-row">
<NextLink className="vx-btn vx-btn-primary" href="/">
Go to the homepage
</NextLink>
<a className="vx-btn vx-btn-secondary" href="https://docs.vortex.dev">
Read the docs
</a>
<NextLink className="vx-btn vx-btn-secondary" href="/blog">
Read the blog
</NextLink>
</div>
</div>
<div className="vx-status-mark">
<AsciiMark />
</div>
</div>
);
return <NotFoundStatus />;
}
4 changes: 2 additions & 2 deletions src/app/(site)/page.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@

/* Corners: from 1240px the install box (480px) and the table (about 620px)
fit side by side under the mark. The hero takes the screen the header
(64px and its 16px margin) leaves, and the mark fills all of it. */
(64px) leaves, and the mark fills all of it. */
@media (min-width: 1240px) {
.hero {
display: block;
height: calc(100dvh - 80px);
height: calc(100dvh - 64px);
min-height: 680px;
padding: 0;
}
Expand Down
5 changes: 2 additions & 3 deletions src/app/global-not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import { alt, contentType, size } from "./(site)/opengraph-image";
// has no single layout to compose an unmatched URL's 404 from; this file
// (next.config.mjs `experimental.globalNotFound`) is that page, prerendered
// once like the site's 404 always was. bench's own unmatched paths never
// reach it: `(bench)/bench/[...notFound]` catches them. bench has no
// not-found.tsx, so Next.js answers those with its default 404 document,
// which carries bench's metadata but not its layout.
// reach it: `(bench)/bench/[...notFound]` catches them, and bench's
// not-found.tsx draws the same body in bench's layout.
//
// The metadata merges as Next.js merges a page's into its layout's: each
// top-level field of the 404's replaces the layout's. Next.js adds the
Expand Down
Loading
Loading