ModalWrapper.vue 698 字节
Newer Older
L
LeoKu 已提交
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
<template>
  <transition name="fade">
    <div v-if="props.visible" class="modal" @click.self="emit('close')">
      <slot />
    </div>
  </transition>
</template>

<script lang="ts" setup>
const props = defineProps<{ visible?: boolean }>()

const emit = defineEmits<{
  (e: 'close'): void
}>()
</script>

<style lang="scss" scoped>
.modal {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  width: 100%;
  height: 100%;
  overflow: hidden;
  backdrop-filter: blur(0.1rem);
}

.fade-enter-active,
.fade-leave-active {
  @media (prefers-reduced-motion: no-preference) {
    transition: opacity 0.25s ease, transform 0.25s;
  }
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
</style>