From 98766e9da41d0f857ad11a2f9f66e86fe9124dec Mon Sep 17 00:00:00 2001 From: HF Date: Sun, 4 Sep 2022 23:11:42 +0200 Subject: [PATCH] add align prop to contextmenu --- src/components/contextmenus/index.jsx | 31 ++++++++++++++++--- src/components/windows/Chat.jsx | 2 ++ src/rep.sh | 4 +++ src/socket/APISocketServer.js | 1 + src/store/actions/index.js | 20 ++++++------ src/store/middleware/notifications.js | 2 +- src/store/middleware/rendererHook.js | 2 +- src/store/middleware/socketClientHook.js | 8 ++--- src/store/middleware/socketClientHookPopUp.js | 6 ++-- src/store/middleware/title.js | 2 +- src/store/reducers/canvas.js | 2 +- src/store/reducers/chat.js | 10 +++--- src/store/reducers/chatRead.js | 4 +-- src/store/reducers/ranks.js | 4 +-- src/store/reducers/user.js | 14 ++++----- 15 files changed, 70 insertions(+), 42 deletions(-) create mode 100755 src/rep.sh diff --git a/src/components/contextmenus/index.jsx b/src/components/contextmenus/index.jsx index 3fcc3e6..0b080ea 100644 --- a/src/components/contextmenus/index.jsx +++ b/src/components/contextmenus/index.jsx @@ -13,7 +13,7 @@ export const types = { }; const ContextMenu = ({ - type, x, y, args, close, + type, x, y, args, close, align, }) => { const wrapperRef = useRef(null); @@ -23,16 +23,37 @@ const ContextMenu = ({ return null; } + const style = {}; + switch (align) { + case 'tr': { + style.right = window.innerWidth - x; + style.top = y; + break; + } + case 'br': { + style.right = window.innerWidth - x; + style.bottom = window.innerHeight - y; + break; + } + case 'bl': { + style.left = x; + style.bottom = window.innerHeight - y; + break; + } + default: { + // also 'tl' + style.left = x; + style.top = y; + } + } + const Content = types[type]; return ReactDOM.createPortal((
diff --git a/src/components/windows/Chat.jsx b/src/components/windows/Chat.jsx index b2796e8..2e026bc 100644 --- a/src/components/windows/Chat.jsx +++ b/src/components/windows/Chat.jsx @@ -162,6 +162,7 @@ const Chat = () => { y={cmArgs.y} args={cmArgs.args} close={closeCm} + align={cmArgs.align} />