import { ArrowIcon, DiamondIcon, EllipseIcon, EraserIcon, FreedrawIcon, ImageIcon, LineIcon, RectangleIcon, SelectionIcon, TextIcon, } from "./components/icons"; import { KEYS } from "./keys"; export const SHAPES = [ { icon: SelectionIcon, value: "selection", key: KEYS.V, fillable: true, }, { icon: RectangleIcon, value: "rectangle", key: KEYS.R, fillable: true, }, { icon: DiamondIcon, value: "diamond", key: KEYS.D, fillable: true, }, { icon: EllipseIcon, value: "ellipse", key: KEYS.O, fillable: true, }, { icon: ArrowIcon, value: "arrow", key: KEYS.A, fillable: true, }, { icon: LineIcon, value: "line", key: [KEYS.P, KEYS.L], fillable: true, }, { icon: FreedrawIcon, value: "freedraw", key: [KEYS.X, KEYS.P.toUpperCase()], fillable: false, }, { icon: TextIcon, value: "text", key: KEYS.T, fillable: false, }, { icon: ImageIcon, value: "image", key: null, fillable: false, }, { icon: EraserIcon, value: "eraser", key: KEYS.E, fillable: false, }, ] as const; export const findShapeByKey = (key: string) => { const shape = SHAPES.find((shape, index) => { return ( key === (shape.value === "eraser" ? 0 : index + 1).toString() || (shape.key && (typeof shape.key === "string" ? shape.key === key : (shape.key as readonly string[]).includes(key))) ); }); return shape?.value || null; };