From b62c0e32cf1357081431281fe637a4c3dec3fbf9 Mon Sep 17 00:00:00 2001 From: Mikasa33 Date: Sat, 5 Sep 2020 14:36:20 +0800 Subject: [PATCH] feat(ActionSheet): add closeable prop (#7099) * feat(ActionSheet): add closeable prop * feat(ActionSheet): add closeable prop * Update index.tsx Co-authored-by: neverland --- src/action-sheet/README.md | 1 + src/action-sheet/README.zh-CN.md | 1 + src/action-sheet/index.tsx | 19 +++++++++++++------ src/action-sheet/test/index.spec.js | 12 ++++++++++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/action-sheet/README.md b/src/action-sheet/README.md index c819f68d0..c7e67d974 100644 --- a/src/action-sheet/README.md +++ b/src/action-sheet/README.md @@ -155,6 +155,7 @@ export default { | title | Title | _string_ | - | | cancel-text | Text of cancel button | _string_ | - | | description | Description above the options | _string_ | - | +| closeable `v2.10.5` | Whether to show close icon | _boolean_ | `true` | | close-icon | Close icon name | _string_ | `cross` | | duration | Transition duration, unit second | _number \| string_ | `0.3` | | round | Whether to show round corner | _boolean_ | `true` | diff --git a/src/action-sheet/README.zh-CN.md b/src/action-sheet/README.zh-CN.md index fb11024b0..4c536711d 100644 --- a/src/action-sheet/README.zh-CN.md +++ b/src/action-sheet/README.zh-CN.md @@ -161,6 +161,7 @@ export default { | title | 顶部标题 | _string_ | - | | cancel-text | 取消按钮文字 | _string_ | - | | description | 选项上方的描述信息 | _string_ | - | +| closeable `v2.10.5` | 是否显示关闭图标 | _boolean_ | `true` | | close-icon | 关闭[图标名称](#/zh-CN/icon)或图片链接 | _string_ | `cross` | | duration | 动画时长,单位秒 | _number \| string_ | `0.3` | | round | 是否显示圆角 | _boolean_ | `true` | diff --git a/src/action-sheet/index.tsx b/src/action-sheet/index.tsx index b06e657ec..bf91976a4 100644 --- a/src/action-sheet/index.tsx +++ b/src/action-sheet/index.tsx @@ -30,6 +30,7 @@ export type ActionSheetProps = PopupMixinProps & { title?: string; actions?: ActionSheetItem[]; duration: number | string; + closeable?: boolean; closeIcon: string; cancelText?: string; description?: string; @@ -50,7 +51,7 @@ function ActionSheet( slots: ActionSheetSlots, ctx: RenderContext ) { - const { title, cancelText } = props; + const { title, cancelText, closeable } = props; function onCancel() { emit(ctx, 'input', false); @@ -62,11 +63,13 @@ function ActionSheet( return (
{title} - + {closeable && ( + + )}
); } @@ -179,6 +182,10 @@ ActionSheet.props = { type: Boolean, default: true, }, + closeable: { + type: Boolean, + default: true, + }, closeIcon: { type: String, default: 'cross', diff --git a/src/action-sheet/test/index.spec.js b/src/action-sheet/test/index.spec.js index 04365ac75..f73946c2e 100644 --- a/src/action-sheet/test/index.spec.js +++ b/src/action-sheet/test/index.spec.js @@ -198,3 +198,15 @@ test('close-icon prop', () => { expect(wrapper).toMatchSnapshot(); }); + +test('closeable prop', () => { + const wrapper = mount(ActionSheet, { + propsData: { + value: true, + title: 'Title', + closeable: false, + }, + }); + + expect(wrapper).toMatchSnapshot(); +});