Merge pull request #45 from shumaiOne/feat/message-card-thread-line

refactor(ui): improve message card thread line alignment and replying indicator
This commit is contained in:
Yiling-J
2026-06-01 09:15:22 +08:00
committed by GitHub
2 changed files with 35 additions and 24 deletions
+30 -18
View File
@@ -3,11 +3,11 @@ import type { UserInfo } from '@/dtos/team'
import { client } from '@/ui/api/client'
import { Button } from '@/ui/components/ui/button'
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from '@/ui/components/ui/dialog'
import { Separator } from '@/ui/components/ui/separator'
import { formatTimeAgo } from '@/ui/lib/time'
@@ -120,24 +120,36 @@ export const MessageCard: React.FC<MessageCardProps> = ({
return (
<div
onClick={onSelect}
className={`relative flex gap-4 ${isReply ? 'mt-2' : 'mt-3'} mr-3 group p-3 py-4 border transition-all duration-200 cursor-pointer rounded-xl ${
className={`relative flex gap-4 ${isReply ? 'mt-[-1px]' : 'mt-3'} mr-3 group p-3 py-4 border transition-all duration-200 cursor-pointer ${
isReply
? isLastReply
? 'rounded-b-xl rounded-t-none'
: 'rounded-none'
: hasReplies
? 'rounded-t-xl rounded-b-none'
: 'rounded-xl'
} ${
isSelected
? 'border-blue-500/40 dark:border-blue-400/40 bg-blue-500/10 dark:bg-blue-400/10 shadow-sm'
: 'border-transparent bg-foreground/2 dark:bg-foreground/10 hover:bg-foreground/4 dark:hover:bg-foreground/15'
? 'z-20 border-blue-500/40 dark:border-blue-400/40 bg-blue-500/10 dark:bg-blue-400/10 shadow-sm'
: 'z-10 border-transparent bg-foreground/2 dark:bg-foreground/10 hover:bg-foreground/4 dark:hover:bg-foreground/15'
}`}
>
{hasReplies && !isReply && (
<div className="absolute left-[1.7rem] top-[2rem] bottom-[-1.8rem] w-0.5 bg-foreground/10 -translate-x-1/2 z-0" />
)}
{/* Left Column: Avatar & Thread Lines */}
<div className="flex flex-col items-center shrink-0 w-8 relative">
{/* Thread line above avatar (for replies) */}
{isReply && (
<div className="absolute top-[-1rem] h-8 w-0.5 bg-foreground/10 left-1/2 -translate-x-1/2 z-0" />
)}
{isReply && !isLastReply && (
<div className="absolute left-[1rem] top-[2rem] bottom-[-1.5rem] w-0.5 bg-foreground/10 -translate-x-1/2 z-0" />
)}
{/* Thread line under avatar (for parent comments with replies, or intermediate replies) */}
{((hasReplies && !isReply) || (isReply && !isLastReply)) && (
<div className="absolute top-4 bottom-[-1rem] w-0.5 bg-foreground/10 left-1/2 -translate-x-1/2 z-0" />
)}
{/* Avatar */}
<div>
<Avatar>
<AvatarFallback>{creator?.name?.[0]?.toUpperCase() || 'U'}</AvatarFallback>
<Avatar className="z-10 relative">
<AvatarFallback className="bg-rose-400 text-black">
{creator?.name?.[0]?.toUpperCase() || 'U'}
</AvatarFallback>
</Avatar>
</div>
+5 -6
View File
@@ -529,16 +529,15 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
{showUpperPart && (
<div className="flex flex-col gap-2 p-3 pb-0 animate-in fade-in slide-in-from-bottom-2 duration-200">
{replyingTo && (
<div className="flex items-start justify-between bg-gray-50 p-2 rounded-xl border border-l-4 border-gray-200 border-l-blue-500">
<div className="flex flex-col text-sm">
<span className="font-semibold text-blue-600 mb-0.5">Replying to thread</span>
<span className="text-gray-600 line-clamp-1">{replyingTo.message}</span>
<div className="flex items-center justify-between bg-muted p-2 px-3 rounded-lg border border-border">
<div className="text-xs text-muted-foreground truncate mr-2">
reply to: {replyingTo.message}
</div>
<button
onClick={onCancelReply}
className="text-gray-400 hover:text-gray-600 p-1 rounded-full hover:bg-gray-200/50"
className="text-muted-foreground hover:text-foreground p-1 rounded-full hover:bg-muted-foreground/10 shrink-0"
>
<XIcon className="w-4 h-4" />
<XIcon className="w-3.5 h-3.5" />
</button>
</div>
)}