From b0e611c9c514dcd66919aff931e88cf43bfdd65b Mon Sep 17 00:00:00 2001 From: Anton Date: Sun, 27 Aug 2023 20:25:52 +0200 Subject: [PATCH] Tag API implementation --- src/Components/Input/TextAreaInput.tsx | 15 +++--- src/Components/Map/Layer.tsx | 52 ++++++------------ .../Map/Subcomponents/ItemFormPopup.tsx | 23 +++++--- src/Components/Map/Tags.tsx | 18 +++---- src/Components/Map/hooks/useTags.tsx | 54 ++++++++++++++++--- src/Utils/HeighlightTags.ts | 6 +-- src/Utils/RandomColor.ts | 43 +++++++++++++++ tsconfig.json | 3 +- 8 files changed, 141 insertions(+), 73 deletions(-) create mode 100644 src/Utils/RandomColor.ts diff --git a/src/Components/Input/TextAreaInput.tsx b/src/Components/Input/TextAreaInput.tsx index 78b17d9b..3f9959e8 100644 --- a/src/Components/Input/TextAreaInput.tsx +++ b/src/Components/Input/TextAreaInput.tsx @@ -28,35 +28,36 @@ export function TextAreaInput({ labelTitle, dataField, labelStyle, containerStyl const init = useRef(false) const tags = useTags(); - const values: KeyValue[] = []; + + let values: KeyValue[] = []; + tags.map(tag => { values.push({ key: tag.id, value: tag.id, color: tag.color }) }) var tribute = new Tribute({ - containerClass: 'tw-z-500 tw-bg-white tw-p-2 tw-rounded', + containerClass: 'tw-z-500 tw-bg-white tw-p-2 tw-rounded-lg tw-shadow', selectClass: 'tw-font-bold', trigger: "#", values: values, + noMatchTemplate: () => { + return "" + }, menuItemTemplate: function (item) { - console.log(item); return `#${item.string}`; - }, + } }); useEffect(() => { if (!init.current) { if (ref.current) { - console.log("check"); tribute.attach(ref.current); } init.current = true; } }, [ref]) - - return (
{labelTitle ?