From 25228df6d13b5e8541672c4cdd84e200ff56a4c4 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Wed, 19 Nov 2025 18:58:54 +0100 Subject: add profile settings to backend and add image loader --- static/widgets/image/index.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 static/widgets/image/index.js (limited to 'static/widgets/image/index.js') 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}`; + } +} -- cgit v1.2.3-70-g09d2