Skip to content

Commit

Permalink
fix: avatar not centered background color (#359)
Browse files Browse the repository at this point in the history
* fix: center + clean up avatar image

* chore: add changeset

* fix: tx spinner was always on

* fix: rmv loading requirement
  • Loading branch information
nicoglennon committed May 11, 2022
1 parent 36aed61 commit 85be3f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-toes-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rainbow-me/rainbowkit': patch
---

Avatar image is now correctly centered, and background + emoji are hidden if image is present.
12 changes: 8 additions & 4 deletions packages/rainbowkit/src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function Avatar({ address, imageUrl, loading, size }: AvatarProps) {
overflow="hidden"
position="absolute"
style={{
backgroundColor,
...(!imageUrl && { backgroundColor }),
fontSize: `${Math.round(size * 0.55)}px`,
height: `${size}px`,
transform: loading ? 'scale(0.72)' : undefined,
Expand All @@ -53,11 +53,15 @@ export function Avatar({ address, imageUrl, loading, size }: AvatarProps) {
borderRadius="full"
height="full"
position="absolute"
style={{ backgroundImage: `url(${imageUrl})` }}
style={{
backgroundImage: `url(${imageUrl})`,
backgroundPosition: 'center',
}}
width="full"
/>
) : null}
{emoji}
) : (
emoji
)}
</Box>
{typeof loading === 'boolean' && (
<Box
Expand Down

2 comments on commit 85be3f8

@vercel
Copy link

@vercel vercel bot commented on 85be3f8 May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 85be3f8 May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.