From be8f54af03775809c027687d7e6a63b5660ba5c0 Mon Sep 17 00:00:00 2001 From: "Craig C." Date: Wed, 18 Nov 2026 22:33:41 +0200 Subject: [PATCH 1/2] feat(site): Settings gear with volume, and sound for Huginn and the sky MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The header gets the GMT docs' Settings gear, last after GitHub and Discord. Its panel holds the mute button and an 11-notch volume fader. The choice is GMT's own `dox:sound` record, so it carries between the two sites. Sound is off until the reader turns it on. With sound on: - Huginn's wingbeats play in time with the drawn wing. The worker posts each downstroke as it starts, and the page puts it on the audio clock for the frame that shows it. He glides, soars and rolls audibly, is placed in 3D, slows and deepens near the camera, and fades steeply with distance. - Each box the aurora draws in plays a faint rustle, panned to the box. - A very light breeze plays under the sky, different for Ísafjörður and Helsinki. Nothing in it repeats on a cycle. - Every link and button plays a soft, distant sonar ping. A link that leaves the page waits for it. - The panel slides in and out, and the mute button and fader have GMT's snap and tick. The panel, fader and toggle-button styles move into @northguild/theme. The voices were picked from context/reference/huginn-sound-audition.html, which stays as the reference. Closes #27. --- apps/site/src/components/Aurora.astro | 50 +- apps/site/src/components/Header.astro | 184 +- apps/site/src/layouts/Base.astro | 17 + apps/site/src/scripts/aurora.raven.ts | 85 +- apps/site/src/scripts/aurora.worker.ts | 104 +- apps/site/src/scripts/sound/control.ts | 87 + apps/site/src/scripts/sound/cue.ts | 179 ++ apps/site/src/scripts/sound/engine.ts | 247 ++ apps/site/src/scripts/sound/huginn.ts | 319 ++ apps/site/src/scripts/sound/kit.ts | 291 ++ apps/site/src/scripts/sound/link-hold.ts | 74 + apps/site/src/scripts/sound/settings.ts | 123 + apps/site/src/scripts/sound/voices.ts | 133 + apps/site/src/scripts/sound/wind.ts | 268 ++ context/reference/huginn-sound-audition.html | 2878 ++++++++++++++++++ packages/theme/README.md | 3 + packages/theme/primitives.css | 272 ++ packages/theme/tokens.css | 21 + 18 files changed, 5305 insertions(+), 30 deletions(-) create mode 100644 apps/site/src/scripts/sound/control.ts create mode 100644 apps/site/src/scripts/sound/cue.ts create mode 100644 apps/site/src/scripts/sound/engine.ts create mode 100644 apps/site/src/scripts/sound/huginn.ts create mode 100644 apps/site/src/scripts/sound/kit.ts create mode 100644 apps/site/src/scripts/sound/link-hold.ts create mode 100644 apps/site/src/scripts/sound/settings.ts create mode 100644 apps/site/src/scripts/sound/voices.ts create mode 100644 apps/site/src/scripts/sound/wind.ts create mode 100644 context/reference/huginn-sound-audition.html diff --git a/apps/site/src/components/Aurora.astro b/apps/site/src/components/Aurora.astro index 5473efa..a55f5bc 100644 --- a/apps/site/src/components/Aurora.astro +++ b/apps/site/src/components/Aurora.astro @@ -162,6 +162,8 @@ import "@northguild/theme/tokens-aurora.css"; SkyLine, WorkerMessage, } from "../scripts/aurora.worker"; + import { cue, HUGINN_EVENT, PLACE_EVENT } from "../scripts/sound/cue"; + import { onSoundChange, readSound } from "../scripts/sound/settings"; // Order matches what the worker destructures. const TOKENS = [ @@ -203,6 +205,12 @@ import "@northguild/theme/tokens-aurora.css"; // The part of the popover under the switcher, which scrolls. const details = document.querySelector(".sky-info-body"); function showChosenSite(): void { + // The place drawn, for the air the sound plays under it. + const place = ids[site] ?? ""; + if (document.documentElement.dataset.skySite !== place) { + document.documentElement.dataset.skySite = place; + document.dispatchEvent(new CustomEvent(PLACE_EVENT)); + } sections.forEach((el, i) => (el.hidden = i !== site)); choices.forEach((button, i) => button.setAttribute("aria-pressed", String(i === site)), @@ -263,10 +271,12 @@ import "@northguild/theme/tokens-aurora.css"; } let lastAngle = 135; // Sweep the pane in toward `angle` (a CSS gradient angle), drifting a - // little along his line, over `duration` seconds. - function brushPane(i: number, angle: number, duration: number): void { + // little along his line, over `duration` seconds. Returns whether it did. + function brushPane(i: number, angle: number, duration: number): boolean { const el = panes[i]; - if (!el || !isAwaiting() || el.classList.contains("ng-brushed")) return; + if (!el || !isAwaiting() || el.classList.contains("ng-brushed")) { + return false; + } lastAngle = angle; const a = (angle * Math.PI) / 180; const [dx, dy] = [Math.sin(a), -Math.cos(a)]; @@ -292,6 +302,23 @@ import "@northguild/theme/tokens-aurora.css"; el.style.setProperty("--ng-dy", Math.max(dy, -roomY).toFixed(3)); el.style.setProperty("--ng-brush-duration", `${duration}s`); el.classList.add("ng-brushed"); + return true; + } + // The draw-in's sound (Silk rustle, scripts/sound/voices.ts): the aurora's + // faint rustle over the sweep, panned to the box and drifting the way the + // light crosses it. Only for his own brushes: a pane painted in by the + // safety net, or all at once, is silent. + function brushSound(i: number, angle: number, duration: number): void { + const el = panes[i]; + if (!el) return; + const r = el.getBoundingClientRect(); + const middle = (r.left + r.width / 2) / (innerWidth || 1); + cue("brush", i, { + duration, + kind: targetKind(el), + pan: Math.min(1, Math.max(-1, (middle - 0.5) * 1.6)), + drift: Math.sign(Math.sin((angle * Math.PI) / 180)), + }); } // His flight draws the panes in. This is only a safety net for a stalled // or slow worker: on a first visit late enough never to start a pane ahead @@ -347,11 +374,24 @@ import "@northguild/theme/tokens-aurora.css"; }, [offscreen], ); + // Huginn's sounds come only while the reader has sound on. + sendToWorker({ type: "sound", on: !readSound().muted }); + onSoundChange((settings) => + sendToWorker({ type: "sound", on: !settings.muted }), + ); worker.onmessage = ({ data }: MessageEvent) => { if (typeof data === "object") { - if ("brush" in data) { + if ("huginn" in data) { + document.dispatchEvent( + new CustomEvent(HUGINN_EVENT, { detail: data.huginn }), + ); + } else if ("brush" in data) { + const angle = data.angle ?? 135; + const duration = data.duration ?? 1; if (data.brush < 0) showAllPanes(); - else brushPane(data.brush, data.angle ?? 135, data.duration ?? 1); + else if (brushPane(data.brush, angle, duration)) { + brushSound(data.brush, angle, duration); + } } else if ("pick" in data) { showPick(data.pick); } else if ("times" in data) { diff --git a/apps/site/src/components/Header.astro b/apps/site/src/components/Header.astro index 2cd37ca..1ed6454 100644 --- a/apps/site/src/components/Header.astro +++ b/apps/site/src/components/Header.astro @@ -26,25 +26,110 @@ const links = [ data-ng-target={entrance ? "header" : undefined} >
NorthGuild
- + + + + + + + + + + + diff --git a/apps/site/src/layouts/Base.astro b/apps/site/src/layouts/Base.astro index 950c886..87e2fc6 100644 --- a/apps/site/src/layouts/Base.astro +++ b/apps/site/src/layouts/Base.astro @@ -77,6 +77,23 @@ const ogAlt = type="font/woff2" crossorigin /> + { entrance && import.meta.env.DEV && ( + + diff --git a/packages/theme/README.md b/packages/theme/README.md index f4c09ca..2bb0977 100644 --- a/packages/theme/README.md +++ b/packages/theme/README.md @@ -36,5 +36,8 @@ NorthGuild's own. - `.gmt-sonar-loop`: the same ping on a permanent loop. - `.gmt-field`: bevelled text input. - `.gmt-button`: small bevelled button. +- `.gmt-panel`: a `[popover]` panel that slides and fades in and out with a sheen. +- `.gmt-toggle-button`: small bevelled button lit while `aria-pressed="true"`. +- `.gmt-fader`: an 11-notch volume fader on ``; set `--gmt-range-pct`. A `prefers-reduced-motion` reset collapses all animation and transition time. diff --git a/packages/theme/primitives.css b/packages/theme/primitives.css index 3776c19..bd6143b 100644 --- a/packages/theme/primitives.css +++ b/packages/theme/primitives.css @@ -311,6 +311,278 @@ } +/* + * Source: apps/dox/src/styles/gmt-primitives.css lines 484-551 (native panels), + * apps/dox/src/widgets/primitives/range/range.module.css (the fader) and + * apps/dox/src/widgets/builders/button.module.css (the pressed button) + * (gmt commit 458860e7730d714b90c63768d9e9758dd1025c01). Made classes here + * where the docs use CSS modules. + */ + +/* ---- Panel ---- + * A popover panel: bevelled, on the raised surface, coming and going with a + * short move and a fade over 240 ms on the sweep curve, one band of ice + * light crossing it each way. Put it on a `[popover]`. Closing keeps it shown, + * and in the top layer, until the fade ends. `--gmt-panel-from` is where it + * comes from, half a rem above by default. + */ +.gmt-panel { + box-sizing: border-box; + margin: 0; + padding: 1rem; + border: 1px solid var(--gmt-border); + border-radius: var(--gmt-bevel-md); + corner-shape: bevel; + background: var(--gmt-surface-2); + color: var(--gmt-ice); + font-size: var(--gmt-text-sm); + overflow: visible; + opacity: 0; + translate: var(--gmt-panel-from, 0 -0.5rem); + transition: + opacity var(--gmt-duration-med) var(--gmt-ease-sweep), + translate var(--gmt-duration-med) var(--gmt-ease-sweep), + display var(--gmt-duration-med) allow-discrete, + overlay var(--gmt-duration-med) allow-discrete; +} + +/* The sheen, over the content and never in the way of a press. Closed, the + animation has another name, so each open and each close starts it again. */ +.gmt-panel::after { + position: absolute; + inset: 0; + border-radius: inherit; + corner-shape: inherit; + content: ""; + pointer-events: none; + background-image: var(--gmt-sheen); + background-repeat: no-repeat; + background-size: 250% 100%; + background-position: 110% 0; + animation: gmt-panel-sheen-out var(--gmt-duration-med) ease-in-out; +} + +.gmt-panel:popover-open { + opacity: 1; + translate: 0 0; +} + +@starting-style { + .gmt-panel:popover-open { + opacity: 0; + translate: var(--gmt-panel-from, 0 -0.5rem); + } +} + +.gmt-panel:popover-open::after { + animation-name: gmt-panel-sheen; +} + +@keyframes gmt-panel-sheen { + from { + background-position: -10% 0; + } +} + +@keyframes gmt-panel-sheen-out { + from { + background-position: -10% 0; + } +} + +@media (prefers-reduced-motion: reduce) { + .gmt-panel { + --gmt-panel-from: 0 0; + } + .gmt-panel::after { + animation: none; + } +} + +@media (forced-colors: active), (prefers-contrast: more) { + .gmt-panel::after { + display: none; + } +} + +@media (forced-colors: active) { + .gmt-panel { + border-color: CanvasText; + background: Canvas; + color: CanvasText; + } +} + +/* ---- Toggle button ---- + * A small bevelled button that holds a state (`aria-pressed`), lit while + * pressed. Sized by the caller; an icon alone sits centred. + */ +.gmt-toggle-button { + appearance: none; + box-sizing: border-box; + display: inline-flex; + align-items: center; + justify-content: center; + min-inline-size: var(--gmt-target-min); + min-block-size: var(--gmt-target-min); + padding: 0; + border: 1px solid var(--gmt-hairline); + border-radius: var(--gmt-radius-sm); + corner-shape: bevel; + background-color: var(--gmt-surface-2); + color: var(--gmt-ice); + font: inherit; + cursor: pointer; + transition: + background-color var(--gmt-motion-fast) var(--gmt-easing), + border-color var(--gmt-motion-fast) var(--gmt-easing); +} + +.gmt-toggle-button:hover { + border-color: var(--gmt-cyan); +} + +.gmt-toggle-button:focus-visible { + outline: 2px solid var(--gmt-cyan); + outline-offset: 2px; +} + +.gmt-toggle-button[aria-pressed="true"] { + border-color: var(--gmt-cyan); + background-color: color-mix(in srgb, var(--gmt-cyan) 22%, var(--gmt-surface-2)); +} + +@media (forced-colors: active) { + .gmt-toggle-button { + border-color: ButtonText; + background-color: ButtonFace; + color: ButtonText; + } + .gmt-toggle-button[aria-pressed="true"] { + background-color: Highlight; + color: HighlightText; + } +} + +/* ---- Fader ---- + * A volume fader on a native `` of 11 steps: bevelled ice + * notches, a square bevelled thumb. The notches and the fill share one + * coordinate system, the track less one thumb, so each notch sits where the + * thumb's centre stops. The page sets `--gmt-range-pct` (0 to 100) to fill it. + */ +.gmt-fader { + --fader-thumb-w: 0.875rem; + --fader-thumb-h: 1.5rem; + --fader-track-h: 0.75rem; + --fader-span: calc(100% - var(--fader-thumb-w) + 1px); + --fader-notches: repeating-linear-gradient( + to right, + color-mix(in srgb, var(--gmt-ice) 55%, transparent) 0 1px, + transparent 1px calc((100% - 1px) / 10) + ); + --fader-fill: linear-gradient( + to right, + color-mix(in srgb, var(--gmt-cyan) 55%, transparent) + calc(var(--gmt-range-pct, 0) * 1%), + transparent 0 + ); + + appearance: none; + margin: 0; + inline-size: 8rem; + block-size: var(--fader-thumb-h); + min-block-size: var(--gmt-target-min); + background: transparent; + cursor: pointer; +} + +.gmt-fader:focus-visible { + outline: 2px solid var(--gmt-cyan); + outline-offset: 2px; +} + +.gmt-fader::-webkit-slider-runnable-track { + box-sizing: border-box; + block-size: var(--fader-track-h); + border: 1px solid var(--gmt-border); + border-radius: var(--gmt-bevel-sm); + corner-shape: bevel; + background-color: color-mix(in srgb, var(--gmt-ice) 14%, transparent); + background-image: var(--fader-notches), var(--fader-fill); + background-size: var(--fader-span) 100%; + background-position: calc(var(--fader-thumb-w) / 2 - 0.5px) 0; + background-repeat: no-repeat; +} + +.gmt-fader::-webkit-slider-thumb { + appearance: none; + box-sizing: border-box; + inline-size: var(--fader-thumb-w); + block-size: var(--fader-thumb-h); + translate: 0 calc((var(--fader-track-h) - var(--fader-thumb-h)) / 2 - 1px); + border: 1px solid var(--gmt-border); + border-radius: var(--gmt-bevel-sm); + corner-shape: bevel; + background: var(--gmt-ice); +} + +.gmt-fader::-moz-range-track { + box-sizing: border-box; + block-size: var(--fader-track-h); + border: 1px solid var(--gmt-border); + border-radius: var(--gmt-bevel-sm); + corner-shape: bevel; + background-color: color-mix(in srgb, var(--gmt-ice) 14%, transparent); + background-image: var(--fader-notches), var(--fader-fill); + background-size: var(--fader-span) 100%; + background-position: calc(var(--fader-thumb-w) / 2 - 0.5px) 0; + background-repeat: no-repeat; +} + +.gmt-fader::-moz-range-progress { + background: transparent; +} + +.gmt-fader::-moz-range-thumb { + box-sizing: border-box; + inline-size: var(--fader-thumb-w); + block-size: var(--fader-thumb-h); + border: 1px solid var(--gmt-border); + border-radius: var(--gmt-bevel-sm); + corner-shape: bevel; + background: var(--gmt-ice); +} + +@media (forced-colors: active) { + .gmt-fader { + --fader-notches: repeating-linear-gradient( + to right, + ButtonText 0 1px, + transparent 1px calc((100% - 1px) / 10) + ); + --fader-fill: linear-gradient( + to right, + Highlight calc(var(--gmt-range-pct, 0) * 1%), + transparent 0 + ); + } + .gmt-fader::-webkit-slider-runnable-track { + border-color: ButtonText; + background-color: ButtonFace; + } + .gmt-fader::-moz-range-track { + border-color: ButtonText; + background-color: ButtonFace; + } + .gmt-fader::-webkit-slider-thumb { + border-color: ButtonText; + background: Highlight; + } + .gmt-fader::-moz-range-thumb { + border-color: ButtonText; + background: Highlight; + } +} /* Reduced motion ---- */ @media (prefers-reduced-motion: reduce) { diff --git a/packages/theme/tokens.css b/packages/theme/tokens.css index 40a77b4..a19fc30 100644 --- a/packages/theme/tokens.css +++ b/packages/theme/tokens.css @@ -468,3 +468,24 @@ font-display: swap; src: url("./fonts/michroma-latin-400-normal.woff2") format("woff2"); } + +/* + * Source: apps/dox/src/styles/gmt-tokens.css lines 119-127, 329-330, 361-362 + * (gmt commit 458860e7730d714b90c63768d9e9758dd1025c01). + * The Settings panel's shape, its sheen and its motion. + */ +:root { + --gmt-ease-sweep: cubic-bezier(0.25, 0.6, 0.2, 1); + --gmt-sheen: linear-gradient( + 105deg, + transparent 38%, + color-mix(in oklab, var(--gmt-ice-bright) 10%, transparent) 45%, + color-mix(in oklab, var(--gmt-ice-bright) 24%, transparent) 50%, + color-mix(in oklab, var(--gmt-ice-bright) 10%, transparent) 55%, + transparent 62% + ); + --gmt-target-min: 24px; + --gmt-motion-fast: var(--gmt-duration-fast); + --gmt-bevel-md: 10px; + --gmt-bevel-sm: 6px; +} From a12fc8f7dba57268fa7839239f23454819bfdf4b Mon Sep 17 00:00:00 2001 From: "Craig C." Date: Thu, 19 Nov 2026 08:19:14 +0200 Subject: [PATCH 2/2] fix(site): show the panel's sheen, and let Huginn's air go on mute - Bring GMT's --gmt-ice-bright into the theme. Without it the Settings panel's sheen was invalid and drew nothing. - Muting now ends Huginn's flight for the page, and the engine hears the end of a flight even while muted or suspended. Unmuting between flights no longer brings back his last glide or soar in an empty sky. --- apps/site/src/scripts/aurora.worker.ts | 5 +++-- apps/site/src/scripts/sound/engine.ts | 9 ++++++++- packages/theme/tokens.css | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/site/src/scripts/aurora.worker.ts b/apps/site/src/scripts/aurora.worker.ts index ff434f3..e898392 100644 --- a/apps/site/src/scripts/aurora.worker.ts +++ b/apps/site/src/scripts/aurora.worker.ts @@ -1778,9 +1778,10 @@ function start(init: Extract): void { wantTimes = data.want; updateTimes(); } else if (data.type === "sound") { + // Muting ends his flight for the page too, so his held air lets go + // and cannot come back in an empty sky when sound returns. + if (!data.on) hushHuginn(); soundOn = data.on; - // Muted, the page's engine fades out by itself: nothing more to say. - if (!soundOn) flying = false; } }; } diff --git a/apps/site/src/scripts/sound/engine.ts b/apps/site/src/scripts/sound/engine.ts index 931c038..9e98813 100644 --- a/apps/site/src/scripts/sound/engine.ts +++ b/apps/site/src/scripts/sound/engine.ts @@ -169,9 +169,16 @@ export function createEngine(): Engine { } function onHuginn(event: Event): void { + const sound = (event as CustomEvent).detail; + // His flight's end is heard even while muted or suspended, so his held + // air never outlives him. + if (sound.kind === "gone") { + huginn?.hear(sound); + return; + } if (!ctx || !master || settings.muted || ctx.state !== "running") return; huginn ??= huginnVoice(ctx, master); - huginn.hear((event as CustomEvent).detail); + huginn.hear(sound); } function onVisibility(): void { diff --git a/packages/theme/tokens.css b/packages/theme/tokens.css index a19fc30..21cb4d4 100644 --- a/packages/theme/tokens.css +++ b/packages/theme/tokens.css @@ -470,12 +470,13 @@ } /* - * Source: apps/dox/src/styles/gmt-tokens.css lines 119-127, 329-330, 361-362 + * Source: apps/dox/src/styles/gmt-tokens.css lines 117, 119-127, 329-330, 361-362 * (gmt commit 458860e7730d714b90c63768d9e9758dd1025c01). * The Settings panel's shape, its sheen and its motion. */ :root { --gmt-ease-sweep: cubic-bezier(0.25, 0.6, 0.2, 1); + --gmt-ice-bright: #e6f6ff; --gmt-sheen: linear-gradient( 105deg, transparent 38%,