Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复modal微信端无动效问题 #1139

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions compiled/alipay/src/Modal/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export interface IModalProps extends IBaseProps {
* @description 过渡动画时长,单位毫秒
*/
duration: number;
/**
* @description 是否开启过渡动画
*/
animation: boolean;
/**
* @description 弹窗层级
*/
zIndex: number;
/**
* @description 标题
*/
Expand Down Expand Up @@ -103,6 +111,8 @@ export const ModalDefaultProps: Partial<IModalProps> = {
closable: true,
type: 'default',
duration: 200,
animation: true,
zIndex: 998,
};

export const ModalFunctionalProps: Partial<IModalProps> = {
Expand All @@ -114,6 +124,8 @@ export const ModalFunctionalProps: Partial<IModalProps> = {
type: 'default',
closable: true,
duration: 200,
animation: true,
zIndex: 998,
title: '',
content: '',
visible: false,
Expand Down
4 changes: 4 additions & 0 deletions compiled/wechat/src/Modal/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export var ModalDefaultProps = {
closable: true,
type: 'default',
duration: 200,
animation: true,
zIndex: 998,
};
export var ModalFunctionalProps = {
bodyClassName: '',
Expand All @@ -14,6 +16,8 @@ export var ModalFunctionalProps = {
type: 'default',
closable: true,
duration: 200,
animation: true,
zIndex: 998,
title: '',
content: '',
visible: false,
Expand Down
50 changes: 24 additions & 26 deletions src/Modal/index.axml.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,32 @@ import AntPopup from '../Popup/index.axml';
import AntButton from '../Button/index.axml';
import AntIcon from '../Icon/index.axml';
import { IModalProps } from './props';
import { TSXMLProps, InternalData } from 'tsxml';
import { TSXMLProps } from 'tsxml';
import utils from './index.sjs';

export default (
{
className,
style,
maskClassName,
maskStyle,
visible,
duration,
destroyOnClose,
bodyClassName,
bodyStyle,
title,
content,
type,
primaryButtonText,
primaryButtonStyle,
secondaryButtonText,
secondaryButtonStyle,
cancelButtonText,
cancelButtonStyle,
closable,
}: TSXMLProps<IModalProps>,

{ animation, zIndex }: InternalData
) => (
export default ({
className,
style,
maskClassName,
maskStyle,
visible,
duration,
destroyOnClose,
bodyClassName,
bodyStyle,
title,
content,
type,
primaryButtonText,
primaryButtonStyle,
secondaryButtonText,
secondaryButtonStyle,
cancelButtonText,
cancelButtonStyle,
closable,
animation,
zIndex,
}: TSXMLProps<IModalProps>) => (
<Component>
<AntPopup
className={`ant-modal ${className || ''}`}
Expand Down
12 changes: 12 additions & 0 deletions src/Modal/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export interface IModalProps extends IBaseProps {
* @description 过渡动画时长,单位毫秒
*/
duration: number;
/**
* @description 是否开启过渡动画
*/
animation: boolean;
/**
* @description 弹窗层级
*/
zIndex: number;
/**
* @description 标题
*/
Expand Down Expand Up @@ -103,6 +111,8 @@ export const ModalDefaultProps: Partial<IModalProps> = {
closable: true,
type: 'default',
duration: 200,
animation: true,
zIndex: 998,
};

export const ModalFunctionalProps: Partial<IModalProps> = {
Expand All @@ -114,6 +124,8 @@ export const ModalFunctionalProps: Partial<IModalProps> = {
type: 'default',
closable: true,
duration: 200,
animation: true,
zIndex: 998,
title: '',
content: '',
visible: false,
Expand Down
51 changes: 51 additions & 0 deletions tests/alipay/Modal/__tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,57 @@
import { getInstance } from 'tests/utils';
import { describe, it, expect, vi } from 'vitest';

describe('init', () => {
it('测试默认值', () => {
const instance = getInstance('Modal', {});

const {
bodyClassName,
bodyStyle,
maskClassName,
maskStyle,
maskClosable,
type,
closable,
duration,
animation,
zIndex,
title,
content,
visible,
destroyOnClose,
primaryButtonText,
secondaryButtonText,
cancelButtonText,
primaryButtonStyle,
secondaryButtonStyle,
cancelButtonStyle,
} = instance.getConfig().props;
expect({
bodyClassName,
bodyStyle,
maskClassName,
maskStyle,
maskClosable,
type,
closable,
duration,
animation,
zIndex,
title,
content,
visible,
destroyOnClose,
primaryButtonText,
secondaryButtonText,
cancelButtonText,
primaryButtonStyle,
secondaryButtonStyle,
cancelButtonStyle,
}).toMatchFileSnapshot('snapshot/alipay_config_props.txt');
});
});

describe('modal onClose', () => {
it('modal onClose', () => {
const onClose = vi.fn();
Expand Down
22 changes: 22 additions & 0 deletions tests/alipay/Modal/__tests__/snapshot/alipay_config_props.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"animation": true,
"bodyClassName": "",
"bodyStyle": "",
"cancelButtonStyle": "",
"cancelButtonText": "",
"closable": true,
"content": "",
"destroyOnClose": false,
"duration": 200,
"maskClassName": "",
"maskClosable": true,
"maskStyle": "",
"primaryButtonStyle": "",
"primaryButtonText": "",
"secondaryButtonStyle": "",
"secondaryButtonText": "",
"title": "",
"type": "default",
"visible": false,
"zIndex": 998,
}
Loading