import { AppBskyFeedDefs, AppBskyFeedPost } from 'npm:@atproto/api'; type CommentProps = { comment: AppBskyFeedDefs.ThreadViewPost; filters?: Array<(arg: any) => boolean>; }; export const Comment = ({ comment, filters }: CommentProps) => { const author = comment.post.author; const avatarClassName = "avatar"; if (!AppBskyFeedPost.isRecord(comment.post.record)) return null; // filter out replies that match any of the commentFilters, by ensuring they all return false if (filters && !filters.every((filter) => !filter(comment))) return null; const styles = ` .container { max-width: 740px; margin: 0 auto; } .statsBar { display: flex; align-items: center; gap: 0.5rem; } .statsBar:hover { text-decoration: underline; } .statItem { display: flex; align-items: center; gap: 0.25rem; white-space: nowrap; } .container a.link { text-decoration: underline; } .container a.link:hover { text-decoration: underline; } .icon { width: 1.25rem; height: 1.25rem; } .errorText, .loadingText { text-align: center; } .commentsTitle { margin-top: 1.5rem; font-size: 1.25rem; font-weight: bold; } .replyText { margin-top: 0.5rem; font-size: 0.875rem; } .divider { margin-top: 0.5rem; } .commentsList { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; } .container .showMoreButton { margin-top: 0.5rem; font-size: 0.875rem; text-decoration: underline; } .container .showMoreButton:hover { text-decoration: underline; } .commentContainer { margin: 1rem 0; font-size: 0.875rem; } .commentContent { display: flex; max-width: 36rem; flex-direction: column; gap: 0.5rem; } .authorLink { display: flex; flex-direction: row; justify-content: flex-start; align-items: center; gap: 0.5rem; } .authorLink:hover { text-decoration: underline; } .avatar { height: 1rem; width: 1rem; flex-shrink: 0; border-radius: 9999px; background-color: #d1d5db; } .authorName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; } .container a { text-decoration: none; color: inherit; } .container a:hover { text-decoration: none; } .commentContent .handle { color: #6b7280; } .repliesContainer { border-left: 2px solid #525252; padding-left: 0.5rem; } .actionsContainer { margin-top: 0.5rem; display: flex; width: 100%; max-width: 150px; flex-direction: row; align-items: center; justify-content: space-between; opacity: 0.6; } .actionsRow { display: flex; align-items: center; gap: 0.25rem; } `; return (
{author.displayName ?? author.handle}{' '} @{author.handle}
{(comment.post.record as AppBskyFeedPost.Record).text}
{post.replyCount ?? 0}
{post.repostCount ?? 0}
{post.likeCount ?? 0}