mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-27 07:58:01 +01:00
The page is prerendered as the Mac page and only guesses the visitor's platform in a layout effect, so a browser without scripts claims a Mac, hides the Windows and Linux panels behind inert tabs, and leaves the architecture and package switches dead. A Windows or Linux visitor could not reach an installer. index.html now carries a <noscript> stylesheet that hides the switcher, the demo key, and the detected-platform line, and shows src/Download.tsx's plain list of every OS, architecture, and package under its own label, plus a neutral hero line naming Mac, Windows, and Linux (src/App.tsx). The list is hidden while scripts run and the prerendered markup is unchanged, so hydration and the interactive page are untouched. The list's commands wrap instead of truncating because it has no copy button. Verified with bun run build, bun test, tsc -b and headless Chromium with JavaScript off (Windows x64/ARM64 and Linux links visible, tabs, switches, and keycap hidden) and on (no console errors, layout identical).
42 lines
1.9 KiB
TypeScript
42 lines
1.9 KiB
TypeScript
// The landing page without scripts. index.html's <noscript> stylesheet hides
|
|
// the controls that need them — the OS tabs, the architecture and package
|
|
// switches inside a row, and the demo key — and shows src/Download.tsx's plain
|
|
// list of every platform and variant; src/styles.css keeps that list and the
|
|
// neutral hero line hidden while scripts run. The halves only work while the
|
|
// class names match, and nothing else exercises the scripting-off page.
|
|
import { expect, test } from "bun:test"
|
|
import { readFileSync } from "node:fs"
|
|
|
|
const read = (path: string) => readFileSync(new URL(path, import.meta.url), "utf8")
|
|
|
|
const html = read("./index.html")
|
|
const css = read("./src/styles.css")
|
|
const app = read("./src/App.tsx")
|
|
const download = read("./src/Download.tsx")
|
|
const shout = read("./src/Shout.tsx")
|
|
const noScript = html.match(/<noscript>([\s\S]*?)<\/noscript>/)?.[1] ?? ""
|
|
|
|
test("scripting off hides the inert controls", () => {
|
|
expect(noScript).toMatch(/\.keycap[^}]*display:\s*none\s*!important/)
|
|
expect(noScript).toMatch(/\.install__os[^}]*display:\s*none\s*!important/)
|
|
expect(noScript).toMatch(/\.install__panels[^}]*display:\s*none\s*!important/)
|
|
expect(noScript).toMatch(/\.hero__device[^}]*display:\s*none\s*!important/)
|
|
})
|
|
|
|
test("scripting off shows the plain list and the neutral hero line", () => {
|
|
expect(noScript).toMatch(/\.install__plain\s*{[^}]*display:\s*flex/)
|
|
expect(noScript).toMatch(/\.hero__any\s*{[^}]*display:\s*block/)
|
|
})
|
|
|
|
test("scripts on keep the plain list and the neutral hero line hidden", () => {
|
|
expect(css).toMatch(/\.install__plain\s*{[^}]*display:\s*none/)
|
|
expect(css).toMatch(/\.hero__any\s*{[^}]*display:\s*none/)
|
|
})
|
|
|
|
test("every class the swap names is on the page", () => {
|
|
expect(shout).toContain("keycap")
|
|
for (const name of ["install__os", "install__panels", "install__plain"]) {
|
|
expect(download).toContain(name)
|
|
}
|
|
for (const name of ["hero__device", "hero__any"]) expect(app).toContain(name)
|
|
})
|