aboutsummaryrefslogtreecommitdiff
path: root/static/widgets/upload-bar/index.js
blob: a9e02208947970db4eb62b55db5002e416711a8f (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
31
32
33
34
35
36
37
38
39
40
41
42
import * as sfw from 'sfw';
const { Div } = sfw.element.native;

const css = await sfw.css(import.meta.url, './index.css')

export default class UploadBar extends sfw.element.Container {
	#files_progress
	#inner_progress
	#container

	constructor() {
		super({ css });

		this.body.append(
			this.#container = Div.new({
				id: 'container',
				style: { display: 'none' },
				children: [
					this.#files_progress = Div.new({ id: 'files', innerText: 'Uploading...' }),
					Div.new({
						id: 'inner-progress',
						children: [
							this.#inner_progress = Div.new({ id: 'progress' }),
						]
					})
				]
			})
		);
	}

	set progress(progress) {
		this.#inner_progress.style.width = `${progress * 100}%`
	}

	hide() {
		this.#container.style.display = 'none';
	}

	show() {
		this.#container.style.display = '';
	}
}