aboutsummaryrefslogtreecommitdiff
path: root/src/components/modal/modal.js
blob: 963f4bcd94fefec69b16f361332176d1a05c4d08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const Modal = {
  props: ['show', 'title'],
  methods: {
    close: function () {
      this.$emit('close')
    },
    handleKeydown: function (e) {
      if (this.show && e.keyCode === 27) {
        this.close()
      }
    }
  },
  mounted: function () {
    document.addEventListener('keydown', this.handleKeydown)
  },
  destroyed: function () {
    document.removeEventListener('keydown', this.handleKeydown)
  }
}

export default Modal