From 0b7395878567f755799cad1745db69d40787875e Mon Sep 17 00:00:00 2001 From: "Craig C." Date: Thu, 5 Nov 2026 21:22:59 +0200 Subject: [PATCH 1/7] fix(site): cards follow Huginn's line, and he flies home on a return The fly-in no longer assumes the order header, card, card. Each box the page hands the worker says what it is (header, card or text), and each card is drawn in as Huginn flies over it or makes his closest pass by it, then no later than a set time after the card before it along his line. Any number of cards now works. Coming back from another of the site's pages (the GMT or worktree docs), or by Back or Forward, the header stays put and only the title, intro and cards come in again. Huginn flies home instead: from close by in the distance, starting on the side of the card for the page left, past the cards and out over the top or a side, now and then as close as the first fly-in. The page is back within 3 s. Also keeps the skyline lift from bending his line sharply when he is only a few metres away, which made the first fly-in jerk on phones. In development, ?huginn=return or ?huginn=first picks the fly-in, and &from=/gmt/ the page to come back from. Closes #15 --- apps/site/src/components/Aurora.astro | 51 +++- apps/site/src/components/Header.astro | 1 + apps/site/src/components/RepoCard.astro | 6 +- apps/site/src/layouts/Base.astro | 66 ++++- apps/site/src/scripts/aurora.raven.ts | 306 +++++++++++++++++++++--- apps/site/src/scripts/aurora.worker.ts | 248 ++++++++++++++----- 6 files changed, 573 insertions(+), 105 deletions(-) diff --git a/apps/site/src/components/Aurora.astro b/apps/site/src/components/Aurora.astro index 204a54d..83ccc25 100644 --- a/apps/site/src/components/Aurora.astro +++ b/apps/site/src/components/Aurora.astro @@ -155,7 +155,7 @@ import { version as gmtVersion } from "../../node_modules/@northguild/gmt/packag import type { SiteTimes } from "../scripts/aurora.ahead"; import type { AuroraMessage, - PageBox, + PageTarget, SkyLabel, SkyLine, WorkerMessage, @@ -210,23 +210,45 @@ import { version as gmtVersion } from "../../node_modules/@northguild/gmt/packag // Huginn's fly-in draws in the header, title, intro and cards as he // reaches them. Base.astro hides them (`ng-await`) until the worker says // he has reached each one; without a fly-in they come in by the usual - // entrance instead. The panes go first (the header, then the cards): - // the worker plans his path through the first two. + // entrance instead. Coming back to the page (`ng-return`, see Base.astro) + // he flies home from the distance instead, and the header stays as it + // was: only the title, intro and cards wait for him. Each says what it is (`data-ng-target`): the worker reaches the + // header and cards in their own ways, and plans his path by the cards. const page = document.documentElement; + const returning = page.classList.contains("ng-return"); const panes = page.classList.contains("ng-await") ? [ - ...document.querySelectorAll(".ng-enter-pane"), - ...document.querySelectorAll(".ng-enter-text"), - ] + ...document.querySelectorAll( + ".ng-enter-pane, .ng-enter-text", + ), + ].filter((el) => !returning || el.dataset.ngTarget !== "header") : []; function isAwaiting(): boolean { return page.classList.contains("ng-await"); } - function paneBoxes(): PageBox[] { + function targetKind(el: HTMLElement): PageTarget["kind"] { + const kind = el.dataset.ngTarget; + return kind === "header" || kind === "card" ? kind : "text"; + } + // The card for the page this visit came back from: the one with a link to + // where that page sits ("/gmt/" for any of the GMT docs). -1 if none. + function cardCameFrom(): number { + const path = page.dataset.ngFrom ?? ""; + if (!returning || !path) return -1; + return panes.findIndex( + (el) => + el.dataset.ngTarget === "card" && + [...el.querySelectorAll("a")].some((a) => { + const { pathname } = new URL(a.href); + return pathname.length > 1 && path.startsWith(pathname); + }), + ); + } + function pageTargets(): PageTarget[] { if (!isAwaiting()) return []; return panes.map((el) => { const r = el.getBoundingClientRect(); - return [r.left, r.top, r.width, r.height]; + return { kind: targetKind(el), box: [r.left, r.top, r.width, r.height] }; }); } function showAllPanes(): void { @@ -257,12 +279,15 @@ import { version as gmtVersion } from "../../node_modules/@northguild/gmt/packag el.classList.add("ng-brushed"); } // His flight draws the panes in. This is only a safety net for a stalled - // worker, late enough never to start a pane ahead of him in a normal flight. + // or slow worker: on a first visit late enough never to start a pane ahead + // of him in a normal flight; coming back, the page is in by 3 s whatever + // he is doing. function brushRemainingPanes(): void { panes.forEach((_, i) => brushPane(i, lastAngle, 1)); } if (panes.length) { - setTimeout(brushRemainingPanes, Math.max(0, 8000 - performance.now())); + const by = returning ? 3000 : 8000; + setTimeout(brushRemainingPanes, Math.max(0, by - performance.now())); } // All WebGL runs in the worker. Without OffscreenCanvas the CSS gradient @@ -294,7 +319,9 @@ import { version as gmtVersion } from "../../node_modules/@northguild/gmt/packag site: chosen, still: motion.matches, hidden: document.hidden, - targets: paneBoxes(), + targets: pageTargets(), + flyIn: returning ? "return" : "first", + from: cardCameFrom(), }, [offscreen], ); @@ -336,7 +363,7 @@ import { version as gmtVersion } from "../../node_modules/@northguild/gmt/packag type: "size", width: canvas.clientWidth, height: canvas.clientHeight, - targets: paneBoxes(), + targets: pageTargets(), }), 150, ); diff --git a/apps/site/src/components/Header.astro b/apps/site/src/components/Header.astro index 8fb0863..d2ecf4d 100644 --- a/apps/site/src/components/Header.astro +++ b/apps/site/src/components/Header.astro @@ -23,6 +23,7 @@ const links = [
NorthGuild