Skip to content

Commit

Permalink
Edit emoji button
Browse files Browse the repository at this point in the history
  • Loading branch information
PopDaph committed Oct 3, 2023
1 parent b5973d9 commit 0c8dd99
Showing 1 changed file with 40 additions and 8 deletions.
48 changes: 40 additions & 8 deletions front/components/assistant/conversation/ConversationMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Avatar, Button, DropdownMenu } from "@dust-tt/sparkle";
import {
Avatar,
Button,
DropdownMenu,
IconButton,
PlusIcon,
} from "@dust-tt/sparkle";
import { Emoji, EmojiMartData } from "@emoji-mart/data";
import Picker from "@emoji-mart/react";
import { ComponentType, MouseEventHandler, useEffect, useState } from "react";
Expand Down Expand Up @@ -80,6 +86,18 @@ export function ConversationMessage({
}
};

const handleEmojiClick = async (emojiCode: string) => {
const reaction = reactions.find((r) => r.emoji === emojiCode);
const hasReacted =
(reaction &&
reaction.users.find((u) => u.userId === user.id) !== undefined) ||
false;
await handleEmoji({
emoji: emojiCode,
isToRemove: hasReacted,
});
};

let hasMoreReactions = null;
if (reactions.length > MAX_REACTIONS_TO_SHOW) {
hasMoreReactions = reactions.length - MAX_REACTIONS_TO_SHOW;
Expand Down Expand Up @@ -153,15 +171,29 @@ export function ConversationMessage({
</div>
))}
</div>
<div>

<div className="duration-400 active:s-border-action-500 box-border inline-flex scale-100 cursor-pointer items-center gap-x-1 whitespace-nowrap rounded-full border border-structure-200 bg-structure-0 px-2 text-xs text-element-800 ">
<a
className="cursor-pointer px-1 py-1.5 hover:border-action-200 hover:bg-action-50 hover:drop-shadow-md active:scale-95 active:bg-action-100 active:drop-shadow-none"
onClick={async () => await handleEmojiClick("+1")}
>
👍
</a>
<a
className="cursor-pointer px-1 py-1.5 hover:border-action-200 hover:bg-action-50 hover:drop-shadow-md active:scale-95 active:bg-action-100 active:drop-shadow-none"
onClick={async () => await handleEmojiClick("-1")}
>
👎
</a>
<a
className="cursor-pointer px-1 py-1.5 hover:border-action-200 hover:bg-action-50 hover:drop-shadow-md active:scale-95 active:bg-action-100 active:drop-shadow-none"
onClick={async () => await handleEmojiClick("heart")}
>
❤️
</a>
<DropdownMenu>
<DropdownMenu.Button>
<Button
type="menu"
variant="tertiary"
size="xs"
label="🔥&nbsp;&nbsp;❌&nbsp;&nbsp;🤩"
/>
<IconButton variant="tertiary" size="xs" icon={PlusIcon} />
</DropdownMenu.Button>
<DropdownMenu.Items width={280}>
<Picker
Expand Down

0 comments on commit 0c8dd99

Please sign in to comment.