all files / src/internal/popup/ overlay.vue

0% Statements 0/5
0% Branches 0/4
100% Functions 0/0
0% Lines 0/5
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                                                                                                                                                         
<template>
  <transition name="mu-overlay-fade">
    <div class="mu-overlay" v-if="show" @click="handleClick" @touchmove="prevent" :style="overlayStyle" ></div>
  </transition>
</template>
<script>
export default {
  name: 'mu-overlay',
  props: {
    show: {
      type: Boolean,
      default: false
    },
    fixed: {
      type: Boolean,
      default: false
    },
    onClick: {
      type: Function
    },
    opacity: {
      type: Number,
      default: 0.4
    },
    color: {
      type: String,
      default: '#000'
    },
    zIndex: {
      type: Number
    }
  },
  computed: {
    overlayStyle () {
      return {
        'opacity': this.opacity,
        'background-color': this.color,
        'position': this.fixed ? 'fixed' : '',
        'z-index': this.zIndex
      }
    }
  },
  methods: {
    prevent (event) {
      event.preventDefault()
      event.stopPropagation()
    },
    handleClick () {
      if (this.onClick) {
        this.onClick()
      }
    }
  }
}
</script>
<style lang="css">
.mu-overlay {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: #000;
  opacity: .4;
  z-index: 1000;
}
 
.mu-overlay-fade-enter-active, .mu-overlay-fade-leave-active {
  transition: opacity .45s cubic-bezier(0.23, 1, 0.32, 1);
}
 
.mu-overlay-fade-enter,
.mu-overlay-fade-leave-active {
  opacity: 0 !important;
}
</style>