mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-30 03:38:54 +01:00
chore(Slideover): allow to disable transitions
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<TransitionRoot as="template" :show="isOpen">
|
<TransitionRoot as="template" :appear="appear" :show="isOpen">
|
||||||
<Dialog
|
<Dialog
|
||||||
class="fixed inset-0 flex z-40"
|
class="fixed inset-0 flex z-40"
|
||||||
:class="{
|
:class="{
|
||||||
@@ -10,18 +10,16 @@
|
|||||||
<TransitionChild
|
<TransitionChild
|
||||||
v-if="overlay"
|
v-if="overlay"
|
||||||
as="template"
|
as="template"
|
||||||
v-bind="overlayTransitionClass"
|
:appear="appear"
|
||||||
|
v-bind="overlayTransition"
|
||||||
>
|
>
|
||||||
<div class="fixed inset-0 transition-opacity" :class="overlayBackgroundClass" />
|
<div class="fixed inset-0 transition-opacity" :class="overlayBackgroundClass" />
|
||||||
</TransitionChild>
|
</TransitionChild>
|
||||||
|
|
||||||
<TransitionChild
|
<TransitionChild
|
||||||
as="template"
|
as="template"
|
||||||
:enter-from="side === 'left' ? '-translate-x-full' : 'translate-x-full'"
|
:appear="appear"
|
||||||
enter-to="translate-x-0"
|
v-bind="slideoverTransition"
|
||||||
leave-from="translate-x-0"
|
|
||||||
:leave-to="side === 'left' ? '-translate-x-full' : 'translate-x-full'"
|
|
||||||
v-bind="transitionClass"
|
|
||||||
>
|
>
|
||||||
<DialogPanel :class="slideoverClass">
|
<DialogPanel :class="slideoverClass">
|
||||||
<div v-if="$slots.header" :class="headerClass">
|
<div v-if="$slots.header" :class="headerClass">
|
||||||
@@ -46,6 +44,10 @@ const props = defineProps({
|
|||||||
type: Boolean as PropType<boolean>,
|
type: Boolean as PropType<boolean>,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
|
appear: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
side: {
|
side: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'left',
|
default: 'left',
|
||||||
@@ -79,6 +81,10 @@ const props = defineProps({
|
|||||||
type: String,
|
type: String,
|
||||||
default: () => $ui.slideover.header
|
default: () => $ui.slideover.header
|
||||||
},
|
},
|
||||||
|
transition: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
transitionClass: {
|
transitionClass: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => $ui.slideover.transition
|
default: () => $ui.slideover.transition
|
||||||
@@ -103,6 +109,28 @@ const slideoverClass = computed(() => {
|
|||||||
props.backgroundClass
|
props.backgroundClass
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const overlayTransition = computed(() => {
|
||||||
|
if (!props.transition) {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
return props.overlayTransitionClass
|
||||||
|
})
|
||||||
|
|
||||||
|
const slideoverTransition = computed(() => {
|
||||||
|
if (!props.transition) {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
enterFrom: props.side === 'left' ? '-translate-x-full' : 'translate-x-full',
|
||||||
|
enterTo: 'translate-x-0',
|
||||||
|
leaveFrom: 'translate-x-0',
|
||||||
|
leaveTo: props.side === 'left' ? '-translate-x-full' : 'translate-x-full',
|
||||||
|
...props.transitionClass
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|||||||
Reference in New Issue
Block a user