Remove unnecessary avatar wrapper div

This commit is contained in:
Marshall Polaris 2022-05-03 22:37:29 -07:00
parent 02e7efe30c
commit ca6c14de50
2 changed files with 22 additions and 27 deletions

View File

@ -10,8 +10,7 @@ export function Avatar(props: {
className?: string className?: string
containerClassName?: 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 +20,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(
'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 +36,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>
) )
} }

View File

@ -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}