Vue 3 better animation (#257)

* vue-3-better-animation

* Working on migration to vueuse/motion

* Form sidebar animations

* Clean code

* Added animations for modal

* Finished implementing better animations

---------

Co-authored-by: Forms Dev <chirag+new@notionforms.io>
This commit is contained in:
Julien Nahum
2023-12-08 19:21:04 +01:00
committed by GitHub
parent 24276f0b95
commit f970557b76
23 changed files with 1756 additions and 870 deletions

View File

@@ -0,0 +1,59 @@
<template>
<transition @leave="(el,done) => motions.collapsible.leave(done)">
<div
v-if="modelValue"
key="dropdown"
v-motion="'collapsible'"
v-on-click-outside.bubble="close"
:variants="motionCollapse"
>
<slot />
</div>
</transition>
</template>
<script>
import { vOnClickOutside } from '@vueuse/components'
import { useMotions } from '@vueuse/motion'
export default {
name: 'Collapsible',
directives: {
onClickOutside: vOnClickOutside
},
props: {
modelValue: { type: Boolean },
closeOnClickAway: { type: Boolean, default: true }
},
setup () {
return {
motions: useMotions()
}
},
computed: {
motionCollapse () {
return {
enter: {
opacity: 1,
y: 0,
height: 'auto',
transition: { duration: 150, ease: 'easeOut' }
},
initial: {
opacity: 0,
y: -10,
height: 0,
transition: { duration: 75, ease: 'easeIn' }
}
}
}
},
methods: {
close () {
if (this.closeOnClickAway) {
this.$emit('update:modelValue', false)
}
}
}
}
</script>