MCPcopy Create free account
hub / github.com/dailydotdev/apps / PostItemCard

Function PostItemCard

packages/shared/src/components/post/PostItemCard.tsx:44–206  ·  view source on GitHub ↗
({
  postItem,
  showButtons = true,
  clickable = true,
  onHide,
  className,
  showVoteActions = false,
  logOrigin = Origin.Feed,
  indexes,
}: PostItemCardProps)

Source from the content-addressed store, hash-verified

42);
43
44export default function PostItemCard({
45 postItem,
46 showButtons = true,
47 clickable = true,
48 onHide,
49 className,
50 showVoteActions = false,
51 logOrigin = Origin.Feed,
52 indexes,
53}: PostItemCardProps): ReactElement {
54 const { timestampDb, post } = postItem;
55 const { source } = post;
56 const sourceImage = source?.image ?? '';
57 const onHideClick = (e: MouseEvent) => {
58 e.stopPropagation();
59 e.preventDefault();
60 if (!onHide || !timestampDb) {
61 return;
62 }
63 onHide({ postId: post.id, timestamp: timestampDb });
64 };
65 const article = post?.sharedPost ?? post;
66 const isUserSource = isSourceUserSource(source);
67
68 const { toggleUpvote, toggleDownvote } = useReadHistoryVotePost();
69
70 const classes = classNames(
71 'relative flex w-full flex-row py-3 pl-9 pr-5',
72 showVoteActions ? 'items-start tablet:items-center' : 'items-center',
73 clickable && 'hover:cursor-pointer hover:bg-surface-hover',
74 className,
75 );
76
77 const title = post?.title || post?.sharedPost?.title;
78
79 return (
80 <article className={classNames(!clickable && classes)}>
81 <ConditionalWrapper
82 condition={clickable}
83 wrapper={(children) => (
84 <Link href={post.commentsPermalink}>
85 <a className={classes} title="Go to post">
86 {children}
87 </a>
88 </Link>
89 )}
90 >
91 <>
92 <Image
93 src={article.image}
94 alt={post.title}
95 className="h-16 w-16 rounded-16 object-cover laptop:w-24"
96 loading="lazy"
97 fallbackSrc={cloudinaryPostImageCoverPlaceholder}
98 />
99 <SourceShadow
100 className={classNames(
101 showVoteActions && 'top-8',

Callers

nothing calls this directly

Calls 4

isSourceUserSourceFunction · 0.90
useReadHistoryVotePostFunction · 0.90
isVideoPostFunction · 0.90
onHideFunction · 0.85

Tested by

no test coverage detected