From 3cbb97fc9e3456b2af3900b415a447863ae5bb21 Mon Sep 17 00:00:00 2001 From: Jad Rizk <29228917+JadRizk@users.noreply.github.com> Date: Fri, 9 Oct 2026 13:30:08 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(showcase):=20a=20Home=20built?= =?UTF-8?q?=20on=20a=20live=20Glitch=20Lab=20monitor;=20=E2=8C=98K=20searc?= =?UTF-8?q?hes=20the=20site?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Home was a three-panel console demo in a 760px box with no headline, no way in, fake sliders and a theme panel duplicating the header. It is now a hero, the routes into the site, and a plain footer. - Hero: the pitch (h1, lede, build-time figures in data-nx-figure spans, Get started / Browse components) beside a CRT running Glitch Lab's own shader pipeline and synthesiser. Each visit lands on a random channel (graph with a fresh layout, bars or HUD). The pointer tunes colour bleed and tracking; Jolt rotates scrub, interference and degauss (the faults that move the picture rather than flash it); Sound voices them, and the room noise fades up while the pointer or focus is on the monitor. The CRT bends, with an overscan so no black shows at the corners. Reduced motion: a still frame, no faults, no sound. Capped at 30 fps and 1x. - Five links (Get started, Tokens, Components, Graph, Glitch Lab) and a borderless footer. - Glitch Lab's engine and synthesiser are split out of GlitchLab.jsx into effects/glitchEngine.js and glitchAudio.js, shared with the hero. Seed 0 and overscan 0 reproduce Glitch Lab's own picture; the engine gains optional fps/dpr caps, a layout seed and a fade on the noise bed. - ⌘K / Ctrl+K and "/" open a site palette on every route (SitePalette.tsx): every page plus the theme and CRT actions, each kind with its own glyph. Theme and CRT left the header; Search is its only control. The palette stands aside on the CommandPalette page, which demonstrates its own. -
scrolls on Home, so it gets the route-change scroll/focus reset. Tests: crt-off, crt-on, console-hud-aa, console-hud and focus-skip-link re-recorded (the hero canvas is masked); the harness drives theme and CRT through the palette; the keyboard-reachability check now covers Home; routing.spec covers the palette; new home.spec.ts covers the monitor. Co-Authored-By: Claude Sonnet 5.5 --- apps/showcase/src/App.tsx | 255 ++- .../showcase/src/components/SignalMonitor.tsx | 278 +++ apps/showcase/src/components/SitePalette.tsx | 126 ++ apps/showcase/src/effects/AUDIO.md | 2 +- apps/showcase/src/effects/GlitchLab.jsx | 1873 +---------------- apps/showcase/src/effects/glitchAudio.js | 335 +++ apps/showcase/src/effects/glitchEngine.js | 1664 +++++++++++++++ apps/showcase/src/pages/HomePage.tsx | 380 +--- apps/showcase/src/showcase.css | 167 ++ browser/__screenshots__/console-hud-aa.png | Bin 69308 -> 69670 bytes browser/__screenshots__/console-hud.png | Bin 61516 -> 62162 bytes browser/__screenshots__/crt-off.png | Bin 69308 -> 69670 bytes browser/__screenshots__/crt-on.png | Bin 271761 -> 252921 bytes browser/__screenshots__/focus-skip-link.png | Bin 7517 -> 7553 bytes browser/a11y.spec.ts | 5 +- browser/harness.ts | 56 +- browser/home.spec.ts | 102 + browser/routing.spec.ts | 35 + browser/states.spec.ts | 23 +- 19 files changed, 3003 insertions(+), 2298 deletions(-) create mode 100644 apps/showcase/src/components/SignalMonitor.tsx create mode 100644 apps/showcase/src/components/SitePalette.tsx create mode 100644 apps/showcase/src/effects/glitchAudio.js create mode 100644 apps/showcase/src/effects/glitchEngine.js create mode 100644 browser/home.spec.ts diff --git a/apps/showcase/src/App.tsx b/apps/showcase/src/App.tsx index bf5bc41..a3b6210 100644 --- a/apps/showcase/src/App.tsx +++ b/apps/showcase/src/App.tsx @@ -8,7 +8,6 @@ import { BlinkCursor, useNexus, } from "@nexus-cyberdeck/react"; -import type { NexusTheme } from "@nexus-cyberdeck/react"; import { HomePage } from "./pages/HomePage.js"; import NexusCyberdeck from "./graph/NexusCyberdeck.js"; import GlitchLab from "./effects/GlitchLab.jsx"; @@ -16,6 +15,7 @@ import { href, useRoute } from "./router.js"; import { DOC_GROUPS, findPage } from "./site.js"; import type { DocPage } from "./site.js"; import { PageHeader } from "./components/Spec.js"; +import { SitePalette, useSitePalette } from "./components/SitePalette.js"; type View = | { kind: "home" } @@ -24,9 +24,9 @@ type View = | { kind: "doc"; page: DocPage } | { kind: "not-found" }; -// Home, Graph and Glitch Lab are self-contained full-viewport "console" -// experiences — docked panels, no page-level padding or scroll. Graph and -// Glitch Lab in particular render their own WebGL surfaces (see README: +// Home, Graph and Glitch Lab are full-bleed: no docs sidebar or page column. +// Graph and Glitch Lab are full-viewport "console" experiences — docked +// panels, no page-level scroll — and render their own WebGL surfaces (see README: // "the graph itself ... is a product, not a design system") and ignore the // site CRT toggle — Glitch Lab especially, since CRT composite is itself // one of its shader effects, not something to layer a second time. Every @@ -71,8 +71,9 @@ function Shell() { const path = useRoute().join("/"); const view = resolve(path); const title = titleOf(view); - const fullBleed = view.kind === "home" || view.kind === "graph" || view.kind === "glitch"; - const { theme, setTheme, crt, setCrt } = useNexus(); + const docked = view.kind === "graph" || view.kind === "glitch"; + // Theme and CRT are switched from the site palette (SitePalette.tsx). + const { crt } = useNexus(); const main = useRef(null); // The route last shown. Null until the first one, which is the document's own // load. Comparing routes rather than counting runs is what keeps StrictMode's @@ -101,149 +102,145 @@ function Shell() { }, [title]); return ( -
- {/* skip link — first tab stop, WCAG 2.4.1 */} - {/* The click is handled here rather than by the browser: the hash + +
+ {/* skip link — first tab stop, WCAG 2.4.1 */} + {/* The click is handled here rather than by the browser: the hash belongs to the router, and following "#main" would navigate to a route called "main". */} - { - e.preventDefault(); - main.current?.focus(); - }} - > - Skip to content - - - {/* A banner landmark: screen-reader users can jump to it, and it gives - the site chrome a name distinct from the theme controls the Home - page renders in its own panel. */} - -
{ + e.preventDefault(); + main.current?.focus(); }} > -
- NEXUS - - DS v{__NX_VERSION__} - -
+ Skip to content + - -
- - THEME - - {(["hud-aa", "hud"] as NexusTheme[]).map((t) => ( - - ))} - +
-
- -
+ + - {/* tabIndex=0 because this element scrolls. A scrollable region that is + {/* tabIndex=0 because this element scrolls. A scrollable region that is not focusable cannot be scrolled by keyboard at all when it holds no focusable content of its own — which is exactly the Tokens page, a long column of swatches with nothing to tab to. It doubles as the skip link's landing target. */} -
's visible height (100cqh) and scroll on its own. - containerType: view.kind === "doc" ? "size" : undefined, - }} - > - {view.kind === "home" && } - {view.kind === "graph" && } - {view.kind === "glitch" && } - {view.kind === "doc" && ( -
- - {/* Sized as the page column was before the sidebar existed: the +
like a docs + // page — which also gives it the scroll reset on navigation. + overflow: docked ? "hidden" : "auto", + // A size container on docs pages, so the sticky sidebar can cap its + // height at
's visible height (100cqh) and scroll on its own. + containerType: view.kind === "doc" ? "size" : undefined, + }} + > + {view.kind === "home" && } + {view.kind === "graph" && } + {view.kind === "glitch" && } + {view.kind === "doc" && ( +
+ + {/* Sized as the page column was before the sidebar existed: the visual baselines capture each example at this width. */} -
- - {/* Mounted as a component, never called as a function: a page's +
+ + {/* Mounted as a component, never called as a function: a page's hooks must belong to the page, or moving between pages with different hooks breaks the shell's own hook order. Keyed by path so each page starts from fresh state. */} - + +
-
- )} - {view.kind === "not-found" && ( -
- -
- )} -
-
+ )} + {view.kind === "not-found" && ( +
+ +
+ )} +
+
+
+ ); +} + +/** + * The site palette's visible way in, for anyone not reaching for ⌘K or "/" — + * and the only control for theme and CRT, which the palette lists first. + */ +function SearchButton() { + const { open } = useSitePalette(); + return ( + ); } diff --git a/apps/showcase/src/components/SignalMonitor.tsx b/apps/showcase/src/components/SignalMonitor.tsx new file mode 100644 index 0000000..3e21a3b --- /dev/null +++ b/apps/showcase/src/components/SignalMonitor.tsx @@ -0,0 +1,278 @@ +import { useEffect, useRef, useState } from "react"; +import type { FocusEvent, PointerEvent } from "react"; +import { Button, Panel } from "@nexus-cyberdeck/react"; +import { configFor, fireEvent, shuffleSeed, useGlitchEngine } from "../effects/glitchEngine.js"; +import { createAudio } from "../effects/glitchAudio.js"; + +/* ============================================================================ + showcase — SignalMonitor + Home's hero: a small CRT running Glitch Lab's own signal path and + synthesiser (effects/glitchEngine.js, effects/glitchAudio.js). The pointer + tunes it — across for colour bleed, down for tracking. Each visit lands on + a channel chosen at random (the graph, with a new layout every time; the + test bars; or the HUD). Jolt fires one of Glitch Lab's faults. + With Sound on, faults are voiced, and the room — tape hiss, mains hum, the + flyback whine — comes up while the pointer or focus is on the monitor. + + Held to the system's own flash rule (WCAG 2.3.1): nothing fires by itself, + one fault runs at a time, and the faults offered are the ones that move + the picture rather than flash it. Under reduced motion the screen is a + still frame that redraws only when it is tuned or changed, and the faults + and the sound are withdrawn with their controls. + + Sound needs the page to have had a press first — browsers allow audio only + after one — so a hover before any press is silent. + ========================================================================== */ + +type Cfg = ReturnType; +type Audio = NonNullable>; + +const CHANNELS = ["GRAPH", "BARS", "HUD"] as const; + +// Faults that displace, ghost or shift colour. Dropout, signal loss, data +// corruption, head crash and cold boot all flash or blank the picture. +const SAFE_FAULTS = ["scrub", "interference", "degauss"] as const; + +const VOLUME = 0.45; +// The room: Glitch Lab's bed with the 15.7 kHz whine kept low, faded so it +// can follow a hover without clicking. +const ROOM = { hiss: 0.4, hum: 0.35, whine: 0.12, fade: 0.25 }; + +/** + * The monitor's resting signal: Glitch Lab's BROADCAST preset, with three + * changes for a screen that sits in a square frame on a page. + * + * - More bend, overscanned. The barrel curve is what reads as a television; + * overscan scales the bent picture out until its corners meet the frame, + * so lines still bow but no black shows past the glass. Degauss's bulge + * overscans with it. + * - Full mix. At BROADCAST's 0.85, 15% of the flat picture showed through + * wherever the bent one did not reach. + * - No hologram flicker. Degauss fades that layer in, and its shader + * otherwise dims at random on a 20 Hz clock; at zero, nothing on this + * screen steps in brightness. + * + * Glitch Lab keeps the preset as it is. + */ +function rest(): Cfg { + const cfg = configFor("BROADCAST"); + Object.assign(cfg["crt"]!, { amt: 1, curve: 0.9, overscan: 1 }); + cfg["holo"]!.flicker = 0; + return cfg; +} + +/** Pointer position, 0–1 on each axis, to the knobs it turns. */ +function tune(x: number, y: number): Cfg { + const cfg = rest(); + Object.assign(cfg["chroma"]!, { on: 1, amt: 0.5 + x * 0.5, width: 4 + x * 20, lag: -2 + x * 12 }); + Object.assign(cfg["tracking"]!, { on: 1, amt: y, shift: y * 0.12, height: 0.06 + y * 0.18 }); + return cfg; +} + +/** Whether the page has had the press browsers require before audio may start. */ +const mayPlay = () => + (navigator as Navigator & { userActivation?: { hasBeenActive: boolean } }).userActivation + ?.hasBeenActive ?? true; + +export function SignalMonitor() { + const hostRef = useRef(null); + const cfgRef = useRef(rest()); + const srcRef = useRef(0); + const seedRef = useRef(0); + const activeRef = useRef([]); + const queueRef = useRef([]); + const stillRef = useRef(false); + const audioRef = useRef