aboutsummaryrefslogtreecommitdiff
path: root/static/widgets/image/index.js
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2025-11-19 18:58:54 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2025-11-19 18:58:54 +0100
commit25228df6d13b5e8541672c4cdd84e200ff56a4c4 (patch)
tree924cc6bdc00440c6bf592b04602261cdab17d60a /static/widgets/image/index.js
parent4c06eb64cbed3562e428ce59857d1763098638f3 (diff)
add profile settings to backend and add image loader
Diffstat (limited to 'static/widgets/image/index.js')
-rw-r--r--static/widgets/image/index.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/static/widgets/image/index.js b/static/widgets/image/index.js
new file mode 100644
index 0000000..ad77c4e
--- /dev/null
+++ b/static/widgets/image/index.js
@@ -0,0 +1,30 @@
+import * as sfw from 'sfw';
+const { Div, Img } = sfw.element.native;
+
+const css = await sfw.css(import.meta.url, './index.css')
+
+export default class Image extends sfw.element.Container {
+ #container
+ #image
+
+ constructor() {
+ super ({ css })
+
+ this.body.append(
+ this.#container = Div.new({
+ id: 'container',
+ children: [
+ this.#image = Img.new({
+ onload: () => this.#container.classList.add('loaded'),
+ }),
+ Div.new({ id: 'loading' })
+ ],
+ })
+ );
+ }
+
+ set id(id) {
+ this.#container.classList.remove('loaded');
+ this.#image.src = `/api/image/load/${id}`;
+ }
+}