summaryrefslogtreecommitdiff
path: root/apps/web/src/stores/text-properties-store.ts
blob: c7476b460144a511f35278326479422f1e507f90 (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
26
27
28
29
30
31
32
33
import { create } from "zustand";
import { persist } from "zustand/middleware";

export type TextPropertiesTab = "text" | "transform";

export interface TextPropertiesTabMeta {
	value: TextPropertiesTab;
	label: string;
}

export const TEXT_PROPERTIES_TABS: ReadonlyArray<TextPropertiesTabMeta> = [
	{ value: "text", label: "Text" },
	{ value: "transform", label: "Transform" },
] as const;

export function isTextPropertiesTab(value: string): value is TextPropertiesTab {
	return TEXT_PROPERTIES_TABS.some((t) => t.value === value);
}

interface TextPropertiesState {
	activeTab: TextPropertiesTab;
	setActiveTab: (tab: TextPropertiesTab) => void;
}

export const useTextPropertiesStore = create<TextPropertiesState>()(
	persist(
		(set) => ({
			activeTab: "text",
			setActiveTab: (tab) => set({ activeTab: tab }),
		}),
		{ name: "text-properties" },
	),
);