Small avatars for nested feed items
This commit is contained in:
parent
5524889d48
commit
7ca0b3662f
|
@ -6,11 +6,11 @@ export function Avatar(props: {
|
||||||
username?: string
|
username?: string
|
||||||
avatarUrl?: string
|
avatarUrl?: string
|
||||||
noLink?: boolean
|
noLink?: boolean
|
||||||
size?: number
|
size?: number | 'xs' | 'sm'
|
||||||
className?: string
|
className?: string
|
||||||
}) {
|
}) {
|
||||||
const { username, avatarUrl, noLink, size, className } = props
|
const { username, avatarUrl, noLink, size, className } = props
|
||||||
const s = size || 10
|
const s = size == 'xs' ? 6 : size === 'sm' ? 8 : size || 10
|
||||||
|
|
||||||
const onClick =
|
const onClick =
|
||||||
noLink && username
|
noLink && username
|
||||||
|
|
|
@ -37,6 +37,7 @@ export type BetItem = BaseActivityItem & {
|
||||||
type: 'bet'
|
type: 'bet'
|
||||||
bet: Bet
|
bet: Bet
|
||||||
hideOutcome: boolean
|
hideOutcome: boolean
|
||||||
|
smallAvatar: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CommentItem = BaseActivityItem & {
|
export type CommentItem = BaseActivityItem & {
|
||||||
|
@ -45,6 +46,7 @@ export type CommentItem = BaseActivityItem & {
|
||||||
bet: Bet
|
bet: Bet
|
||||||
hideOutcome: boolean
|
hideOutcome: boolean
|
||||||
truncate: boolean
|
truncate: boolean
|
||||||
|
smallAvatar: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CreateAnswerItem = BaseActivityItem & {
|
export type CreateAnswerItem = BaseActivityItem & {
|
||||||
|
@ -88,9 +90,10 @@ function groupBets(
|
||||||
options: {
|
options: {
|
||||||
hideOutcome: boolean
|
hideOutcome: boolean
|
||||||
abbreviated: boolean
|
abbreviated: boolean
|
||||||
|
smallAvatar: boolean
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
const { hideOutcome, abbreviated } = options
|
const { hideOutcome, abbreviated, smallAvatar } = options
|
||||||
|
|
||||||
const commentsMap = mapCommentsByBetId(comments)
|
const commentsMap = mapCommentsByBetId(comments)
|
||||||
const items: ActivityItem[] = []
|
const items: ActivityItem[] = []
|
||||||
|
@ -123,6 +126,7 @@ function groupBets(
|
||||||
contract,
|
contract,
|
||||||
hideOutcome,
|
hideOutcome,
|
||||||
truncate: abbreviated,
|
truncate: abbreviated,
|
||||||
|
smallAvatar,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
type: 'bet' as const,
|
type: 'bet' as const,
|
||||||
|
@ -130,6 +134,7 @@ function groupBets(
|
||||||
bet,
|
bet,
|
||||||
contract,
|
contract,
|
||||||
hideOutcome,
|
hideOutcome,
|
||||||
|
smallAvatar,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +218,7 @@ function getAnswerGroups(
|
||||||
DAY_IN_MS,
|
DAY_IN_MS,
|
||||||
contract,
|
contract,
|
||||||
user?.id,
|
user?.id,
|
||||||
{ hideOutcome: true, abbreviated }
|
{ hideOutcome: true, abbreviated, smallAvatar: true }
|
||||||
)
|
)
|
||||||
|
|
||||||
if (abbreviated) items = items.slice(-2)
|
if (abbreviated) items = items.slice(-2)
|
||||||
|
@ -272,6 +277,7 @@ export function getAllContractActivityItems(
|
||||||
: groupBets(bets, comments, DAY_IN_MS, contract, user?.id, {
|
: groupBets(bets, comments, DAY_IN_MS, contract, user?.id, {
|
||||||
hideOutcome: !!filterToOutcome,
|
hideOutcome: !!filterToOutcome,
|
||||||
abbreviated,
|
abbreviated,
|
||||||
|
smallAvatar: !!filterToOutcome,
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -310,6 +316,7 @@ export function getRecentContractActivityItems(
|
||||||
: groupBets(bets, comments, DAY_IN_MS, contract, user?.id, {
|
: groupBets(bets, comments, DAY_IN_MS, contract, user?.id, {
|
||||||
hideOutcome: false,
|
hideOutcome: false,
|
||||||
abbreviated: true,
|
abbreviated: true,
|
||||||
|
smallAvatar: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
return [questionItem, ...items]
|
return [questionItem, ...items]
|
||||||
|
|
|
@ -111,8 +111,9 @@ function FeedComment(props: {
|
||||||
bet: Bet
|
bet: Bet
|
||||||
hideOutcome: boolean
|
hideOutcome: boolean
|
||||||
truncate: boolean
|
truncate: boolean
|
||||||
|
smallAvatar: boolean
|
||||||
}) {
|
}) {
|
||||||
const { contract, comment, bet, hideOutcome, truncate } = props
|
const { contract, comment, bet, hideOutcome, truncate, smallAvatar } = props
|
||||||
const { amount, outcome } = bet
|
const { amount, outcome } = bet
|
||||||
const { text, userUsername, userName, userAvatarUrl, createdTime } = comment
|
const { text, userUsername, userName, userAvatarUrl, createdTime } = comment
|
||||||
|
|
||||||
|
@ -121,7 +122,12 @@ function FeedComment(props: {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Avatar username={userUsername} avatarUrl={userAvatarUrl} />
|
<Avatar
|
||||||
|
className={clsx(smallAvatar && 'ml-1')}
|
||||||
|
size={smallAvatar ? 'sm' : undefined}
|
||||||
|
username={userUsername}
|
||||||
|
avatarUrl={userAvatarUrl}
|
||||||
|
/>
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
<div>
|
<div>
|
||||||
<p className="mt-0.5 text-sm text-gray-500">
|
<p className="mt-0.5 text-sm text-gray-500">
|
||||||
|
@ -165,8 +171,9 @@ function FeedBet(props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
bet: Bet
|
bet: Bet
|
||||||
hideOutcome: boolean
|
hideOutcome: boolean
|
||||||
|
smallAvatar: boolean
|
||||||
}) {
|
}) {
|
||||||
const { contract, bet, hideOutcome } = props
|
const { contract, bet, hideOutcome, smallAvatar } = props
|
||||||
const { id, amount, outcome, createdTime, userId } = bet
|
const { id, amount, outcome, createdTime, userId } = bet
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
const isSelf = user?.id === userId
|
const isSelf = user?.id === userId
|
||||||
|
@ -194,9 +201,16 @@ function FeedBet(props: {
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
{isSelf ? (
|
{isSelf ? (
|
||||||
<Avatar avatarUrl={user.avatarUrl} username={user.username} />
|
<Avatar
|
||||||
|
className={clsx(smallAvatar && 'ml-1')}
|
||||||
|
size={smallAvatar ? 'sm' : undefined}
|
||||||
|
avatarUrl={user.avatarUrl}
|
||||||
|
username={user.username}
|
||||||
|
/>
|
||||||
) : isCreator ? (
|
) : isCreator ? (
|
||||||
<Avatar
|
<Avatar
|
||||||
|
className={clsx(smallAvatar && 'ml-1')}
|
||||||
|
size={smallAvatar ? 'sm' : undefined}
|
||||||
avatarUrl={contract.creatorAvatarUrl}
|
avatarUrl={contract.creatorAvatarUrl}
|
||||||
username={contract.creatorUsername}
|
username={contract.creatorUsername}
|
||||||
/>
|
/>
|
||||||
|
@ -504,11 +518,16 @@ function FeedDescription(props: { contract: Contract }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function FeedCreateAnswer(props: { contract: Contract; answer: Answer }) {
|
function FeedCreateAnswer(props: { contract: Contract; answer: Answer }) {
|
||||||
const { contract, answer } = props
|
const { answer } = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Avatar username={answer.username} avatarUrl={answer.avatarUrl} />
|
<Avatar
|
||||||
|
className="ml-1"
|
||||||
|
size="sm"
|
||||||
|
username={answer.username}
|
||||||
|
avatarUrl={answer.avatarUrl}
|
||||||
|
/>
|
||||||
<div className="min-w-0 flex-1 py-1.5">
|
<div className="min-w-0 flex-1 py-1.5">
|
||||||
<div className="text-sm text-gray-500">
|
<div className="text-sm text-gray-500">
|
||||||
<UserLink
|
<UserLink
|
||||||
|
|
Loading…
Reference in New Issue
Block a user