2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2020-09-05 14:52:36 +02:00
|
|
|
<div class="mk-modal" v-hotkey.global="keymap" :style="{ pointerEvents: showing ? 'auto' : 'none' }">
|
2020-02-06 11:11:14 +01:00
|
|
|
<transition :name="$store.state.device.animation ? 'bg-fade' : ''" appear>
|
2020-09-05 14:52:36 +02:00
|
|
|
<div class="bg _modalBg" ref="bg" v-if="showing" @click="$emit('click')"></div>
|
2020-01-29 20:37:25 +01:00
|
|
|
</transition>
|
2020-09-05 14:52:36 +02:00
|
|
|
<transition :name="$store.state.device.animation ? 'modal' : ''" appear @after-leave="$emit('closed')">
|
|
|
|
|
<div class="content" ref="content" v-if="showing" @click.self="$emit('click')"><slot></slot></div>
|
2020-01-29 20:37:25 +01:00
|
|
|
</transition>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-07-23 20:15:32 +02:00
|
|
|
import { defineComponent } from 'vue';
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2020-07-23 20:15:32 +02:00
|
|
|
export default defineComponent({
|
2020-09-05 14:52:36 +02:00
|
|
|
emits: ['click', 'esc'],
|
2020-01-29 20:37:25 +01:00
|
|
|
props: {
|
2020-09-05 14:52:36 +02:00
|
|
|
showing: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
2020-07-11 03:13:11 +02:00
|
|
|
canClose: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
required: false,
|
|
|
|
|
default: true,
|
|
|
|
|
},
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
2020-02-16 14:46:18 +01:00
|
|
|
computed: {
|
|
|
|
|
keymap(): any {
|
|
|
|
|
return {
|
2020-09-05 14:52:36 +02:00
|
|
|
'esc': () => this.$emit('esc'),
|
2020-02-16 14:46:18 +01:00
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-01-29 20:37:25 +01:00
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.modal-enter-active, .modal-leave-active {
|
|
|
|
|
transition: opacity 0.3s, transform 0.3s !important;
|
|
|
|
|
}
|
2020-09-05 14:52:36 +02:00
|
|
|
.modal-enter-from, .modal-leave-to {
|
|
|
|
|
pointer-events: none;
|
2020-01-29 20:37:25 +01:00
|
|
|
opacity: 0;
|
|
|
|
|
transform: scale(0.9);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.bg-fade-enter-active, .bg-fade-leave-active {
|
|
|
|
|
transition: opacity 0.3s !important;
|
|
|
|
|
}
|
2020-09-05 14:52:36 +02:00
|
|
|
.bg-fade-enter-from, .bg-fade-leave-to {
|
2020-01-29 20:37:25 +01:00
|
|
|
opacity: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mk-modal {
|
|
|
|
|
> .bg {
|
|
|
|
|
z-index: 10000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
> .content {
|
|
|
|
|
position: fixed;
|
|
|
|
|
z-index: 10000;
|
|
|
|
|
top: 0;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
max-width: calc(100% - 16px);
|
|
|
|
|
max-height: calc(100% - 16px);
|
|
|
|
|
overflow: auto;
|
2020-09-05 14:52:36 +02:00
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|