2026-11-09 23:29:02 +00:00
|
|
|
// 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.
|
2026-11-09 22:10:11 +00:00
|
|
|
//
|
2026-11-09 23:18:08 +00:00
|
|
|
// Day and Dusk take the dark ink of Noonday Sky, Night the light ink of Midnight Sky. Each state's
|
2026-11-17 16:05:19 +01:00
|
|
|
// 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
|
2026-11-10 01:18:45 +00:00
|
|
|
// 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
|
2026-11-10 01:13:29 +00:00
|
|
|
// (4.53 on it, 5.43 on the darkest). The plate (skyPlate.css.ts) is still in the shell, pending
|
2026-11-09 23:18:08 +00:00
|
|
|
// its removal.
|
2026-11-10 14:03:21 +00:00
|
|
|
import type { FixedSkyState, SkyState } from './skyState';
|
2026-11-09 22:10:11 +00:00
|
|
|
|
|
|
|
|
export type SkyThemeId = 'midnight-sky' | 'noonday-sky';
|
|
|
|
|
|
2026-11-09 23:18:08 +00:00
|
|
|
const BY_STATE: Record<FixedSkyState, SkyThemeId> = {
|
2026-11-09 22:10:11 +00:00
|
|
|
day: 'noonday-sky',
|
|
|
|
|
dusk: 'noonday-sky',
|
|
|
|
|
night: 'midnight-sky',
|
|
|
|
|
};
|
|
|
|
|
|
2026-11-09 23:29:02 +00:00
|
|
|
export const skyThemeId = (state: SkyState): SkyThemeId | undefined =>
|
2026-11-10 14:03:21 +00:00
|
|
|
state === 'auto' ? undefined : BY_STATE[state];
|
|
|
|
|
|
|
|
|
|
/**
|
2026-11-12 11:41:43 +00:00
|
|
|
* 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.
|
2026-11-10 14:03:21 +00:00
|
|
|
* Signed-out pages choose no theme, so they pass `userChoseTheme: false`.
|
|
|
|
|
*/
|
|
|
|
|
export const sceneThemeId = (
|
|
|
|
|
state: SkyState,
|
|
|
|
|
resolved: FixedSkyState,
|
|
|
|
|
sceneOn: boolean,
|
|
|
|
|
userChoseTheme: boolean
|
|
|
|
|
): SkyThemeId | undefined => {
|
2026-11-12 11:41:43 +00:00
|
|
|
if (userChoseTheme) return undefined;
|
2026-11-10 14:03:21 +00:00
|
|
|
if (state !== 'auto') return BY_STATE[state];
|
2026-11-12 11:41:43 +00:00
|
|
|
return sceneOn ? BY_STATE[resolved] : undefined;
|
2026-11-10 14:03:21 +00:00
|
|
|
};
|