Skip to content

Commit 7ff87fc

Browse files
authored
feat(b-avatar): if variant is empty string, then remove spacing around image (closes #5154) (#5156)
Co-authored-by: Jacob Müller
1 parent 8f3ec59 commit 7ff87fc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/components/avatar/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ and will be sized to show the avatar's [variant background](#variants) around th
8484
fallback to the value of the `icon` or `text` props. If neither the `icon` or `text` props are
8585
provided, then the default avatar icon will be shown. Also, when the image fails to load, the
8686
`img-error` event will be emitted.
87+
- <span class="badge badge-secondary">2.12.0+</span> Setting the [variant prop](#variants) to an
88+
empty string will remove the visible background border around the image.
8789

8890
### Icon content
8991

@@ -301,7 +303,7 @@ The `to` prop can either be a string path, or a `Location` object. The `to` prop
301303
```html
302304
<template>
303305
<div>
304-
<b-avatar href="#foobar"variant="info" src="https://placekitten.com/300/300"></b-avatar>
306+
<b-avatar href="#foobar" variant="info" src="https://placekitten.com/300/300"></b-avatar>
305307
Link Avatar
306308
</div>
307309
</template>

src/components/avatar/avatar.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,11 @@ export const BAvatar = /*#__PURE__*/ Vue.extend({
226226
// Default slot overrides props
227227
$content = h('span', { staticClass: 'b-avatar-custom' }, [this.normalizeSlot('default')])
228228
} else if (src) {
229-
$content = h('img', { attrs: { src, alt }, on: { error: this.onImgError } })
229+
$content = h('img', {
230+
style: variant ? {} : { width: '100%', height: '100%' },
231+
attrs: { src, alt },
232+
on: { error: this.onImgError }
233+
})
230234
} else if (icon) {
231235
$content = h(BIcon, {
232236
props: { icon },

0 commit comments

Comments
 (0)