2022-11-01 17:29:58 +01:00
|
|
|
import {
|
|
|
|
ArrowIcon,
|
|
|
|
DiamondIcon,
|
|
|
|
EllipseIcon,
|
|
|
|
EraserIcon,
|
|
|
|
FreedrawIcon,
|
|
|
|
ImageIcon,
|
|
|
|
LineIcon,
|
|
|
|
RectangleIcon,
|
|
|
|
SelectionIcon,
|
|
|
|
TextIcon,
|
|
|
|
} from "./components/icons";
|
2020-12-01 23:36:06 +02:00
|
|
|
import { KEYS } from "./keys";
|
2020-01-06 21:29:44 +04:00
|
|
|
|
2020-04-14 12:30:58 +03:00
|
|
|
export const SHAPES = [
|
|
|
|
{
|
2022-11-01 17:29:58 +01:00
|
|
|
icon: SelectionIcon,
|
2020-04-14 12:30:58 +03:00
|
|
|
value: "selection",
|
2021-07-04 22:27:33 +02:00
|
|
|
key: KEYS.V,
|
2022-11-06 20:14:53 +01:00
|
|
|
numericKey: KEYS["1"],
|
2022-11-01 17:29:58 +01:00
|
|
|
fillable: true,
|
2020-04-14 12:30:58 +03:00
|
|
|
},
|
|
|
|
{
|
2022-11-01 17:29:58 +01:00
|
|
|
icon: RectangleIcon,
|
2020-04-14 12:30:58 +03:00
|
|
|
value: "rectangle",
|
2020-12-01 23:36:06 +02:00
|
|
|
key: KEYS.R,
|
2022-11-06 20:14:53 +01:00
|
|
|
numericKey: KEYS["2"],
|
2022-11-01 17:29:58 +01:00
|
|
|
fillable: true,
|
2020-04-14 12:30:58 +03:00
|
|
|
},
|
|
|
|
{
|
2022-11-01 17:29:58 +01:00
|
|
|
icon: DiamondIcon,
|
2020-04-14 12:30:58 +03:00
|
|
|
value: "diamond",
|
2020-12-01 23:36:06 +02:00
|
|
|
key: KEYS.D,
|
2022-11-06 20:14:53 +01:00
|
|
|
numericKey: KEYS["3"],
|
2022-11-01 17:29:58 +01:00
|
|
|
fillable: true,
|
2020-04-14 12:30:58 +03:00
|
|
|
},
|
|
|
|
{
|
2022-11-01 17:29:58 +01:00
|
|
|
icon: EllipseIcon,
|
2020-04-14 12:30:58 +03:00
|
|
|
value: "ellipse",
|
2022-03-16 18:31:20 +05:30
|
|
|
key: KEYS.O,
|
2022-11-06 20:14:53 +01:00
|
|
|
numericKey: KEYS["4"],
|
2022-11-01 17:29:58 +01:00
|
|
|
fillable: true,
|
2020-04-14 12:30:58 +03:00
|
|
|
},
|
|
|
|
{
|
2022-11-01 17:29:58 +01:00
|
|
|
icon: ArrowIcon,
|
2020-04-14 12:30:58 +03:00
|
|
|
value: "arrow",
|
2020-12-01 23:36:06 +02:00
|
|
|
key: KEYS.A,
|
2022-11-06 20:14:53 +01:00
|
|
|
numericKey: KEYS["5"],
|
2022-11-01 17:29:58 +01:00
|
|
|
fillable: true,
|
2020-04-14 12:30:58 +03:00
|
|
|
},
|
|
|
|
{
|
2022-11-01 17:29:58 +01:00
|
|
|
icon: LineIcon,
|
2020-04-14 12:30:58 +03:00
|
|
|
value: "line",
|
2022-11-06 20:14:53 +01:00
|
|
|
key: KEYS.L,
|
|
|
|
numericKey: KEYS["6"],
|
2022-11-01 17:29:58 +01:00
|
|
|
fillable: true,
|
2020-05-12 20:10:11 +01:00
|
|
|
},
|
|
|
|
{
|
2022-11-01 17:29:58 +01:00
|
|
|
icon: FreedrawIcon,
|
2021-05-09 16:42:10 +01:00
|
|
|
value: "freedraw",
|
2022-11-06 20:14:53 +01:00
|
|
|
key: KEYS.P,
|
|
|
|
numericKey: KEYS["7"],
|
2022-11-01 17:29:58 +01:00
|
|
|
fillable: false,
|
2020-04-14 12:30:58 +03:00
|
|
|
},
|
|
|
|
{
|
2022-11-01 17:29:58 +01:00
|
|
|
icon: TextIcon,
|
2020-04-14 12:30:58 +03:00
|
|
|
value: "text",
|
2020-12-01 23:36:06 +02:00
|
|
|
key: KEYS.T,
|
2022-11-06 20:14:53 +01:00
|
|
|
numericKey: KEYS["8"],
|
2022-11-01 17:29:58 +01:00
|
|
|
fillable: false,
|
2020-04-14 12:30:58 +03:00
|
|
|
},
|
2021-10-21 22:05:48 +02:00
|
|
|
{
|
2022-11-01 17:29:58 +01:00
|
|
|
icon: ImageIcon,
|
2021-10-21 22:05:48 +02:00
|
|
|
value: "image",
|
|
|
|
key: null,
|
2022-11-06 20:14:53 +01:00
|
|
|
numericKey: KEYS["9"],
|
2022-11-01 17:29:58 +01:00
|
|
|
fillable: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: EraserIcon,
|
|
|
|
value: "eraser",
|
|
|
|
key: KEYS.E,
|
2022-11-06 20:14:53 +01:00
|
|
|
numericKey: KEYS["0"],
|
2022-11-01 17:29:58 +01:00
|
|
|
fillable: false,
|
2021-10-21 22:05:48 +02:00
|
|
|
},
|
2020-04-14 12:30:58 +03:00
|
|
|
] as const;
|
2020-01-06 21:29:44 +04:00
|
|
|
|
2020-07-24 15:47:46 +02:00
|
|
|
export const findShapeByKey = (key: string) => {
|
|
|
|
const shape = SHAPES.find((shape, index) => {
|
|
|
|
return (
|
2022-11-06 20:14:53 +01:00
|
|
|
(shape.numericKey != null && key === shape.numericKey.toString()) ||
|
2021-10-21 22:05:48 +02:00
|
|
|
(shape.key &&
|
|
|
|
(typeof shape.key === "string"
|
|
|
|
? shape.key === key
|
|
|
|
: (shape.key as readonly string[]).includes(key)))
|
2020-07-24 15:47:46 +02:00
|
|
|
);
|
|
|
|
});
|
|
|
|
return shape?.value || null;
|
|
|
|
};
|