diff --git a/package.json b/package.json index 26b1fa2..af765fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tp/tp-avatar", - "version": "1.0.3", + "version": "1.0.4", "description": "", "main": "tp-avatar.js", "scripts": { @@ -13,6 +13,7 @@ "author": "trading_peter", "license": "Apache-2.0", "dependencies": { - "lit": "^3.0.0" + "lit": "^3.0.0", + "@tp/helpers": "^1.0.0" } } diff --git a/tp-avatar.js b/tp-avatar.js index 4edb0f4..fbf14b2 100644 --- a/tp-avatar.js +++ b/tp-avatar.js @@ -7,8 +7,9 @@ This program is available under Apache License Version 2.0 import '@tp/tp-icon/tp-icon.js'; import { LitElement, html, css, svg } from 'lit'; import { classMap } from 'lit/directives/class-map.js'; +import { DomQuery } from '@tp/helpers/dom-query.js'; -class TpAvatar extends LitElement { +class TpAvatar extends DomQuery(LitElement) { static get styles() { return [ css` @@ -25,8 +26,8 @@ class TpAvatar extends LitElement { } #avatarImg { - width: var(--era-avatar-size, 32px); - height: var(--era-avatar-size, 32px); + width: var(--tp-avatar-size, 32px); + height: var(--tp-avatar-size, 32px); background-size: cover; background-position: center center; border-radius: 50%; @@ -61,8 +62,8 @@ class TpAvatar extends LitElement { const { loaded, hasSrc } = this; return html` -
- +
+ `; } @@ -90,13 +91,13 @@ class TpAvatar extends LitElement { if (this.src !== changes.get('src')) { this.hasSrc = true; - if (newSrc.indexOf(this.baseUrl) !== 0 && !this.hasSchema(newSrc)) { + if (this.src.indexOf(this.baseUrl) !== 0 && !this.hasSchema(this.src)) { this.src = this.baseUrl + this.src; return; } this.loaded = false; - if (Boolean(newSrc)) { + if (Boolean(this.src)) { this.loadImage(); } }