blob: ad77c4ec9128a1f842be3f56b57586c0fe6ab7d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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}`;
}
}
|