Skip to content

Commit

Permalink
fix(Avatar): add responsive image handling to component
Browse files Browse the repository at this point in the history
  • Loading branch information
booc0mtaco committed Jul 10, 2023
1 parent 682c029 commit 9788e8c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/Avatar/Avatar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@
.avatar--circle {
border-radius: var(--eds-border-radius-round);
}

.avatar__image {
width: 100%;
}
4 changes: 3 additions & 1 deletion src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ export const Avatar = ({
>
{variant === 'initials' && (user ? getInitials(user.fullName) : '??')}
{variant === 'icon' && <Icon name="person" purpose="decorative" />}
{variant === 'image' && <img alt="user" src={src} />}
{variant === 'image' && (
<img alt="user" className={styles['avatar__image']} src={src} />
)}
</div>
);
};
1 change: 1 addition & 0 deletions src/components/Avatar/__snapshots__/Avatar.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ exports[`<Avatar /> UsingImage story renders snapshot 1`] = `
>
<img
alt="user"
class="avatar__image"
src="data:image/svg+xml,%3csvg width='38' height='37' viewBox='0 0 38 37' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M19 17.9417C16.4333 17.9417 14.3333 17.125 12.7 15.4917C11.0667 13.8583 10.25 11.7583 10.25 9.19168C10.25 6.62502 11.0667 4.52501 12.7 2.89168C14.3333 1.25835 16.4333 0.441681 19 0.441681C21.5667 0.441681 23.6667 1.25835 25.3 2.89168C26.9333 4.52501 27.75 6.62502 27.75 9.19168C27.75 11.7583 26.9333 13.8583 25.3 15.4917C23.6667 17.125 21.5667 17.9417 19 17.9417ZM0.333344 36.6667V31.1833C0.333344 29.7056 0.702788 28.4417 1.44168 27.3917C2.18057 26.3417 3.13334 25.5445 4.30001 25C6.90557 23.8333 9.40418 22.9583 11.7958 22.375C14.1875 21.7917 16.5889 21.5 19 21.5C21.4111 21.5 23.8028 21.8014 26.175 22.4042C28.5472 23.007 31.0361 23.8722 33.6417 25C34.8472 25.5445 35.8195 26.3417 36.5583 27.3917C37.2972 28.4417 37.6667 29.7056 37.6667 31.1833V36.6667H0.333344Z' fill='%235D6369'/%3e%3c/svg%3e"
/>
</div>
Expand Down

0 comments on commit 9788e8c

Please sign in to comment.