mirror of
https://github.com/olehomelchenko/astrolabe.git
synced 2026-08-08 10:12:34 +00:00
Implement fit-mode rendering contract with container sizing and pane re-fit
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user