| // src/components/networking/ActivityFeedPost.tsx | |
| import { Heart, MessageCircle, Share2, Bookmark, Eye, MoreHorizontal, User } from "lucide-react"; | |
| import type { FeedItem } from "@/types/networking"; | |
| import { useNavigate } from "react-router-dom"; | |
| import { useState } from "react"; | |
| import { PollWidget } from "@/components/social/PollWidget"; // reuse from stories | |
| interface ActivityFeedPostProps { | |
| item: FeedItem; | |
| onBookmark: (id: string) => void; | |
| } | |
| export function ActivityFeedPost({ item, onBookmark }: ActivityFeedPostProps) { | |
| const navigate = useNavigate(); | |
| const [liked, setLiked] = useState(false); | |
| const handleClick = () => { | |
| if (item.targetLink) navigate(item.targetLink); | |
| }; | |
| return ( | |
| <div className="glass rounded-2xl border border-white/20 dark:border-white/10 overflow-hidden"> | |
| {/* Header */} | |
| <div className="flex items-center gap-3 px-4 py-3 cursor-pointer" onClick={() => navigate(`/users/${item.actor.username}`)}> | |
| <div className="w-10 h-10 rounded-full bg-linear-to-br from-primary to-secondary text-white flex items-center justify-center font-bold"> | |
| {(item.actor.fullName ?? item.actor.username)[0]?.toUpperCase()} | |
| </div> | |
| <div className="flex-1"> | |
| <p className="font-semibold text-sm">{item.actor.fullName}</p> | |
| <div className="flex items-center gap-2 text-xs text-gray-500"> | |
| {item.actor.affiliation && <span>{item.actor.affiliation}</span>} | |
| <span>·</span> | |
| <span>{new Date(item.timestamp).toLocaleDateString()}</span> | |
| </div> | |
| </div> | |
| <button className="text-gray-400"><MoreHorizontal className="w-4 h-4" /></button> | |
| </div> | |
| {/* Body */} | |
| <div className="px-4 pb-3 cursor-pointer" onClick={handleClick}> | |
| <div className="flex items-center gap-2 mb-1"> | |
| <span className="text-[10px] px-2 py-0.5 rounded-full bg-primary/10 text-primary capitalize">{item.type.replace(/_/g, " ")}</span> | |
| {item.target && <span className="text-xs text-gray-500">· {item.target}</span>} | |
| </div> | |
| <p className="text-sm text-gray-800 dark:text-gray-200 whitespace-pre-wrap">{item.body}</p> | |
| </div> | |
| {/* Media / Carousel */} | |
| {item.media && item.media.urls.length > 0 && ( | |
| <div className={`${item.media.urls.length > 1 ? "flex overflow-x-auto snap-x" : ""}`} onClick={handleClick}> | |
| {item.media.urls.map((url, i) => ( | |
| <img key={i} src={url} alt="" className={`${item.media!.urls.length > 1 ? "w-full snap-center" : "w-full"} max-h-80 object-cover cursor-pointer`} /> | |
| ))} | |
| </div> | |
| )} | |
| {/* Poll */} | |
| {item.poll && ( | |
| <div className="px-4 pb-3"> | |
| <PollWidget | |
| pollId={item.id} | |
| question={item.poll.question} | |
| options={item.poll.options.map((text, i) => ({ id: `${item.id}-${i}`, text, votes: 0 }))} | |
| /> | |
| </div> | |
| )} | |
| {/* Stats & Actions */} | |
| <div className="px-4 py-2 border-t border-white/10 flex items-center justify-between"> | |
| <div className="flex items-center gap-1 text-xs text-gray-400"> | |
| {item.stats.views > 0 && <span><Eye className="w-3.5 h-3.5 inline mr-0.5" />{item.stats.views}</span>} | |
| </div> | |
| <div className="flex items-center gap-4"> | |
| <button onClick={() => setLiked(!liked)} className={`flex items-center gap-1 text-xs ${liked ? "text-red-500" : "text-gray-500 hover:text-red-500"}`}> | |
| <Heart className={`w-4 h-4 ${liked ? "fill-current" : ""}`} /> {item.stats.likes + (liked ? 1 : 0)} | |
| </button> | |
| <button className="flex items-center gap-1 text-xs text-gray-500 hover:text-primary"> | |
| <MessageCircle className="w-4 h-4" /> {item.stats.comments} | |
| </button> | |
| <button className="flex items-center gap-1 text-xs text-gray-500 hover:text-primary"> | |
| <Share2 className="w-4 h-4" /> | |
| </button> | |
| <button onClick={() => onBookmark(item.id)} | |
| className={`flex items-center gap-1 text-xs ${item.isBookmarked ? "text-amber-500" : "text-gray-500 hover:text-amber-500"}`}> | |
| <Bookmark className={`w-4 h-4 ${item.isBookmarked ? "fill-current" : ""}`} /> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| } | |
Xet Storage Details
- Size:
- 4.32 kB
- Xet hash:
- e94b0533516b658f5c5ecdf226bd61f6837771eecf1c3c29fb19a9512ded7f77
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.