cordis/client/webapp/elements/member.ts

25 lines
980 B
TypeScript
Raw Normal View History

2021-10-30 17:26:41 +00:00
import { Member } from "../data-types";
2021-11-22 02:47:29 +00:00
import CombinedGuild from "../guild-combined";
import Q from "../q-module";
2021-10-30 17:26:41 +00:00
import ElementsUtil from "./require/elements-util";
2021-10-30 17:26:41 +00:00
2021-11-21 18:29:42 +00:00
export default function createMember(q: Q, guild: CombinedGuild, member: Member): HTMLElement {
let nameStyle = member.roleColor ? 'color: ' + member.roleColor : '';
let element = q.create({ class: 'member ' + member.status, 'meta-id': member.id, content: [
{ class: 'icon', content: [
{ tag: 'img', class: 'avatar', src: './img/loading.svg', alt: member.displayName },
{ class: 'status-circle' }
] },
{ class: 'text', content: [
{ class: 'name', style: nameStyle, content: member.displayName },
{ class: 'status-text', content: member.status }
] }
] }) as HTMLElement;
(async () => {
(q.$$$(element, 'img.avatar') as HTMLImageElement).src =
2021-11-22 02:47:29 +00:00
await ElementsUtil.getImageBufferFromResourceFailSoftly(guild, member.avatarResourceId);
})();
return element;
2021-10-30 17:26:41 +00:00
}