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},
|
2023-03-29 18:02:12 -04:00
|
|
|
};
|
2022-09-06 19:26:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static styles = styles;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.id = null;
|
|
|
|
this.users = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2024-05-12 10:40:06 -04:00
|
|
|
let image = html`<span
|
|
|
|
class="w3-theme-light w3-circle"
|
|
|
|
style="display: inline-block; width: 2em; height: 2em; text-align: center; line-height: 2em"
|
2024-05-15 19:25:48 -04:00
|
|
|
>?</span
|
|
|
|
>`;
|
2023-03-19 19:31:08 -04:00
|
|
|
let name = this.users?.[this.id]?.name;
|
2024-02-24 11:09:34 -05:00
|
|
|
name =
|
|
|
|
name !== undefined
|
|
|
|
? html`<a target="_top" href=${'#' + this.id}>${name}</a>`
|
|
|
|
: html`<a target="_top" href=${'#' + this.id}>${this.id}</a>`;
|
2023-03-19 19:31:08 -04:00
|
|
|
|
2022-09-06 19:26:43 -04:00
|
|
|
if (this.users[this.id]) {
|
2024-05-12 10:40:06 -04:00
|
|
|
let image_link = this.users[this.id].image;
|
2024-05-15 19:25:48 -04:00
|
|
|
image_link =
|
|
|
|
typeof image_link == 'string' ? image_link : image_link?.link;
|
2024-05-12 10:40:06 -04:00
|
|
|
if (image_link !== undefined) {
|
|
|
|
image = html`<img
|
|
|
|
class="w3-circle"
|
2024-10-10 21:41:34 -04:00
|
|
|
style="width: 2em; height: 2em; vertical-align: middle; object-fit: cover"
|
2024-05-12 10:40:06 -04:00
|
|
|
src="/${image_link}/view"
|
|
|
|
/>`;
|
|
|
|
}
|
2022-09-06 19:26:43 -04:00
|
|
|
}
|
2024-05-12 10:40:06 -04:00
|
|
|
return html` <div style="display: inline-block; font-weight: bold">
|
2024-05-15 19:25:48 -04:00
|
|
|
${image} ${name}
|
2024-05-12 10:40:06 -04:00
|
|
|
</div>`;
|
2022-09-06 19:26:43 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-24 11:09:34 -05:00
|
|
|
customElements.define('tf-user', TfUserElement);
|