Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ yarn-error.log*
# Pre commit
/.husky
tsconfig.tsbuildinfo

# private fork-only notes
/.fork-local
22 changes: 21 additions & 1 deletion src/components/message/MessageActions.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
import type React from "react";
import { FaExpand, FaReply, FaTrash } from "react-icons/fa";
import { FaExpand, FaLanguage, FaReply, FaTrash } from "react-icons/fa";
import type { MessageType } from "../../types";
import { MdAddReaction } from "./icons";

interface MessageActionsProps {
message: MessageType;
onReplyClick: () => void;
onReactClick: (buttonElement: Element) => void;
onTranslateClick?: () => void;
onRedactClick?: () => void;
onOpenMedia?: () => void;
canRedact?: boolean;
canReply?: boolean;
canTranslate?: boolean;
canOpenMedia?: boolean;
isTranslating?: boolean;
inline?: boolean;
}

export const MessageActions: React.FC<MessageActionsProps> = ({
message,
onReplyClick,
onReactClick,
onTranslateClick,
onRedactClick,
onOpenMedia,
canRedact = false,
canReply = !!message.msgid,
canTranslate = false,
canOpenMedia = false,
isTranslating = false,
inline = false,
}) => {
return (
Expand Down Expand Up @@ -62,6 +68,20 @@ export const MessageActions: React.FC<MessageActionsProps> = ({
<FaReply className="w-4 h-4" />
</button>
)}
{canTranslate && onTranslateClick && (
<button
type="button"
className="px-2.5 py-1.5 text-sky-300/80 hover:text-sky-200 hover:bg-white/10 transition-colors first:rounded-l-lg last:rounded-r-lg disabled:opacity-60 disabled:cursor-wait"
onClick={onTranslateClick}
title={isTranslating ? "Translating" : "Translate message"}
aria-label={
isTranslating ? "Translating message" : "Translate message"
}
disabled={isTranslating}
>
<FaLanguage className="w-4 h-4" />
</button>
)}
<button
type="button"
className="px-2.5 py-1.5 text-discord-text-muted hover:text-discord-text-normal hover:bg-white/10 transition-colors first:rounded-l-lg last:rounded-r-lg"
Expand Down
Loading