From b316ce9ca67765ce131e45d7ef100cfdad90f34f Mon Sep 17 00:00:00 2001 From: kjuulh Date: Mon, 15 Nov 2021 18:49:03 +0100 Subject: [PATCH] Make context menu --- src/client/package.json | 1 + src/client/src/components/todos/todoItem.tsx | 44 +++++++++++++++----- src/client/yarn.lock | 19 +++++++++ 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/src/client/package.json b/src/client/package.json index 2448249..cb7eac1 100644 --- a/src/client/package.json +++ b/src/client/package.json @@ -9,6 +9,7 @@ }, "dependencies": { "@microsoft/signalr": "^6.0.0", + "@tippyjs/react": "^4.2.6", "next": "12.0.3", "next-pwa": "^5.4.0", "react": "17.0.2", diff --git a/src/client/src/components/todos/todoItem.tsx b/src/client/src/components/todos/todoItem.tsx index 7e5ed96..7cbf02e 100644 --- a/src/client/src/components/todos/todoItem.tsx +++ b/src/client/src/components/todos/todoItem.tsx @@ -1,6 +1,7 @@ import { Todo } from "@src/core/entities/todo"; import { FC, useState } from "react"; import { TodoCheckmark } from "@src/components/todos/todoCheckmark"; +import Tippy from "@tippyjs/react"; interface TodoItemProps { todo: Todo; @@ -10,6 +11,7 @@ interface TodoItemProps { export const TodoItem: FC = (props) => { const [isHovering, setIsHovering] = useState(false); + const [menuIsOpen, setMenuIsOpen] = useState(false); return (
= (props) => {
-
- {isHovering && ( -
-
-
-
+ { + setMenuIsOpen(false); + }} + interactive={true} + interactiveBorder={20} + content={ +
+ +
- )} -
+ } + > +
setMenuIsOpen(true)} + > + {isHovering && ( +
+
+
+
+
+ )} +
+
); }; diff --git a/src/client/yarn.lock b/src/client/yarn.lock index 5a2396f..28ceb31 100644 --- a/src/client/yarn.lock +++ b/src/client/yarn.lock @@ -1102,6 +1102,11 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@popperjs/core@^2.9.0": + version "2.10.2" + resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.10.2.tgz#0798c03351f0dea1a5a4cabddf26a55a7cbee590" + integrity sha512-IXf3XA7+XyN7CP9gGh/XB0UxVMlvARGEgGXLubFICsUMGz6Q+DU+i4gGlpOxTjKvXjkJDJC8YdqdKkDj9qZHEQ== + "@rollup/plugin-babel@^5.2.0": version "5.3.0" resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.3.0.tgz#9cb1c5146ddd6a4968ad96f209c50c62f92f9879" @@ -1152,6 +1157,13 @@ ejs "^2.6.1" magic-string "^0.25.0" +"@tippyjs/react@^4.2.6": + version "4.2.6" + resolved "https://registry.yarnpkg.com/@tippyjs/react/-/react-4.2.6.tgz#971677a599bf663f20bb1c60a62b9555b749cc71" + integrity sha512-91RicDR+H7oDSyPycI13q3b7o4O60wa2oRbjlz2fyRLmHImc4vyDwuUP8NtZaN0VARJY5hybvDYrFzhY9+Lbyw== + dependencies: + tippy.js "^6.3.1" + "@trysound/sax@0.2.0": version "0.2.0" resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad" @@ -5257,6 +5269,13 @@ timsort@^0.3.0: resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4" integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q= +tippy.js@^6.3.1: + version "6.3.7" + resolved "https://registry.yarnpkg.com/tippy.js/-/tippy.js-6.3.7.tgz#8ccfb651d642010ed9a32ff29b0e9e19c5b8c61c" + integrity sha512-E1d3oP2emgJ9dRQZdf3Kkn0qJgI6ZLpyS5z6ZkY1DF3kaQaBsGZsndEpHwx+eC+tYM41HaSNvNtLx8tU57FzTQ== + dependencies: + "@popperjs/core" "^2.9.0" + tmp@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14"