|
// retoor <retoor@molodetz.nl>
|
|
|
|
import { Component } from "./Component.js";
|
|
import { Avatar } from "../Avatar.js";
|
|
|
|
export class AppAvatar extends Component {
|
|
static get observedAttributes() {
|
|
return ["username", "size"];
|
|
}
|
|
|
|
connectedCallback() {
|
|
this.render();
|
|
}
|
|
|
|
attributeChangedCallback() {
|
|
if (this.isConnected) {
|
|
this.render();
|
|
}
|
|
}
|
|
|
|
render() {
|
|
const username = this.attr("username");
|
|
const size = this.intAttr("size", 24);
|
|
this.textContent = "";
|
|
if (!username) {
|
|
return;
|
|
}
|
|
this.appendChild(Avatar.imgElement(username, size));
|
|
}
|
|
}
|
|
|
|
customElements.define("dp-avatar", AppAvatar);
|