Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 🐛 adjust avatar component to prevent hydration errors #1022

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
`;