summaryrefslogtreecommitdiff
path: root/apps/web/src/stores/text-properties-store.ts
blob: b3ce3689fd6266e40da132a0ef13cd2398eb17f7 (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 = "transform" | "style";

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

export const TEXT_PROPERTIES_TABS: ReadonlyArray<TextPropertiesTabMeta> = [
  { value: "transform", label: "Transform" },
  { value: "style", label: "Style" },
] 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: "transform",
      setActiveTab: (tab) => set({ activeTab: tab }),
    }),
    { name: "text-properties" }
  )
);