From d8b564fed0c08a9fe35cc48506bc6241f291d911 Mon Sep 17 00:00:00 2001 From: zp6 <373669493@qq.com> Date: Sat, 16 May 2026 02:30:48 +0800 Subject: [PATCH] feat: bounty comments/discussion thread component --- .../components/bounty/BountyDiscussion.tsx | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 frontend/src/components/bounty/BountyDiscussion.tsx diff --git a/frontend/src/components/bounty/BountyDiscussion.tsx b/frontend/src/components/bounty/BountyDiscussion.tsx new file mode 100644 index 000000000..51ee1b853 --- /dev/null +++ b/frontend/src/components/bounty/BountyDiscussion.tsx @@ -0,0 +1,106 @@ +import React, { useState } from 'react'; +import { motion, AnimatePresence } from 'framer-motion'; +import { MessageSquare, Send, ChevronDown, ChevronUp } from 'lucide-react'; + +interface Comment { + id: string; + author: string; + avatar: string; + content: string; + timestamp: string; + replies?: Comment[]; +} + +interface BountyDiscussionProps { + bountyId: string; + comments?: Comment[]; +} + +function timeAgo(dateStr: string): string { + const diff = Date.now() - new Date(dateStr).getTime(); + const mins = Math.floor(diff / 60000); + if (mins < 60) return mins + 'm ago'; + const hrs = Math.floor(mins / 60); + if (hrs < 24) return hrs + 'h ago'; + return Math.floor(hrs / 24) + 'd ago'; +} + +function CommentThread({ comment, depth = 0 }: { comment: Comment; depth?: number }) { + const [showReplies, setShowReplies] = useState(depth < 1); + const [replyText, setReplyText] = useState(''); + const [showReplyInput, setShowReplyInput] = useState(false); + + return ( +
{comment.content}
+