-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: modal 适配微信 * fix: remove cancel --------- Co-authored-by: DiamondYuan <fandi.yfd@antgroup.com>
- Loading branch information
1 parent
08f7a92
commit 07034fd
Showing
27 changed files
with
800 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"defaultTitle": "Modal", | ||
"usingComponents": { | ||
"modal": "../../../src/Modal/index", | ||
"button": "../../../src/Button/index", | ||
"icon": "../../../src/Icon/index", | ||
"container": "../../../src/Container/index" | ||
"ant-modal": "../../../src/Modal/index", | ||
"ant-button": "../../../src/Button/index", | ||
"ant-icon": "../../../src/Icon/index", | ||
"ant-container": "../../../src/Container/index" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,29 @@ | ||
import { ModalDefaultProps } from './props'; | ||
import { useEvent } from 'functional-mini/component'; | ||
import '../_util/assert-component2'; | ||
import { mountComponent } from '../_util/component'; | ||
import { useComponentEvent } from '../_util/hooks/useComponentEvent'; | ||
import { IModalProps, ModalFunctionalProps } from './props'; | ||
|
||
Component({ | ||
props: ModalDefaultProps, | ||
methods: { | ||
onClose() { | ||
const { onClose } = this.props; | ||
if (onClose) { | ||
onClose(); | ||
} | ||
}, | ||
onMaskClose() { | ||
const { onClose, maskClosable } = this.props; | ||
if (maskClosable && onClose) { | ||
onClose(); | ||
} | ||
}, | ||
onPrimaryButtonTap() { | ||
const { onPrimaryButtonTap } = this.props; | ||
if (onPrimaryButtonTap) { | ||
onPrimaryButtonTap(); | ||
} | ||
}, | ||
onSecondaryButtonTap() { | ||
const { onSecondaryButtonTap } = this.props; | ||
if (onSecondaryButtonTap) { | ||
onSecondaryButtonTap(); | ||
} | ||
}, | ||
onCancelButtonTap() { | ||
const { onCancelButtonTap } = this.props; | ||
if (onCancelButtonTap) { | ||
onCancelButtonTap(); | ||
} | ||
}, | ||
}, | ||
}); | ||
const Modal = (props: IModalProps) => { | ||
const { triggerEventOnly } = useComponentEvent(props); | ||
useEvent('onClose', () => { | ||
triggerEventOnly('close'); | ||
}); | ||
useEvent('onMaskClose', () => { | ||
if (props.maskClosable) { | ||
triggerEventOnly('close'); | ||
} | ||
}); | ||
useEvent('onPrimaryButtonTap', () => { | ||
triggerEventOnly('primaryButtonTap'); | ||
}); | ||
useEvent('onSecondaryButtonTap', () => { | ||
triggerEventOnly('secondaryButtonTap'); | ||
}); | ||
useEvent('onCancelButtonTap', () => { | ||
triggerEventOnly('cancelButtonTap'); | ||
}); | ||
return {}; | ||
}; | ||
|
||
mountComponent(Modal, ModalFunctionalProps); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Page({ | ||
data: { | ||
basicVisible: false, | ||
withTitleVisible: false, | ||
basicTwoVisible: false, | ||
basicThreeVisible: false, | ||
focusOneVisible: false, | ||
focusTwoVisible: false, | ||
focusThreeVisible: false, | ||
customVisible: false, | ||
customBodyVisible: false, | ||
}, | ||
handleOpen: function (e) { | ||
var _a; | ||
var field = e.target.dataset.field; | ||
this.setData((_a = {}, _a[field] = true, _a)); | ||
}, | ||
handleClose: function () { | ||
this.setData({ | ||
basicVisible: false, | ||
withTitleVisible: false, | ||
basicTwoVisible: false, | ||
basicThreeVisible: false, | ||
focusOneVisible: false, | ||
focusTwoVisible: false, | ||
focusThreeVisible: false, | ||
customVisible: false, | ||
customBodyVisible: false, | ||
}); | ||
}, | ||
handlePrimaryButtonTap: function () { | ||
this.handleClose(); | ||
this.showToast('点击主要按钮'); | ||
}, | ||
handleSecondaryButtonTap: function () { | ||
this.handleClose(); | ||
this.showToast('点击辅助按钮'); | ||
}, | ||
handleCancelButtonTap: function () { | ||
this.handleClose(); | ||
this.showToast('点击取消按钮'); | ||
}, | ||
showToast: function (content) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
//@ts-ignore | ||
wx.showToast({ | ||
title: content, | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"defaultTitle": "Modal", | ||
"usingComponents": { | ||
"ant-modal": "../../../src/Modal/index", | ||
"ant-button": "../../../src/Button/index", | ||
"ant-icon": "../../../src/Icon/index", | ||
"ant-container": "../../../src/Container/index" | ||
} | ||
} |
Oops, something went wrong.