Ratatoskr/src/app/features/scene/skyTheme.ts
Meta Vens c1628468a3 Serve the ridge scene only: delete the terrain style and its picker
Removes scene/terrain/, the temporary sceneStyle.ts localStorage override, the Terrain/Ridges
picker in SkyStateControl, terrainSkyFor/terrainDrawn and the terrain reach, 'terrain' from
SceneStyle, and skyBand.ts (the band shaping only the terrain sky used; FixedSkyState now lives
in skyState.ts). A config or stored value that says anything but 'raymarch' is the ridges.
skyBackdrop keeps its constants: the bounds are at least as wide as the ridge budgets, now
asserted directly instead of against the terrain union. The raymarch scene is untouched.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 16:05:19 +01:00

40 lines
2 KiB
TypeScript

// Which theme a sky state lights the page with. 'auto' picks none: it never overrides a person's theme
// (the stored one when signed in, Midnight Sky when signed out). A wiring that follows the sky when no theme
// is stored reads `getResolvedSkyState` (skyState.ts) and passes that fixed state here.
//
// Day and Dusk take the dark ink of Noonday Sky, Night the light ink of Midnight Sky. Each state's
// drawn sky is held to a luminance budget (ridge/toneMap.ts, bands in skyState.ts `FixedSkyState`) in which that ink's TEXT clears 4.5:1 on
// bare sky: Day at least 0.2983 (dark ink), Night at most 0.0931 (light ink). Dusk's floor is higher, the bound of
// the dark link (0.4554), so its link clears as well. skyTheme.test.ts pins the measured text and link ratios. Night's
// link ink is not in the band, and the themes' link colours are derived outside this code (src/sky/skyTokens.js).
// Midnight Sky's link is derived there against the lightest Night sky
// (4.53 on it, 5.43 on the darkest). The plate (skyPlate.css.ts) is still in the shell, pending
// its removal.
import type { FixedSkyState, SkyState } from './skyState';
export type SkyThemeId = 'midnight-sky' | 'noonday-sky';
const BY_STATE: Record<FixedSkyState, SkyThemeId> = {
day: 'noonday-sky',
dusk: 'noonday-sky',
night: 'midnight-sky',
};
export const skyThemeId = (state: SkyState): SkyThemeId | undefined =>
state === 'auto' ? undefined : BY_STATE[state];
/**
* The theme the page wears: a theme the person chose always wins, and picks none here. Otherwise a fixed sky state
* picks its theme, and 'auto' follows the resolved sky (`resolved`, the clock's state) only while a scene is on.
* Signed-out pages choose no theme, so they pass `userChoseTheme: false`.
*/
export const sceneThemeId = (
state: SkyState,
resolved: FixedSkyState,
sceneOn: boolean,
userChoseTheme: boolean
): SkyThemeId | undefined => {
if (userChoseTheme) return undefined;
if (state !== 'auto') return BY_STATE[state];
return sceneOn ? BY_STATE[resolved] : undefined;
};