import { track } from '@amplitude/analytics-browser' import { DocumentIcon } from '@heroicons/react/solid' import clsx from 'clsx' import { Post } from 'common/post' import Link from 'next/link' import { useUserById } from 'web/hooks/use-user' import { postPath } from 'web/lib/firebase/posts' import { fromNow } from 'web/lib/util/time' import { Avatar } from './avatar' import { CardHighlightOptions } from './contract/contracts-grid' import { Row } from './layout/row' import { UserLink } from './user-link' export function PostCard(props: { post: Post onPostClick?: (post: Post) => void highlightOptions?: CardHighlightOptions }) { const { post, onPostClick, highlightOptions } = props const creatorId = post.creatorId const user = useUserById(creatorId) const { itemIds: itemIds, highlightClassName } = highlightOptions || {} if (!user) return <> return (
{fromNow(post.createdTime)}
{post.title}
{post.subtitle}
Post
{onPostClick ? ( { // Let the browser handle the link click (opens in new tab). if (e.ctrlKey || e.metaKey) return e.preventDefault() track('select post card'), { slug: post.slug, postId: post.id, } onPostClick(post) }} /> ) : ( { track('select post card'), { slug: post.slug, postId: post.id, } }} className="absolute top-0 left-0 right-0 bottom-0" /> )}
) } export function PostCardList(props: { posts: Post[] highlightOptions?: CardHighlightOptions onPostClick?: (post: Post) => void }) { const { posts, onPostClick, highlightOptions } = props return (
{posts.map((post) => ( ))}
) }