Skip to content

Commit

Permalink
fix(avatar): object fit to properly handle non-squared images (#4298)
Browse files Browse the repository at this point in the history
* fix(avatar): object fit to properly handle non-squared images

* chore(avatar): add non square aspect ratio story

---------

Co-authored-by: Maksim Nedoshev <m0ksem1337@gmail.com>
  • Loading branch information
untael and m0ksem authored Jun 3, 2024
1 parent 6bd8ea7 commit 69a3202
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/ui/src/components/va-avatar/VaAvatar.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ export const Square = () => ({
`,
})

/** Must be centered image */
export const NonSquareAspectRation = () => ({
components: { VaAvatar },
template: `
<VaAvatar src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_light_color_272x92dp.png" />
`,
})

export const Loading = () => ({
components: { VaAvatar },
template: '<VaAvatar loading/>',
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/components/va-avatar/VaAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ defineExpose({
img,
svg {
object-fit: var(--va-avatar-object-fit);
border-radius: inherit;
display: inline-flex;
height: inherit;
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/components/va-avatar/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
--va-avatar-position: relative;
--va-avatar-line-height: normal;
--va-avatar-border-radius: 50%;
--va-avatar-object-fit: cover;
}

0 comments on commit 69a3202

Please sign in to comment.