import React from "react"; import oc from "open-color"; // We inline font-awesome icons in order to save on js size rather than including the font awesome react library export const SHAPES = [ { icon: ( // fa-mouse-pointer ), value: "selection", key: ["v", "s"], }, { icon: ( // fa-square ), value: "rectangle", key: "r", }, { icon: ( // custom ), value: "diamond", key: "d", }, { icon: ( // fa-circle ), value: "ellipse", key: "e", }, { icon: ( // fa-long-arrow-alt-right ), value: "arrow", key: "a", }, { icon: ( // custom ), value: "line", key: ["p", "l"], }, { icon: ( // fa-pencil ), value: "draw", key: ["P", "x"], }, { icon: ( // fa-font ), value: "text", key: "t", }, ] as const; export const findShapeByKey = (key: string) => { const shape = SHAPES.find((shape, index) => { return ( key === (index + 1).toString() || (typeof shape.key === "string" ? shape.key === key : (shape.key as readonly string[]).includes(key)) ); }); return shape?.value || null; };