Chatwoot/app/javascript/dashboard/components/Modal.vue

53 lines
956 B
Vue
Raw Normal View History

<template>
<transition name="modal-fade">
2020-03-01 05:53:55 +00:00
<div
v-if="show"
class="modal-mask"
transition="modal"
@click="onBackDropClick"
>
<i class="ion-android-close modal--close" @click="close"></i>
<div class="modal-container" :class="className" @click.stop>
<slot />
</div>
</div>
</transition>
</template>
<script>
export default {
props: {
closeOnBackdropClick: {
type: Boolean,
default: true,
},
show: Boolean,
onClose: {
type: Function,
required: true,
},
className: {
type: String,
default: '',
},
},
mounted() {
document.addEventListener('keydown', e => {
if (this.show && e.keyCode === 27) {
this.onClose();
}
});
},
methods: {
close() {
2020-03-01 05:53:55 +00:00
this.onClose();
},
onBackDropClick() {
if (this.closeOnBackdropClick) {
this.onClose();
}
},
},
};
</script>