27 lines
889 B
TypeScript
27 lines
889 B
TypeScript
import { FaArrowsUpDownLeftRight, FaExpand } from "react-icons/fa6";
|
|
import type { DefinedTool } from "./interfaces";
|
|
import type { JSX } from "react";
|
|
import { FaMousePointer } from "react-icons/fa";
|
|
|
|
export const TOOLS: DefinedTool<any>[] = [];
|
|
|
|
export function defineTool<T = any, K extends string = string>(
|
|
key: K,
|
|
name: string,
|
|
icon: () => JSX.Element,
|
|
defaultSettings: () => T = () => null,
|
|
): DefinedTool<T, K> {
|
|
const tool: DefinedTool<T, K> = {
|
|
key,
|
|
name,
|
|
icon,
|
|
defaultSettings,
|
|
};
|
|
TOOLS.push(tool);
|
|
return tool;
|
|
}
|
|
|
|
export const TOOL_SELECT = defineTool<null>("select", "Select", () => <FaMousePointer />);
|
|
export const TOOL_CANVAS_MOVE = defineTool<null>("move", "move-canvas", () => <FaArrowsUpDownLeftRight />);
|
|
export const TOOL_OBJECT_MOVE = defineTool<null>("move-object", "Move object", () => <FaExpand />);
|