({
postItem,
showButtons = true,
clickable = true,
onHide,
className,
showVoteActions = false,
logOrigin = Origin.Feed,
indexes,
}: PostItemCardProps)
| 42 | ); |
| 43 | |
| 44 | export 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', |
nothing calls this directly
no test coverage detected