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
|
||||
size?: number | 'xs' | 'sm'
|
||||
className?: string
|
||||
containerClassName?: string
|
||||
}) {
|
||||
const { username, avatarUrl, noLink, size, className, containerClassName } =
|
||||
props
|
||||
const { username, avatarUrl, noLink, size, className } = props
|
||||
const s = size == 'xs' ? 6 : size === 'sm' ? 8 : size || 10
|
||||
|
||||
const onClick =
|
||||
|
@ -21,17 +19,13 @@ export function Avatar(props: {
|
|||
e.stopPropagation()
|
||||
Router.push(`/${username}`)
|
||||
}
|
||||
return (
|
||||
<div
|
||||
className={clsx(
|
||||
`flex-shrink-0 rounded-full bg-white w-${s} h-${s}`,
|
||||
containerClassName
|
||||
)}
|
||||
>
|
||||
{avatarUrl ? (
|
||||
|
||||
// there can be no avatar URL or username in the feed, we show a "submit comment"
|
||||
// item with a fake grey user circle guy even if you aren't signed in
|
||||
return avatarUrl ? (
|
||||
<img
|
||||
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}`,
|
||||
!noLink && 'cursor-pointer',
|
||||
className
|
||||
|
@ -41,12 +35,12 @@ export function Avatar(props: {
|
|||
alt={username}
|
||||
/>
|
||||
) : (
|
||||
// TODO: After 2022-03-01, can just assume that all contracts have an avatarUrl
|
||||
<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"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -262,9 +262,7 @@ export function CommentInput(props: {
|
|||
return (
|
||||
<>
|
||||
<Row className={'flex w-full gap-2'}>
|
||||
<div>
|
||||
<Avatar avatarUrl={user?.avatarUrl} username={user?.username} />
|
||||
</div>
|
||||
<div className={'min-w-0 flex-1'}>
|
||||
<div className="text-sm text-gray-500">
|
||||
{mostRecentCommentableBet && (
|
||||
|
@ -413,7 +411,6 @@ export function FeedBet(props: {
|
|||
return (
|
||||
<>
|
||||
<Row className={'flex w-full gap-2 pt-3'}>
|
||||
<div>
|
||||
{isSelf ? (
|
||||
<Avatar
|
||||
className={clsx(smallAvatar && 'ml-1')}
|
||||
|
@ -431,14 +428,10 @@ export function FeedBet(props: {
|
|||
) : (
|
||||
<div className="relative px-1">
|
||||
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-gray-200">
|
||||
<UserIcon
|
||||
className="h-5 w-5 text-gray-500"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<UserIcon className="h-5 w-5 text-gray-500" aria-hidden="true" />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className={'min-w-0 flex-1 py-1.5'}>
|
||||
<BetStatusText
|
||||
bet={bet}
|
||||
|
@ -807,10 +800,8 @@ function FeedAnswerGroup(props: {
|
|||
|
||||
<Row className="my-4 gap-3">
|
||||
<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} />
|
||||
</div>
|
||||
</div>
|
||||
<Col className="min-w-0 flex-1 gap-2">
|
||||
<div className="text-sm text-gray-500">
|
||||
<UserLink username={username} name={name} /> answered
|
||||
|
|
|
@ -60,7 +60,7 @@ export function BottomNavBar() {
|
|||
) : user ? (
|
||||
<>
|
||||
<Avatar
|
||||
containerClassName={'mx-auto my-1'}
|
||||
className="mx-auto my-1"
|
||||
size="xs"
|
||||
username={user.username}
|
||||
avatarUrl={user.avatarUrl}
|
||||
|
|
Loading…
Reference in New Issue
Block a user