summaryrefslogtreecommitdiff
path: root/apps/web/src/components/editor/panels/properties/stores/properties-store.ts
blob: 3303dae28e2e3002c41c97b475a77a60d96df139 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { create } from "zustand";

interface PropertiesState {
	activeTabPerType: Record<string, string>;
	setActiveTab: (args: { elementType: string; tabId: string }) => void;
	isTransformScaleLocked: boolean;
	setTransformScaleLocked: (args: { locked: boolean }) => void;
	selectedTrackId: string | null;
	selectTrack: ({ trackId }: { trackId: string }) => void;
	clearTrackSelection: () => void;
}

export const usePropertiesStore = create<PropertiesState>()((set) => ({
	activeTabPerType: {},
	setActiveTab: ({ elementType, tabId }) =>
		set((state) => ({
			activeTabPerType: { ...state.activeTabPerType, [elementType]: tabId },
		})),
	isTransformScaleLocked: false,
	setTransformScaleLocked: ({ locked }) =>
		set({ isTransformScaleLocked: locked }),
	selectedTrackId: null,
	selectTrack: ({ trackId }) => set({ selectedTrackId: trackId }),
	clearTrackSelection: () => set({ selectedTrackId: null }),
}));