<template>
  <transition :mode="mode" :name="formattedTransitionName">
    <slot />
  </transition>
</template>

<script setup lang="ts">
import { computed } from 'vue'

interface Props {
  mode?: 'in-out' | 'out-in' | 'default'
  slideTo?: 'top' | 'left'
}

const props = withDefaults(defineProps<Props>(), {
  slideTo: 'top',
  mode: 'out-in',
})

const formattedTransitionName = computed(() => `slide-${props.slideTo}`)
</script>

<style lang="scss">
.slide-top-enter-active,
.slide-top-leave-active,
.slide-left-enter-active,
.slide-left-leave-active {
  transition:
    transform 300ms ease,
    opacity 300ms ease;
}

.slide-top-enter-from,
.slide-top-leave-to {
  opacity: 0;
  transform: scale3d(0.8, 0.8, 1) translate3d(0, fn.px-to-rem(10), 0);
}

.slide-left-enter-from,
.slide-left-leave-to {
  opacity: 0;
  transform: scale3d(0.8, 0.8, 1) translate3d(fn.px-to-rem(10), 0, 0);
}
</style>
