<template>
  <teleport to="body">
    <Transition name="fade">
      <div v-if="modelValue" class="fixed inset-0 z-50 flex items-center justify-center bg-black/60" @click.self="close">
        <div :class="`bg-white ${modalClass}`">
          <header class="">
            <slot name="title"></slot>
          </header>
          <main class="">
            <slot></slot>
          </main>
        </div>
      </div>
    </Transition>
  </teleport>
</template>

<script lang="ts" setup>

defineProps({
    modelValue:{
        type:Boolean,
        default: false
    },
    modalClass:{
        type:String,
        default: ""
    }
});

const emit = defineEmits(['update:modelValue']);

function close() {
  emit('update:modelValue', false);
}
</script>

<style scoped>
.fade-enter-active, .fade-leave-active {
  transition: opacity 0.2s;
}
.fade-enter-from, .fade-leave-to {
  opacity: 0;
}
</style>