From b53254e33a7931b5064cf96afc0a423a96646d87 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 21 Nov 2020 18:36:23 +0800 Subject: [PATCH 1/3] feat(Popup): add click-close-icon event (#7599) --- src/popup/README.md | 17 +++++++++-------- src/popup/README.zh-CN.md | 17 +++++++++-------- src/popup/index.js | 9 ++++++++- src/popup/test/index.spec.js | 12 ++++++++++++ 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/popup/README.md b/src/popup/README.md index ce481f84b..4b4aa8720 100644 --- a/src/popup/README.md +++ b/src/popup/README.md @@ -129,11 +129,12 @@ export default { ### Events -| Event | Description | Arguments | -| ------------- | ------------------------------- | -------------- | -| click | Emitted when Popup is clicked | _event: Event_ | -| open | Emitted when opening Popup | - | -| close | Emitted when closing Popup | - | -| opened | Emitted when Popup is opened | - | -| closed | Emitted when Popup is closed | - | -| click-overlay | Emitted when overlay is clicked | - | +| Event | Description | Arguments | +| --- | --- | --- | +| click | Emitted when Popup is clicked | _event: Event_ | +| click-overlay | Emitted when overlay is clicked | - | +| click-close-icon `v2.11.0` | Emitted when close icon is clicked | _event: Event_ | +| open | Emitted when opening Popup | - | +| close | Emitted when closing Popup | - | +| opened | Emitted when Popup is opened | - | +| closed | Emitted when Popup is closed | - | diff --git a/src/popup/README.zh-CN.md b/src/popup/README.zh-CN.md index f834c5168..67035c47a 100644 --- a/src/popup/README.zh-CN.md +++ b/src/popup/README.zh-CN.md @@ -140,11 +140,12 @@ export default { ### Events -| 事件名 | 说明 | 回调参数 | -| ------------- | -------------------------- | -------------- | -| click | 点击弹出层时触发 | _event: Event_ | -| open | 打开弹出层时触发 | - | -| close | 关闭弹出层时触发 | - | -| opened | 打开弹出层且动画结束后触发 | - | -| closed | 关闭弹出层且动画结束后触发 | - | -| click-overlay | 点击遮罩层时触发 | - | +| 事件名 | 说明 | 回调参数 | +| -------------------------- | -------------------------- | -------------- | +| click | 点击弹出层时触发 | _event: Event_ | +| click-overlay | 点击遮罩层时触发 | - | +| click-close-icon `v2.11.0` | 点击关闭图标时触发 | _event: Event_ | +| open | 打开弹出层时触发 | - | +| close | 关闭弹出层时触发 | - | +| opened | 打开弹出层且动画结束后触发 | - | +| closed | 关闭弹出层且动画结束后触发 | - | diff --git a/src/popup/index.js b/src/popup/index.js index d10199839..f10207495 100644 --- a/src/popup/index.js +++ b/src/popup/index.js @@ -44,6 +44,13 @@ export default createComponent({ this.onClosed = createEmitter('closed'); }, + methods: { + onClickCloseIcon(event) { + this.$emit('click-close-icon', event); + this.close(); + }, + }, + render() { if (!this.shouldRender) { return; @@ -86,7 +93,7 @@ export default createComponent({ tabindex="0" name={this.closeIcon} class={bem('close-icon', this.closeIconPosition)} - onClick={this.close} + onClick={this.onClickCloseIcon} /> )} diff --git a/src/popup/test/index.spec.js b/src/popup/test/index.spec.js index f570087a7..993e9e8e0 100644 --- a/src/popup/test/index.spec.js +++ b/src/popup/test/index.spec.js @@ -252,6 +252,18 @@ test('closeable prop', () => { expect(wrapper.emitted('input')[0][0]).toEqual(false); }); +test('should emit click-close-icon event when close icon is clicked', () => { + const wrapper = mount(Popup, { + propsData: { + value: true, + closeable: true, + }, + }); + + wrapper.find('.van-popup__close-icon').trigger('click'); + expect(wrapper.emitted('click-close-icon').length).toEqual(1); +}); + test('close-icon prop', () => { const wrapper = mount(Popup, { propsData: { From 2eec9b7cafea96886aafec6c50680833c6f777bb Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 21 Nov 2020 18:37:14 +0800 Subject: [PATCH 2/3] docs(Popover): add offset prop (#7600) --- src/popover/README.md | 1 + src/popover/README.zh-CN.md | 1 + 2 files changed, 2 insertions(+) diff --git a/src/popover/README.md b/src/popover/README.md index 3203ae89f..7410727dc 100644 --- a/src/popover/README.md +++ b/src/popover/README.md @@ -163,6 +163,7 @@ export default { | actions | Actions | _Action[]_ | `[]` | | placement | Placement | _string_ | `bottom` | | theme | Theme,can be set to `dark` | _string_ | `light` | +| offset | Distance to reference | _[number, number]_ | `[0, 8]` | | overlay | Whether to show overlay | _boolean_ | `false` | | close-on-click-action | Whether to close when clicking action | _boolean_ | `true` | | close-on-click-outside | Whether to close when clicking outside | _boolean_ | `true` | diff --git a/src/popover/README.zh-CN.md b/src/popover/README.zh-CN.md index 12ade4c26..5910186df 100644 --- a/src/popover/README.zh-CN.md +++ b/src/popover/README.zh-CN.md @@ -205,6 +205,7 @@ export default { | actions | 选项列表 | _Action[]_ | `[]` | | placement | 弹出位置 | _string_ | `bottom` | | theme | 主题风格,可选值为 `dark` | _string_ | `light` | +| offset | 出现位置的偏移量 | _[number, number]_ | `[0, 8]` | | overlay | 是否显示遮罩层 | _boolean_ | `false` | | close-on-click-action | 是否在点击选项后关闭 | _boolean_ | `true` | | close-on-click-outside | 是否在点击外部元素后关闭菜单 | _boolean_ | `true` | From cda5e0869eb9e29c820e3b3df40714723e0fb01e Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 21 Nov 2020 18:43:49 +0800 Subject: [PATCH 3/3] chore(Popover): remove unused prop (#7601) --- src/popover/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/popover/index.js b/src/popover/index.js index 943fda9f9..ed1024152 100644 --- a/src/popover/index.js +++ b/src/popover/index.js @@ -31,8 +31,6 @@ export default createComponent({ props: { value: Boolean, overlay: Boolean, - textColor: String, - backgroundColor: String, offset: { type: Array, default: () => [0, 8],