Cleanup avatar again (#161)
* Reinstate avatar component cleanup This was reverted due to a bug, fixed in the subsequent commit. * Kill additional wrapper divs around avatars This also fixes a bug where the `w-8` answer row wrapper div was constraining the width of the `w-10` avatar, leading it to be `w-8` and `h-10` and appear as an oval.
This commit is contained in:
parent
9fc9fc0dd6
commit
8a99f3772a
|
@ -8,10 +8,8 @@ export function Avatar(props: {
|
||||||
noLink?: boolean
|
noLink?: boolean
|
||||||
size?: number | 'xs' | 'sm'
|
size?: number | 'xs' | 'sm'
|
||||||
className?: string
|
className?: string
|
||||||
containerClassName?: string
|
|
||||||
}) {
|
}) {
|
||||||
const { username, avatarUrl, noLink, size, className, containerClassName } =
|
const { username, avatarUrl, noLink, size, className } = props
|
||||||
props
|
|
||||||
const s = size == 'xs' ? 6 : size === 'sm' ? 8 : size || 10
|
const s = size == 'xs' ? 6 : size === 'sm' ? 8 : size || 10
|
||||||
|
|
||||||
const onClick =
|
const onClick =
|
||||||
|
@ -21,17 +19,13 @@ export function Avatar(props: {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
Router.push(`/${username}`)
|
Router.push(`/${username}`)
|
||||||
}
|
}
|
||||||
return (
|
|
||||||
<div
|
// there can be no avatar URL or username in the feed, we show a "submit comment"
|
||||||
className={clsx(
|
// item with a fake grey user circle guy even if you aren't signed in
|
||||||
`flex-shrink-0 rounded-full bg-white w-${s} h-${s}`,
|
return avatarUrl ? (
|
||||||
containerClassName
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{avatarUrl ? (
|
|
||||||
<img
|
<img
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'flex items-center justify-center rounded-full object-cover',
|
'flex-shrink-0 rounded-full rounded-full bg-white object-cover',
|
||||||
`w-${s} h-${s}`,
|
`w-${s} h-${s}`,
|
||||||
!noLink && 'cursor-pointer',
|
!noLink && 'cursor-pointer',
|
||||||
className
|
className
|
||||||
|
@ -41,12 +35,12 @@ export function Avatar(props: {
|
||||||
alt={username}
|
alt={username}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
// TODO: After 2022-03-01, can just assume that all contracts have an avatarUrl
|
|
||||||
<UserCircleIcon
|
<UserCircleIcon
|
||||||
className={`w-${s} h-${s} text-gray-500`}
|
className={clsx(
|
||||||
|
`flex-shrink-0 rounded-full bg-white w-${s} h-${s} text-gray-500`,
|
||||||
|
className
|
||||||
|
)}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,9 +262,7 @@ export function CommentInput(props: {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Row className={'flex w-full gap-2'}>
|
<Row className={'flex w-full gap-2'}>
|
||||||
<div>
|
|
||||||
<Avatar avatarUrl={user?.avatarUrl} username={user?.username} />
|
<Avatar avatarUrl={user?.avatarUrl} username={user?.username} />
|
||||||
</div>
|
|
||||||
<div className={'min-w-0 flex-1'}>
|
<div className={'min-w-0 flex-1'}>
|
||||||
<div className="text-sm text-gray-500">
|
<div className="text-sm text-gray-500">
|
||||||
{mostRecentCommentableBet && (
|
{mostRecentCommentableBet && (
|
||||||
|
@ -413,7 +411,6 @@ export function FeedBet(props: {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Row className={'flex w-full gap-2 pt-3'}>
|
<Row className={'flex w-full gap-2 pt-3'}>
|
||||||
<div>
|
|
||||||
{isSelf ? (
|
{isSelf ? (
|
||||||
<Avatar
|
<Avatar
|
||||||
className={clsx(smallAvatar && 'ml-1')}
|
className={clsx(smallAvatar && 'ml-1')}
|
||||||
|
@ -431,14 +428,10 @@ export function FeedBet(props: {
|
||||||
) : (
|
) : (
|
||||||
<div className="relative px-1">
|
<div className="relative px-1">
|
||||||
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-gray-200">
|
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-gray-200">
|
||||||
<UserIcon
|
<UserIcon className="h-5 w-5 text-gray-500" aria-hidden="true" />
|
||||||
className="h-5 w-5 text-gray-500"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
|
||||||
<div className={'min-w-0 flex-1 py-1.5'}>
|
<div className={'min-w-0 flex-1 py-1.5'}>
|
||||||
<BetStatusText
|
<BetStatusText
|
||||||
bet={bet}
|
bet={bet}
|
||||||
|
@ -807,10 +800,8 @@ function FeedAnswerGroup(props: {
|
||||||
|
|
||||||
<Row className="my-4 gap-3">
|
<Row className="my-4 gap-3">
|
||||||
<div className="px-1">
|
<div className="px-1">
|
||||||
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-gray-200">
|
|
||||||
<Avatar username={username} avatarUrl={avatarUrl} />
|
<Avatar username={username} avatarUrl={avatarUrl} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<Col className="min-w-0 flex-1 gap-2">
|
<Col className="min-w-0 flex-1 gap-2">
|
||||||
<div className="text-sm text-gray-500">
|
<div className="text-sm text-gray-500">
|
||||||
<UserLink username={username} name={name} /> answered
|
<UserLink username={username} name={name} /> answered
|
||||||
|
|
|
@ -60,7 +60,7 @@ export function BottomNavBar() {
|
||||||
) : user ? (
|
) : user ? (
|
||||||
<>
|
<>
|
||||||
<Avatar
|
<Avatar
|
||||||
containerClassName={'mx-auto my-1'}
|
className="mx-auto my-1"
|
||||||
size="xs"
|
size="xs"
|
||||||
username={user.username}
|
username={user.username}
|
||||||
avatarUrl={user.avatarUrl}
|
avatarUrl={user.avatarUrl}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user