({
email,
mailboxId,
mailboxEmail,
isLast,
isDraft,
isSending,
isExpanded,
onToggleExpand,
onSendDraft,
onEditDraft,
onDeleteDraft,
onViewSource,
onPreviewImage,
}: ThreadMessageProps)
| 54 | } |
| 55 | |
| 56 | export default function ThreadMessage({ |
| 57 | email, |
| 58 | mailboxId, |
| 59 | mailboxEmail, |
| 60 | isLast, |
| 61 | isDraft, |
| 62 | isSending, |
| 63 | isExpanded, |
| 64 | onToggleExpand, |
| 65 | onSendDraft, |
| 66 | onEditDraft, |
| 67 | onDeleteDraft, |
| 68 | onViewSource, |
| 69 | onPreviewImage, |
| 70 | }: ThreadMessageProps) { |
| 71 | const isSelf = email.sender === mailboxEmail; |
| 72 | const containerClassName = `${!isLast ? "border-b border-kumo-line" : ""} ${isDraft ? "border-l-2 border-l-kumo-warning bg-kumo-warning/[0.02]" : ""}`; |
| 73 | const senderLabel = isDraft ? "Draft reply" : isSelf ? "You" : email.sender; |
| 74 | |
| 75 | if (!isExpanded) { |
| 76 | return ( |
| 77 | <div className={containerClassName}> |
| 78 | <button |
| 79 | type="button" |
| 80 | onClick={onToggleExpand} |
| 81 | className="w-full flex items-center gap-3 px-4 py-3 hover:bg-kumo-tint rounded-lg text-left" |
| 82 | > |
| 83 | <Avatar isDraft={isDraft} isSelf={isSelf} sender={email.sender} /> |
| 84 | <div className="flex-1 min-w-0"> |
| 85 | <div className="flex items-center justify-between"> |
| 86 | <span className="text-sm font-medium text-kumo-default truncate"> |
| 87 | {senderLabel} |
| 88 | </span> |
| 89 | <span className="text-xs text-kumo-subtle shrink-0"> |
| 90 | {formatDetailDate(email.date)} |
| 91 | </span> |
| 92 | </div> |
| 93 | <p className="text-xs text-kumo-subtle truncate"> |
| 94 | {stripHtml(email.body || "").slice(0, 80)} |
| 95 | </p> |
| 96 | </div> |
| 97 | <CaretDownIcon size={14} className="text-kumo-subtle shrink-0" /> |
| 98 | </button> |
| 99 | </div> |
| 100 | ); |
| 101 | } |
| 102 | |
| 103 | return ( |
| 104 | <div className={`group/thread-msg ${containerClassName}`}> |
| 105 | <div className="px-4 py-4 md:px-6"> |
| 106 | <div className="flex items-center justify-between gap-3 mb-3"> |
| 107 | <div className="flex items-center gap-2.5 min-w-0"> |
| 108 | <button |
| 109 | type="button" |
| 110 | onClick={onToggleExpand} |
| 111 | className="shrink-0" |
| 112 | aria-label="Collapse message" |
| 113 | > |
nothing calls this directly
no test coverage detected