Implement fit-mode rendering contract with container sizing and pane re-fit

This commit is contained in:
2026-06-05 10:45:41 +03:00
parent f4253f50ca
commit 411bfbc6c2
13 changed files with 552 additions and 73 deletions
+26
View File
@@ -0,0 +1,26 @@
/**
* Preference orchestration — bridges the (browser-free) AppStore to the settings
* adapter for the small UI preferences pulled forward ahead of the M5 Settings
* modal. Same store↔adapter pattern as theme orchestration; currently the only
* such preference is the Live Preview fit mode (spec §04, `previewFitMode`).
*
* Unlike theme there is no FOUC concern (the preview renders after hydration
* anyway), but hydrating early keeps the store the single source of truth from
* the first render.
*/
import { loadPreviewFitMode, savePreviewFitMode } from '../infrastructure/settings-store';
import { useAppStore } from '../stores/AppStore';
/** Hydrate the persisted fit mode into the store. Call before render. */
export function initPreviewFitMode(): void {
useAppStore.getState().setPreviewFitMode(loadPreviewFitMode());
}
/** Persist the fit mode on change. Returns a teardown that detaches the subscriber. */
export function wirePreviewFitMode(): () => void {
return useAppStore.subscribe((state, prev) => {
if (state.previewFitMode === prev.previewFitMode) return;
savePreviewFitMode(state.previewFitMode);
});
}