2021-12-16 00:16:16 +00:00
|
|
|
import { g, h, x } from "./xeact.min.js";
|
|
|
|
import { div, span } from "./xeact-html.min.js";
|
|
|
|
|
2021-12-19 17:54:02 +00:00
|
|
|
export const mkConversation = (who, mood, message, extraClasses = "") =>
|
|
|
|
h("div", {className: "conversation gruvbox-dark " + extraClasses}, [
|
2021-12-16 00:16:16 +00:00
|
|
|
h("div", {className: "conversation-picture conversation-smol"}, [
|
|
|
|
h("picture", {}, [
|
|
|
|
h("source", {type: "image/avif", srcset: `https://cdn.christine.website/file/christine-static/stickers/${who.toLowerCase()}/${mood}.avif`}),
|
|
|
|
h("source", {type: "image/webp", srcset: `https://cdn.christine.website/file/christine-static/stickers/${who.toLowerCase()}/${mood}.webp`}),
|
|
|
|
h("img", {alt: `${who} is ${mood}`, src: `https://cdn.christine.website/file/christine-static/stickers/${who.toLowerCase()}/${mood}.png`})
|
|
|
|
])
|
|
|
|
]),
|
|
|
|
h("div", {className: "conversation-chat"}, [
|
|
|
|
h("span", {innerText: "<"}),
|
|
|
|
h("b", {innerText: who}),
|
|
|
|
h("span", {innerText: "> "}),
|
|
|
|
span({}, Array.from(message))
|
|
|
|
])
|
|
|
|
]);
|
|
|
|
|
|
|
|
export class Conversation extends HTMLElement {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
let root = this.attachShadow({mode: "open"});
|
|
|
|
let who = this.getAttribute("name");
|
|
|
|
let mood = this.getAttribute("mood");
|
|
|
|
|
2021-12-19 18:14:45 +00:00
|
|
|
root.appendChild(h("link", {rel: "stylesheet", href: "/css/hack.css"}));
|
2021-12-16 00:16:16 +00:00
|
|
|
root.appendChild(h("link", {rel: "stylesheet", href: "/css/gruvbox-dark.css"}));
|
|
|
|
root.appendChild(h("link", {rel: "stylesheet", href: "/css/shim.css"}));
|
|
|
|
root.appendChild(mkConversation(who, mood, this.childNodes));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.customElements.define("xeblog-conv", Conversation);
|