2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2022-05-11 15:59:43 +00:00
|
|
|
<div v-if="state.showing" id="overlay" :class="state.type" class="overlay" data-testid="overlay">
|
2022-04-15 14:24:30 +00:00
|
|
|
<div class="display">
|
2022-05-11 15:24:28 +00:00
|
|
|
<SoundBar v-if="state.type === 'loading'"/>
|
|
|
|
<i v-if="state.type === 'error'" class="fa fa-exclamation-circle"/>
|
|
|
|
<i v-if="state.type === 'warning'" class="fa fa-exclamation-triangle"/>
|
|
|
|
<i v-if="state.type === 'info'" class="fa fa-info-circle"/>
|
|
|
|
<i v-if="state.type === 'success'" class="fa fa-check-circle"/>
|
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-05-11 15:24:28 +00:00
|
|
|
<button v-if="state.dismissible" class="btn-dismiss" type="button" @click.prevent="hide">Close</button>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-04-15 14:24:30 +00:00
|
|
|
import { eventBus } from '@/utils'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { defineAsyncComponent, reactive } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-23 21:36:19 +00:00
|
|
|
const SoundBar = defineAsyncComponent(() => import('@/components/ui/SoundBar.vue'))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const state = reactive<OverlayState>({
|
|
|
|
showing: true,
|
|
|
|
dismissible: false,
|
|
|
|
type: 'loading',
|
|
|
|
message: ''
|
|
|
|
})
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const show = (options: Partial<OverlayState>) => {
|
2022-05-11 15:59:43 +00:00
|
|
|
Object.assign(state, options)
|
2022-04-15 17:00:08 +00:00
|
|
|
state.showing = true
|
|
|
|
}
|
|
|
|
|
|
|
|
const hide = () => (state.showing = false)
|
|
|
|
|
|
|
|
eventBus.on({
|
|
|
|
'SHOW_OVERLAY': show,
|
|
|
|
'HIDE_OVERLAY': hide
|
2022-04-15 14:24:30 +00:00
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
#overlay {
|
|
|
|
background-color: var(--color-bg-primary);
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
.display {
|
|
|
|
@include vertical-center();
|
|
|
|
|
|
|
|
i {
|
|
|
|
margin-right: 6px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.error {
|
|
|
|
color: var(--color-red);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.success {
|
|
|
|
color: var(--color-green);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.info {
|
|
|
|
color: var(--color-blue);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.loading {
|
|
|
|
color: var(--color-text-secondary);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.warning {
|
|
|
|
color: var(--color-highlight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|