diff --git a/src/components/avatar/avatar.ts b/src/components/avatar/avatar.ts index 1f2d0b3c..287ea2d7 100644 --- a/src/components/avatar/avatar.ts +++ b/src/components/avatar/avatar.ts @@ -52,6 +52,29 @@ export default class SlAvatar extends ShoelaceElement { } render() { + const avatarWithImage = html` + + `; + + let avatarWithoutImage = html``; + + if (this.initials) { + avatarWithoutImage = html`
${this.initials}
`; + } else { + avatarWithoutImage = html` + + `; + } + return html`
- ${this.image && !this.hasError // with image - ? html` - - ` - : this.initials // no image, just initials - ? html`
${this.initials}
` - : html` - - `} + ${this.image && !this.hasError ? avatarWithImage : avatarWithoutImage}
`; }