From 4d127a038bf768eded68aae3cfa5c1b12241bdac Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Fri, 27 Mar 2026 00:55:15 +0100 Subject: chore: normalize line endings --- apps/web/src/stores/preview-store.ts | 224 +++++++++++++++++------------------ 1 file changed, 112 insertions(+), 112 deletions(-) (limited to 'apps/web/src/stores/preview-store.ts') diff --git a/apps/web/src/stores/preview-store.ts b/apps/web/src/stores/preview-store.ts index cd6488b3..d0489e3b 100644 --- a/apps/web/src/stores/preview-store.ts +++ b/apps/web/src/stores/preview-store.ts @@ -1,112 +1,112 @@ -import { create } from "zustand"; -import { persist } from "zustand/middleware"; -import { isGuideId, type GuideId } from "@/lib/guides"; -import { DEFAULT_GRID_CONFIG } from "@/constants/guide-constants"; -import type { GridConfig } from "@/lib/guides/types"; - -interface PreviewOverlaysState { - bookmarks: boolean; -} - -interface PersistedPreviewState { - activeGuide?: string | null; - layoutGuide?: { - platform?: string | null; - }; - overlays?: PreviewOverlaysState; - gridConfig?: GridConfig; -} - -interface PreviewState { - activeGuide: GuideId | null; - overlays: PreviewOverlaysState; - gridConfig: GridConfig; - toggleGuide: (guideId: GuideId) => void; - setGridConfig: (config: Partial) => void; - setOverlayVisibility: ({ - overlay, - isVisible, - }: { - overlay: keyof PreviewOverlaysState; - isVisible: boolean; - }) => void; - toggleOverlayVisibility: ({ - overlay, - }: { - overlay: keyof PreviewOverlaysState; - }) => void; -} - -const DEFAULT_PREVIEW_OVERLAYS: PreviewOverlaysState = { - bookmarks: true, -}; - -function getPersistedActiveGuide( - state: PersistedPreviewState | undefined, -): GuideId | null { - const persistedGuide = - state?.activeGuide ?? state?.layoutGuide?.platform ?? null; - - if (typeof persistedGuide !== "string") { - return null; - } - - return isGuideId(persistedGuide) ? persistedGuide : null; -} - -export const usePreviewStore = create()( - persist( - (set) => ({ - activeGuide: null, - overlays: DEFAULT_PREVIEW_OVERLAYS, - gridConfig: DEFAULT_GRID_CONFIG, - toggleGuide: (guideId) => { - set((state) => ({ - activeGuide: state.activeGuide === guideId ? null : guideId, - })); - }, - setGridConfig: (config) => { - set((state) => ({ - gridConfig: { ...state.gridConfig, ...config }, - })); - }, - setOverlayVisibility: ({ overlay, isVisible }) => { - set((state) => ({ - overlays: { - ...state.overlays, - [overlay]: isVisible, - }, - })); - }, - toggleOverlayVisibility: ({ overlay }) => { - set((state) => ({ - overlays: { - ...state.overlays, - [overlay]: !state.overlays[overlay], - }, - })); - }, - }), - { - name: "preview-settings", - version: 4, - migrate: (persistedState) => { - const state = persistedState as PersistedPreviewState | undefined; - - return { - activeGuide: getPersistedActiveGuide(state), - overlays: state?.overlays ?? DEFAULT_PREVIEW_OVERLAYS, - gridConfig: { - rows: state?.gridConfig?.rows ?? DEFAULT_GRID_CONFIG.rows, - cols: state?.gridConfig?.cols ?? DEFAULT_GRID_CONFIG.cols, - }, - }; - }, - partialize: (state) => ({ - activeGuide: state.activeGuide, - overlays: state.overlays, - gridConfig: state.gridConfig, - }), - }, - ), -); +import { create } from "zustand"; +import { persist } from "zustand/middleware"; +import { isGuideId, type GuideId } from "@/lib/guides"; +import { DEFAULT_GRID_CONFIG } from "@/constants/guide-constants"; +import type { GridConfig } from "@/lib/guides/types"; + +interface PreviewOverlaysState { + bookmarks: boolean; +} + +interface PersistedPreviewState { + activeGuide?: string | null; + layoutGuide?: { + platform?: string | null; + }; + overlays?: PreviewOverlaysState; + gridConfig?: GridConfig; +} + +interface PreviewState { + activeGuide: GuideId | null; + overlays: PreviewOverlaysState; + gridConfig: GridConfig; + toggleGuide: (guideId: GuideId) => void; + setGridConfig: (config: Partial) => void; + setOverlayVisibility: ({ + overlay, + isVisible, + }: { + overlay: keyof PreviewOverlaysState; + isVisible: boolean; + }) => void; + toggleOverlayVisibility: ({ + overlay, + }: { + overlay: keyof PreviewOverlaysState; + }) => void; +} + +const DEFAULT_PREVIEW_OVERLAYS: PreviewOverlaysState = { + bookmarks: true, +}; + +function getPersistedActiveGuide( + state: PersistedPreviewState | undefined, +): GuideId | null { + const persistedGuide = + state?.activeGuide ?? state?.layoutGuide?.platform ?? null; + + if (typeof persistedGuide !== "string") { + return null; + } + + return isGuideId(persistedGuide) ? persistedGuide : null; +} + +export const usePreviewStore = create()( + persist( + (set) => ({ + activeGuide: null, + overlays: DEFAULT_PREVIEW_OVERLAYS, + gridConfig: DEFAULT_GRID_CONFIG, + toggleGuide: (guideId) => { + set((state) => ({ + activeGuide: state.activeGuide === guideId ? null : guideId, + })); + }, + setGridConfig: (config) => { + set((state) => ({ + gridConfig: { ...state.gridConfig, ...config }, + })); + }, + setOverlayVisibility: ({ overlay, isVisible }) => { + set((state) => ({ + overlays: { + ...state.overlays, + [overlay]: isVisible, + }, + })); + }, + toggleOverlayVisibility: ({ overlay }) => { + set((state) => ({ + overlays: { + ...state.overlays, + [overlay]: !state.overlays[overlay], + }, + })); + }, + }), + { + name: "preview-settings", + version: 4, + migrate: (persistedState) => { + const state = persistedState as PersistedPreviewState | undefined; + + return { + activeGuide: getPersistedActiveGuide(state), + overlays: state?.overlays ?? DEFAULT_PREVIEW_OVERLAYS, + gridConfig: { + rows: state?.gridConfig?.rows ?? DEFAULT_GRID_CONFIG.rows, + cols: state?.gridConfig?.cols ?? DEFAULT_GRID_CONFIG.cols, + }, + }; + }, + partialize: (state) => ({ + activeGuide: state.activeGuide, + overlays: state.overlays, + gridConfig: state.gridConfig, + }), + }, + ), +); -- cgit v1.3.1