aboutsummaryrefslogtreecommitdiff
path: root/static/js/conversation.js
diff options
context:
space:
mode:
authorXe <me@christine.website>2021-12-15 19:16:16 -0500
committerXe <me@christine.website>2021-12-15 19:16:16 -0500
commit166079f0e381bcfff0f79cd55031d634308d1a68 (patch)
treee6999e3a6c285d11cc7435649500b147aeacf2c7 /static/js/conversation.js
parent1986de12d175196721349dd3626686f3880f1805 (diff)
downloadxesite-166079f0e381bcfff0f79cd55031d634308d1a68.tar.xz
xesite-166079f0e381bcfff0f79cd55031d634308d1a68.zip
make test custom element page
Signed-off-by: Xe <me@christine.website>
Diffstat (limited to 'static/js/conversation.js')
-rw-r--r--static/js/conversation.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/static/js/conversation.js b/static/js/conversation.js
new file mode 100644
index 0000000..bdce9ad
--- /dev/null
+++ b/static/js/conversation.js
@@ -0,0 +1,36 @@
+import { g, h, x } from "./xeact.min.js";
+import { div, span } from "./xeact-html.min.js";
+
+const mkConversation = (who, mood, message) =>
+ h("div", {className: "conversation gruvbox-dark"}, [
+ 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");
+
+ root.appendChild(h("link", {rel: "stylesheet", href: "/css/gruvbox-dark.css"}));
+ root.appendChild(h("link", {rel: "stylesheet", href: "/css/shim.css"}));
+ root.appendChild(h("style", {textContent: `img { width: 67%; }`}));
+ root.appendChild(mkConversation(who, mood, this.childNodes));
+ }
+}
+
+window.customElements.define("xeblog-conv", Conversation);