Skip to content

Commit

Permalink
chore: 🐛 adjust avatar component to prevent hydration errors
Browse files Browse the repository at this point in the history
#TECH-1321
  • Loading branch information
birterohden committed Jan 30, 2025
1 parent e5a2c64 commit 9012e03
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
8 changes: 5 additions & 3 deletions packages/components/src/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export interface AvatarProps extends Omit<AvatarImageProps, 'className'> {
textColor?: TextColorProps['color'];
}

const AvatarPlaceholder = styled((props) => <Placeholder {...props} />)`
const AvatarPlaceholder = styled((props) => (
<Placeholder as="span" {...props} />
))`
${({ theme }) =>
border({
theme,
Expand All @@ -40,7 +42,7 @@ const AvatarPlaceholder = styled((props) => <Placeholder {...props} />)`
})};
`;

const DefaultAvatar = styled((props) => <Box {...props} />)`
const DefaultAvatar = styled((props) => <Box as="span" {...props} />)`
${({ theme }) =>
border({
theme,
Expand Down Expand Up @@ -128,7 +130,7 @@ const StyledAvatarImage = styled(AvatarImage)<{ src?: string }>`
box-sizing: border-box;
`;

const StyledAvatar = styled.div`
const StyledAvatar = styled.span`
display: flex;
align-items: center;
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ exports[`Avatar matches snapshot and renders label 1`] = `
padding-left: 8px;
}
<div
<span
class="c0"
>
<div
<span
class="c1 c2"
display="flex"
height="40px"
Expand All @@ -72,13 +72,13 @@ exports[`Avatar matches snapshot and renders label 1`] = `
>
a
</p>
</div>
</span>
<span
class="c5"
>
Some author
</span>
</div>
</span>
`;

exports[`Avatar renders without label 1`] = `
Expand Down Expand Up @@ -135,10 +135,10 @@ exports[`Avatar renders without label 1`] = `
align-items: center;
}
<div
<span
class="c0"
>
<div
<span
class="c1 c2"
display="flex"
height="40px"
Expand All @@ -149,6 +149,6 @@ exports[`Avatar renders without label 1`] = `
>
a
</p>
</div>
</div>
</span>
</span>
`;

0 comments on commit 9012e03

Please sign in to comment.