import Vue from 'vue'; import Icon from "./Icon"; export default Vue.component('modal', { components: { Icon, }, props: { modalName: { type: String, default: 'modal' }, show: { type: Boolean, default: false }, closeOnEsc: { type: Boolean, default: true }, }, mounted: function () { if (this.$props.closeOnEsc) { document.addEventListener('keydown', e => { if (this.show && e.key === 'Escape') { this.close(); } }) } }, methods: { close: function () { this.$emit('close', this.$props.modalName); } }, template: ` ` })