feat: floodlit roadside billboard carries the selected-builds case studies
This commit is contained in:
47
src/journey/billboard-feed.ts
Normal file
47
src/journey/billboard-feed.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* DRIVE-IN, the part the DOM needs (initial chunk): the case-study stops and
|
||||
* the slot the scene reads. The beats themselves (t, floods, screen kind)
|
||||
* live in billboard-progress.ts, which only the lazy scene chunk loads.
|
||||
*/
|
||||
export interface BillboardShot {
|
||||
/** Manifest asset id (html[data-billboard-focus] names it). */
|
||||
id: string;
|
||||
url: string;
|
||||
kind: string;
|
||||
}
|
||||
|
||||
export interface BillboardProject {
|
||||
id: string;
|
||||
title: string;
|
||||
/** The route plate, e.g. "05.2 / PUBLIC / ACTIVE" (src/lib/route-plate.ts). */
|
||||
plate: string;
|
||||
shots: readonly BillboardShot[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Chapter-local progress at which each case-study header crosses the
|
||||
* activation line, from document tops (the chapter heading, each header,
|
||||
* the next chapter's heading). The first case study takes the board as the
|
||||
* chapter opens (stop 0), so the board is lit in the band above the chapter
|
||||
* heading. Scroll-invariant: measure once per layout.
|
||||
*/
|
||||
export function billboardStops(chapterTop: number, nextTop: number, headerTops: readonly number[]): number[] {
|
||||
const span = nextTop - chapterTop;
|
||||
return span > 0 ? headerTops.map((top, i) => (i === 0 ? 0 : Math.min(1, Math.max(0, (top - chapterTop) / span)))) : [];
|
||||
}
|
||||
|
||||
/** Index of the case study holding the board at chapter progress p: the last stop passed, else -1. */
|
||||
export const activeStop = (p: number | null, stops: readonly number[], count: number): number =>
|
||||
p === null ? -1 : Math.min(count, stops.filter((stop) => p >= stop).length) - 1;
|
||||
|
||||
/**
|
||||
* The DOM publishes the projects and their stops here once per layout; the
|
||||
* scene reads them inside its own frame. Nothing here schedules work.
|
||||
*/
|
||||
let feed: { projects: readonly BillboardProject[]; stops: readonly number[] } = { projects: [], stops: [] };
|
||||
|
||||
export function publishBillboard(projects: readonly BillboardProject[], stops: readonly number[]): void {
|
||||
feed = { projects, stops };
|
||||
}
|
||||
|
||||
export const readBillboard = (): typeof feed => feed;
|
||||
Reference in New Issue
Block a user