2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2022-11-18 15:31:36 +00:00
|
|
|
<dialog ref="el" :class="state.type" @cancel.prevent="onCancel" data-testid="overlay">
|
|
|
|
<div class="wrapper">
|
2022-08-01 08:58:25 +00:00
|
|
|
<SoundBars v-if="state.type === 'loading'"/>
|
2022-07-15 07:23:55 +00:00
|
|
|
<icon v-if="state.type === 'error'" :icon="faCircleExclamation"/>
|
|
|
|
<icon v-if="state.type === 'warning'" :icon="faWarning"/>
|
|
|
|
<icon v-if="state.type === 'info'" :icon="faCircleInfo"/>
|
|
|
|
<icon v-if="state.type === 'success'" :icon="faCircleCheck"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-05-11 15:24:28 +00:00
|
|
|
<span class="message" v-html="state.message"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
2022-11-18 15:31:36 +00:00
|
|
|
</dialog>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-07-15 07:23:55 +00:00
|
|
|
import { faCircleCheck, faCircleExclamation, faCircleInfo, faWarning } from '@fortawesome/free-solid-svg-icons'
|
2022-11-18 15:31:36 +00:00
|
|
|
import { defineAsyncComponent, reactive, ref } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-08-01 08:58:25 +00:00
|
|
|
const SoundBars = defineAsyncComponent(() => import('@/components/ui/SoundBars.vue'))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-11-18 15:31:36 +00:00
|
|
|
const el = ref<HTMLDialogElement>()
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const state = reactive<OverlayState>({
|
|
|
|
dismissible: false,
|
|
|
|
type: 'loading',
|
2022-11-19 21:59:56 +00:00
|
|
|
message: ''
|
2022-04-15 17:00:08 +00:00
|
|
|
})
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-11-18 15:31:36 +00:00
|
|
|
const show = (options: Partial<OverlayState> = {}) => {
|
2022-05-11 15:59:43 +00:00
|
|
|
Object.assign(state, options)
|
2022-11-18 15:31:36 +00:00
|
|
|
el.value?.open || el.value?.showModal()
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
|
|
|
|
2022-11-18 15:31:36 +00:00
|
|
|
const hide = () => el.value?.close()
|
|
|
|
const onCancel = () => state.dismissible && hide()
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-11-19 18:04:21 +00:00
|
|
|
defineExpose({ show, hide })
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
2022-11-18 15:31:36 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
dialog {
|
|
|
|
border: 0;
|
|
|
|
padding: 0;
|
|
|
|
background: transparent;
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-11-18 15:31:36 +00:00
|
|
|
&::backdrop {
|
2022-11-19 21:59:56 +00:00
|
|
|
background: rgba(0, 0, 0, 0.8);
|
2022-11-18 15:31:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.wrapper {
|
2022-08-01 08:58:25 +00:00
|
|
|
display: flex;
|
|
|
|
align-items: baseline;
|
|
|
|
justify-content: center;
|
2022-11-18 15:31:36 +00:00
|
|
|
gap: 6px;
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
&.error {
|
|
|
|
color: var(--color-red);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.success {
|
|
|
|
color: var(--color-green);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.info {
|
|
|
|
color: var(--color-blue);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.loading {
|
|
|
|
color: var(--color-text-secondary);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.warning {
|
2022-11-18 15:31:36 +00:00
|
|
|
color: var(--color-orange);
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|