aboutsummaryrefslogtreecommitdiff
path: root/src/components/modal/modal.vue
blob: 2187f3922c40ca88bbd5f69d235ab5e547d9f19b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<template>
  <div
    v-show="isOpen"
    v-body-scroll-lock="isOpen && !noBackground"
    class="modal-view"
    :class="classes"
    @click.self="$emit('backdropClicked')"
  >
    <slot />
  </div>
</template>

<script>
export default {
  provide: {
    popoversZLayer: 'modals'
  },
  props: {
    isOpen: {
      type: Boolean,
      default: true
    },
    noBackground: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    classes () {
      return {
        'modal-background': !this.noBackground,
        open: this.isOpen
      }
    }
  }
}
</script>

<style lang="scss">
.modal-view {
  z-index: var(--ZI_modals);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
  pointer-events: none;
  animation-duration: 0.2s;
  animation-name: modal-background-fadein;
  opacity: 0;

  > * {
    pointer-events: initial;
  }

  &.modal-background {
    pointer-events: initial;
    background-color: rgba(0, 0, 0, 0.5);
  }

  &.open {
    opacity: 1;
  }
}

@keyframes modal-background-fadein {
  from {
    background-color: rgba(0, 0, 0, 0);
  }
  to {
    background-color: rgba(0, 0, 0, 0.5);
  }
}
</style>