Files
mixtape/zero.Backoffice.UI/app/ui/app-overlays.vue
T

222 lines
4.9 KiB
Vue
Raw Normal View History

2020-04-08 23:33:56 +02:00
<template>
2021-12-23 14:39:00 +01:00
<transition-group name="overlay" :duration="600" tag="div" class="app-overlays" :class="{ 'has-multiple': instances.length > 1 }">
<div class="app-overlay-outer" :display="instance.display" v-for="(instance, index) in instances" :key="instance.id"
:style="{ transform: instance.display !== 'editor' ? null : 'translateX(' + (editorLength - index - 1) * -120 + 'px)' }"
:class="instance.class || ''">
<div class="app-overlay-bg" @click="tryRemove(instance)"></div>
<div open class="app-overlay" :data-alias="instance.alias" :style="{ width: instance.width ? (instance.width + 'px') : null }" :class="'theme-' + instance.theme" :display="instance.display">
<component :is="instance.component" :model.sync="instance.model" :config="instance" v-bind="instance" title=""></component>
2020-04-09 01:04:05 +02:00
</div>
2021-12-23 14:39:00 +01:00
</div>
</transition-group>
2020-04-08 23:33:56 +02:00
</template>
2021-12-14 16:06:54 +01:00
<script lang="ts">
import emitter from '../services/eventhub';
import { event_showOverlay, event_closeOverlays, event_finalizeOverlay, event_closeOverlay } from '../services/overlay';
import { arrayRemove } from '../utils/arrays';
import { defineComponent } from 'vue';
export default defineComponent({
name: 'app-overlays',
2020-04-08 23:33:56 +02:00
data: () => ({
2021-12-14 16:06:54 +01:00
instances: []
2020-04-08 23:33:56 +02:00
}),
computed: {
editorLength()
{
return this.instances.filter(x => x.display === 'editor').length;
}
},
mounted()
2021-12-14 16:06:54 +01:00
{
emitter.on(event_showOverlay, overlay => this.add(overlay));
emitter.on(event_closeOverlays, () => this.instances = []);
emitter.on(event_finalizeOverlay, opts => this.finalize(opts.eventType, opts.instance, opts.value, opts.force));
emitter.on(event_closeOverlay, overlay => this.remove(overlay, true));
2021-09-03 09:40:36 +02:00
this.$el.addEventListener('keyup', e =>
{
if (e.key === "Escape" && this.instances.length)
{
2021-12-14 16:06:54 +01:00
this.instances[this.instances.length - 1].close();
2021-09-03 09:40:36 +02:00
}
});
},
2020-04-08 23:33:56 +02:00
methods: {
2021-12-14 16:06:54 +01:00
add(instance)
2020-04-08 23:33:56 +02:00
{
2021-12-14 16:06:54 +01:00
this.instances.push(instance);
},
2021-12-18 16:24:07 +01:00
tryRemove(instance)
{
if (instance.softdismiss)
{
this.remove(instance);
}
},
remove(instance)
2021-12-14 16:06:54 +01:00
{
emitter.emit(event_finalizeOverlay, { eventType: 'close', instance, force: true });
2021-12-14 16:06:54 +01:00
},
finalize(eventType, instance, value, force)
{
if ((eventType === 'close' && force) || (eventType === 'confirm' && instance.autoclose))
{
arrayRemove(this.instances, instance);
}
2020-04-08 23:33:56 +02:00
}
}
2021-12-14 16:06:54 +01:00
})
2020-04-08 23:33:56 +02:00
</script>
<style lang="scss">
.app-overlays
{
grid-column: span 2 / auto;
}
2020-04-09 01:04:05 +02:00
.app-overlay-outer
{
display: flex;
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: 5;
justify-content: center;
2021-08-26 20:42:25 +02:00
align-items: flex-start;
2021-09-12 13:00:07 +02:00
transition: transform 0.55s ease-out;
2020-04-09 01:04:05 +02:00
& + .app-overlay-outer .app-overlay
{
//top: -10px;
2020-04-09 01:04:05 +02:00
}
}
.app-overlay-bg
{
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: var(--color-overlay-shade);
z-index: 2;
opacity: 1;
}
.app-overlay
{
width: auto;
height: auto;
background: var(--color-overlay);
2021-08-26 20:42:25 +02:00
border-bottom-right-radius: var(--radius);
border-bottom-left-radius: var(--radius);
border: none !important;
box-shadow: var(--shadow-overlay-dialog);
2020-04-09 01:04:05 +02:00
padding: var(--padding);
2021-08-26 20:42:25 +02:00
text-align: left;
2020-04-09 01:04:05 +02:00
position: relative;
-webkit-backface-visibility: hidden;
z-index: 3;
color: var(--color-text);
2020-04-09 01:04:05 +02:00
font-size: var(--font-size);
}
.app-overlay .ui-loading
{
position: relative;
left: 50%;
margin-left: -16px;
margin-top: 20px;
margin-bottom: 20px;
}
2021-08-26 20:42:25 +02:00
.app-overlay .ui-headline
{
2021-12-18 16:24:07 +01:00
margin-bottom: var(--padding);
2021-08-26 20:42:25 +02:00
}
2020-05-04 14:13:03 +02:00
.app-overlay[display="dialog"] .ui-form-loading
{
height: 200px;
}
2020-04-24 15:13:54 +02:00
.app-overlay[display="editor"]
{
width: auto;
position: absolute;
left: auto;
2021-12-14 16:06:54 +01:00
right: 0;
2020-04-24 15:13:54 +02:00
top: 0;
bottom: 0;
box-shadow: var(--shadow-overlay);
background: var(--color-overlay-editor);
2020-04-24 15:13:54 +02:00
text-align: left;
padding: 0;
2021-03-21 15:14:29 +01:00
height: 100vh;
2020-04-24 15:13:54 +02:00
max-width: 100%;
2021-09-16 10:25:56 +02:00
border-bottom-right-radius: 0;
border-top-left-radius: var(--radius);
2020-04-24 15:13:54 +02:00
}
2020-04-09 01:04:05 +02:00
.overlay-enter-active, .overlay-leave-active
{
.app-overlay-bg
{
transition: opacity .3s ease;
}
.app-overlay
{
transition: transform .3s ease, opacity .3s ease;
}
2020-04-24 15:13:54 +02:00
.app-overlay[display="editor"]
{
transition: transform .6s ease;
2020-04-24 15:13:54 +02:00
}
2020-04-09 01:04:05 +02:00
}
.overlay-enter, .overlay-leave-to
2021-12-14 16:06:54 +01:00
{
2020-04-09 01:04:05 +02:00
.app-overlay-bg
{
opacity: 0;
}
.app-overlay
{
opacity: 0;
2021-08-26 20:42:25 +02:00
transform: translateY(-20px);
2020-04-09 01:04:05 +02:00
}
2020-04-24 15:13:54 +02:00
.app-overlay[display="editor"]
{
opacity: 1;
transform: scale(1) translateX(100%);
}
2020-04-09 01:04:05 +02:00
}
2021-12-18 01:51:38 +01:00
.app-confirm-buttons
{
margin-top: 40px;
}
.app-confirm p
{
line-height: 1.4;
}
2020-04-08 23:33:56 +02:00
</style>