From 1d01e5959d5550fabba479447165083b3de95a52 Mon Sep 17 00:00:00 2001 From: Pavel Prichodko <14926950+prichodko@users.noreply.github.com> Date: Tue, 19 Apr 2022 14:09:16 +0200 Subject: [PATCH] feat(react): add action handlers --- .../chat/components/chat-message/actions.tsx | 25 +++++----- .../chat/components/chat-message/index.tsx | 48 ++++++++++--------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/packages/status-react/src/routes/chat/components/chat-message/actions.tsx b/packages/status-react/src/routes/chat/components/chat-message/actions.tsx index 76b0b7c6..269dd54f 100644 --- a/packages/status-react/src/routes/chat/components/chat-message/actions.tsx +++ b/packages/status-react/src/routes/chat/components/chat-message/actions.tsx @@ -22,6 +22,7 @@ interface Props { pinned: boolean onReplyClick: () => void onEditClick: () => void + onPinClick: () => void reacting: boolean onReactingChange: (reacting: boolean) => void reactions: Reactions @@ -33,6 +34,7 @@ export const Actions = (props: Props) => { pinned, onReplyClick, onEditClick, + onPinClick, reacting, onReactingChange, reactions, @@ -77,19 +79,16 @@ export const Actions = (props: Props) => { )} - {pinned ? ( - - - - - - ) : ( - - - - - - )} + + + {pinned ? : } + + {owner && ( diff --git a/packages/status-react/src/routes/chat/components/chat-message/index.tsx b/packages/status-react/src/routes/chat/components/chat-message/index.tsx index e4945869..f88ae41a 100644 --- a/packages/status-react/src/routes/chat/components/chat-message/index.tsx +++ b/packages/status-react/src/routes/chat/components/chat-message/index.tsx @@ -60,12 +60,26 @@ export const ChatMessage = (props: Props) => { const { dispatch } = useChatContext() - if (editing) { - return ( - - + const handleReplyClick = () => { + dispatch({ + type: 'SET_REPLY', + message, + }) + } + + const handlePinClick = () => { + console.log(pinned) + } + + const handleReaction = (reaction: string) => { + console.log(reaction) + } + + const renderMessage = () => { + if (editing) { + return ( - + - - ) - } + ) + } - const handleReplyClick = () => { - dispatch({ - type: 'SET_REPLY', - message, - }) - } - - const handleReaction = (reaction: string) => { - console.log(reaction) - } - - const renderMessage = () => { switch (type) { case 'text': { // @@ -210,14 +211,15 @@ export const ChatMessage = (props: Props) => { pinned={pinned} onEditClick={() => setEditing(true)} onReplyClick={handleReplyClick} + onPinClick={handlePinClick} reacting={reacting} onReactingChange={setReacting} reactions={reactions} /> - Reply - Pin + Reply + Pin @@ -280,4 +282,6 @@ const Wrapper = styled('div', { }, }, }, + + compoundVariants: [], })