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"
|
|
|
|
>
|
2019-08-14 09:48:44 +00:00
|
|
|
<div class="modal-container" :class="className" @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,
|
|
|
|
},
|
|
|
|
className: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
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>
|