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 { postPath } from 'web/lib/firebase/posts' import { fromNow } from 'web/lib/util/time' import { Avatar } from './avatar' import { Card } from './card' import { CardHighlightOptions } from './contract/contracts-grid' import { Col } from './layout/col' 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 { itemIds: itemIds, highlightClassName } = highlightOptions || {} return ( {fromNow(post.createdTime)}
Post
{post.title}
{post.subtitle}
{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) => ( ))}
) }