summaryrefslogtreecommitdiff
path: root/packages/client/src/components/waiting-dialog.vue
blob: 206f7d0c5aa29c9c903a3d85838aad1eb0cbd9d5 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<template>
<MkModal ref="modal" @click="success ? done() : () => {}" @closed="$emit('closed')">
	<div class="iuyakobc" :class="{ iconOnly: (text == null) || success }">
		<i v-if="success" class="fas fa-check icon success"></i>
		<i v-else class="fas fa-spinner fa-pulse icon waiting"></i>
		<div v-if="text && !success" class="text">{{ text }}<MkEllipsis/></div>
	</div>
</MkModal>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import MkModal from '@/components/ui/modal.vue';

export default defineComponent({
	components: {
		MkModal,
	},

	props: {
		success: {
			type: Boolean,
			required: true,
		},
		showing: {
			type: Boolean,
			required: true,
		},
		text: {
			type: String,
			required: false,
		},
	},

	emits: ['done', 'closed'],

	data() {
		return {
		};
	},

	watch: {
		showing() {
			if (!this.showing) this.done();
		}
	},

	methods: {
		done() {
			this.$emit('done');
			this.$refs.modal.close();
		},
	}
});
</script>

<style lang="scss" scoped>
.iuyakobc {
	position: relative;
	padding: 32px;
	box-sizing: border-box;
	text-align: center;
	background: var(--panel);
	border-radius: var(--radius);
	width: 250px;

	&.iconOnly {
		padding: 0;
		width: 96px;
		height: 96px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	> .icon {
		font-size: 32px;

		&.success {
			color: var(--accent);
		}

		&.waiting {
			opacity: 0.7;
		}
	}

	> .text {
		margin-top: 16px;
	}
}
</style>