aboutsummaryrefslogtreecommitdiff
path: root/static/pages/image-viewer/index.js
blob: d28b3e1cd1beaac626b0b852313d2d3cbf55329d (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 ImageViewer extends sfw.element.Container {
	#container

	constructor() {
		super({ css });

		this.body.append(
			this.#container = Div.new({ id: 'container' })
		);
	}

	add(url) {
		let image;
		this.#container.append(
			image = Img.new({
				className: 'hidden',
				src: url,
				onload: () => image.classList.remove('hidden')
			}));
	}

	clear() {
		this.#container.innerHTML = '';
	}
}