22 lines
684 B
TypeScript
22 lines
684 B
TypeScript
export const availableToolIds = ["select", "crop", "brush", "eraser", "pan"] as const;
|
|
|
|
export type ToolId = (typeof availableToolIds)[number];
|
|
|
|
export type InteractionMode =
|
|
| { type: "tool"; tool: ToolId }
|
|
| { type: "temporary-pan"; previousTool: ToolId };
|
|
|
|
export type ToolState = {
|
|
activeTool: ToolId;
|
|
interactionMode: InteractionMode;
|
|
};
|
|
|
|
export const initialToolState: ToolState = {
|
|
activeTool: "select",
|
|
interactionMode: { type: "tool", tool: "select" },
|
|
};
|
|
|
|
export function isPanInteractionMode(interactionMode: InteractionMode): boolean {
|
|
return interactionMode.type === "temporary-pan" || (interactionMode.type === "tool" && interactionMode.tool === "pan");
|
|
}
|