mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-25 16:16:20 +08:00
feat: add animation effects to VbenModal component
This commit is contained in:
@@ -59,6 +59,7 @@ export class ModalApi {
|
||||
showCancelButton: true,
|
||||
showConfirmButton: true,
|
||||
title: '',
|
||||
animationType: 'slide',
|
||||
};
|
||||
|
||||
this.store = new Store<ModalState>(
|
||||
|
@@ -5,6 +5,11 @@ import type { MaybePromise } from '@vben-core/typings';
|
||||
import type { ModalApi } from './modal-api';
|
||||
|
||||
export interface ModalProps {
|
||||
/**
|
||||
* 动画类型
|
||||
* @default 'slide'
|
||||
*/
|
||||
animationType?: 'scale' | 'slide';
|
||||
/**
|
||||
* 是否要挂载到内容区域
|
||||
* @default false
|
||||
|
@@ -94,6 +94,7 @@ const {
|
||||
submitting,
|
||||
title,
|
||||
titleTooltip,
|
||||
animationType,
|
||||
zIndex,
|
||||
} = usePriorityValues(props, state);
|
||||
|
||||
@@ -244,6 +245,7 @@ function handleClosed() {
|
||||
:modal="modal"
|
||||
:open="state?.isOpen"
|
||||
:show-close="closable"
|
||||
:animation-type="animationType"
|
||||
:z-index="zIndex"
|
||||
:overlay-blur="overlayBlur"
|
||||
close-class="top-3"
|
||||
|
@@ -20,6 +20,7 @@ import DialogOverlay from './DialogOverlay.vue';
|
||||
const props = withDefaults(
|
||||
defineProps<
|
||||
DialogContentProps & {
|
||||
animationType?: 'scale' | 'slide';
|
||||
appendTo?: HTMLElement | string;
|
||||
class?: ClassType;
|
||||
closeClass?: ClassType;
|
||||
@@ -31,7 +32,12 @@ const props = withDefaults(
|
||||
zIndex?: number;
|
||||
}
|
||||
>(),
|
||||
{ appendTo: 'body', closeDisabled: false, showClose: true },
|
||||
{
|
||||
appendTo: 'body',
|
||||
animationType: 'slide',
|
||||
closeDisabled: false,
|
||||
showClose: true,
|
||||
},
|
||||
);
|
||||
const emits = defineEmits<
|
||||
DialogContentEmits & { close: []; closed: []; opened: [] }
|
||||
@@ -43,6 +49,7 @@ const delegatedProps = computed(() => {
|
||||
modal: _modal,
|
||||
open: _open,
|
||||
showClose: __,
|
||||
animationType: ___,
|
||||
...delegated
|
||||
} = props;
|
||||
|
||||
@@ -100,7 +107,11 @@ defineExpose({
|
||||
v-bind="forwarded"
|
||||
:class="
|
||||
cn(
|
||||
'z-popup bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-top-[48%] w-full p-6 shadow-lg outline-none sm:rounded-xl',
|
||||
'z-popup bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 w-full p-6 shadow-lg outline-none sm:rounded-xl',
|
||||
{
|
||||
'data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-top-[48%]':
|
||||
animationType === 'slide',
|
||||
},
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
|
Reference in New Issue
Block a user