2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
|
|
|
<transition name="modal-fade">
|
2020-03-01 05:53:55 +00:00
|
|
|
<div
|
|
|
|
v-if="show"
|
|
|
|
class="modal-mask"
|
|
|
|
transition="modal"
|
|
|
|
@click="onBackDropClick"
|
|
|
|
>
|
2020-10-25 18:58:23 +00:00
|
|
|
<div :class="modalContainerClassName" @click.stop>
|
2020-05-17 15:37:45 +00:00
|
|
|
<i class="ion-android-close modal--close" @click="close"></i>
|
2019-12-16 12:53:14 +00:00
|
|
|
<slot />
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
2020-02-29 12:13:49 +00:00
|
|
|
closeOnBackdropClick: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
show: Boolean,
|
2020-02-29 12:13:49 +00:00
|
|
|
onClose: {
|
|
|
|
type: Function,
|
|
|
|
required: true,
|
|
|
|
},
|
2020-10-25 18:58:23 +00:00
|
|
|
fullWidth: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
modalContainerClassName() {
|
|
|
|
let className = 'modal-container';
|
|
|
|
if (this.fullWidth) {
|
|
|
|
return `${className} modal-container--full-width`;
|
|
|
|
}
|
|
|
|
return className;
|
2020-02-29 12:13:49 +00:00
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
mounted() {
|
2019-12-14 12:44:35 +00:00
|
|
|
document.addEventListener('keydown', e => {
|
2019-08-14 09:48:44 +00:00
|
|
|
if (this.show && e.keyCode === 27) {
|
|
|
|
this.onClose();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2019-12-14 12:44:35 +00:00
|
|
|
methods: {
|
|
|
|
close() {
|
2020-03-01 05:53:55 +00:00
|
|
|
this.onClose();
|
|
|
|
},
|
|
|
|
onBackDropClick() {
|
2020-02-29 12:13:49 +00:00
|
|
|
if (this.closeOnBackdropClick) {
|
|
|
|
this.onClose();
|
|
|
|
}
|
2019-12-14 12:44:35 +00:00
|
|
|
},
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
};
|
|
|
|
</script>
|
2020-10-25 18:58:23 +00:00
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.modal-container--full-width {
|
|
|
|
align-items: center;
|
|
|
|
border-radius: 0;
|
|
|
|
display: flex;
|
|
|
|
height: 100%;
|
|
|
|
justify-content: center;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
</style>
|