import React from "react";
import { KEYS } from "./keys";
// 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: [KEYS.V, KEYS.S],
},
{
icon: (
// fa-square
),
value: "rectangle",
key: KEYS.R,
},
{
icon: (
// custom
),
value: "diamond",
key: KEYS.D,
},
{
icon: (
// fa-circle
),
value: "ellipse",
key: KEYS.E,
},
{
icon: (
// fa-long-arrow-alt-right
),
value: "arrow",
key: KEYS.A,
},
{
icon: (
// custom
),
value: "line",
key: [KEYS.P, KEYS.L],
},
{
icon: (
// fa-pencil
),
value: "freedraw",
key: KEYS.X,
},
{
icon: (
// fa-font
),
value: "text",
key: KEYS.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;
};