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,
icon: DiamondIcon,
value: "diamond",
key: KEYS.D,
icon: EllipseIcon,
value: "ellipse",
key: KEYS.O,
icon: ArrowIcon,
value: "arrow",
key: KEYS.A,
icon: LineIcon,
value: "line",
key: [KEYS.P, KEYS.L],
icon: FreedrawIcon,
value: "freedraw",
key: [KEYS.X, KEYS.P.toUpperCase()],
fillable: false,
icon: TextIcon,
value: "text",
key: KEYS.T,
icon: ImageIcon,
value: "image",
key: null,
icon: EraserIcon,
value: "eraser",
key: KEYS.E,
] 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;
};