2022-09-06 19:26:43 -04:00
|
|
|
import {LitElement, html} from './lit-all.min.js';
|
|
|
|
import * as tfrpc from '/static/tfrpc.js';
|
|
|
|
import {styles} from './tf-styles.js';
|
|
|
|
|
|
|
|
class TfUserElement extends LitElement {
|
|
|
|
static get properties() {
|
|
|
|
return {
|
|
|
|
id: {type: String},
|
|
|
|
users: {type: Object},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static styles = styles;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.id = null;
|
|
|
|
this.users = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
if (this.users[this.id]) {
|
|
|
|
let image = this.users[this.id].image;
|
|
|
|
image = typeof(image) == 'string' ? image : image?.link;
|
|
|
|
return html`
|
|
|
|
<div style="display: inline-block; font-weight: bold">
|
2022-09-09 22:56:15 -04:00
|
|
|
<img style="width: 2em; height: 2em; vertical-align: middle; border-radius: 50%" ?hidden=${image === undefined} src="${image ? '/' + image + '/view' : undefined}">
|
|
|
|
<a target="_top" href=${'#' + this.id}>${this.users[this.id].name ?? this.id}</a>
|
2022-09-06 19:26:43 -04:00
|
|
|
</div>`;
|
|
|
|
} else {
|
|
|
|
return html`
|
2022-10-04 22:11:46 -04:00
|
|
|
<div style="display: inline-block; font-weight: bold; word-wrap: anywhere">
|
2022-09-06 19:26:43 -04:00
|
|
|
<a target="_top" href=${'#' + this.id}>${this.id}</a>
|
|
|
|
</div>`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
customElements.define('tf-user', TfUserElement);
|