feat(ShareSheet): add round prop (#9645)

This commit is contained in:
neverland 2021-10-09 10:28:08 +08:00 committed by GitHub
parent e5a92fe6a9
commit 80c3b5b362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 2 deletions

View File

@ -120,7 +120,7 @@ test('should allow to use the teleport prop', () => {
expect(root.querySelector('.van-action-sheet')).toBeTruthy(); expect(root.querySelector('.van-action-sheet')).toBeTruthy();
}); });
test('should have "van-popup--round" class when setting the round prop', () => { test('should have "van-popup--round" class when setting the round prop', async () => {
const wrapper = mount(ActionSheet, { const wrapper = mount(ActionSheet, {
props: { props: {
show: true, show: true,
@ -129,6 +129,9 @@ test('should have "van-popup--round" class when setting the round prop', () => {
}); });
expect(wrapper.find('.van-popup--round').exists()).toBeTruthy(); expect(wrapper.find('.van-popup--round').exists()).toBeTruthy();
await wrapper.setProps({ round: false });
expect(wrapper.find('.van-popup--round').exists()).toBeFalsy();
}); });
test('should change option color when using the color prop', () => { test('should change option color when using the color prop', () => {

View File

@ -174,6 +174,7 @@ export default {
| cancel-text | Cancel button text | _string_ | `'Cancel'` | | cancel-text | Cancel button text | _string_ | `'Cancel'` |
| description | Description | _string_ | - | | description | Description | _string_ | - |
| duration | Transition duration, unit second | _number \| string_ | `0.3` | | duration | Transition duration, unit second | _number \| string_ | `0.3` |
| round `v3.2.6` | Whether to show round corner | _boolean_ | `true` |
| overlay | Whether to show overlay | _boolean_ | `true` | | overlay | Whether to show overlay | _boolean_ | `true` |
| overlay-class | Custom overlay class | _string \| Array \| object_ | - | | overlay-class | Custom overlay class | _string \| Array \| object_ | - |
| overlay-style | Custom overlay style | _object_ | - | | overlay-style | Custom overlay style | _object_ | - |

View File

@ -186,6 +186,7 @@ export default {
| cancel-text | 取消按钮文字,传入空字符串可以隐藏按钮 | _string_ | `'取消'` | | cancel-text | 取消按钮文字,传入空字符串可以隐藏按钮 | _string_ | `'取消'` |
| description | 标题下方的辅助描述文字 | _string_ | - | | description | 标题下方的辅助描述文字 | _string_ | - |
| duration | 动画时长,单位秒,设置为 0 可以禁用动画 | _number \| string_ | `0.3` | | duration | 动画时长,单位秒,设置为 0 可以禁用动画 | _number \| string_ | `0.3` |
| round `v3.2.6` | 是否显示圆角 | _boolean_ | `true` |
| overlay | 是否显示遮罩层 | _boolean_ | `true` | | overlay | 是否显示遮罩层 | _boolean_ | `true` |
| overlay-class | 自定义遮罩层类名 | _string \| Array \| object_ | - | | overlay-class | 自定义遮罩层类名 | _string \| Array \| object_ | - |
| overlay-style | 自定义遮罩层样式 | _object_ | - | | overlay-style | 自定义遮罩层样式 | _object_ | - |

View File

@ -35,6 +35,7 @@ const PRESET_ICONS = [
const popupKeys = [ const popupKeys = [
...popupSharedPropKeys, ...popupSharedPropKeys,
'round',
'closeOnPopstate', 'closeOnPopstate',
'safeAreaInsetBottom', 'safeAreaInsetBottom',
] as const; ] as const;
@ -53,6 +54,7 @@ export default defineComponent({
props: extend({}, popupSharedProps, { props: extend({}, popupSharedProps, {
title: String, title: String,
round: truthProp,
options: makeArrayProp<ShareSheetOption | ShareSheetOption[]>(), options: makeArrayProp<ShareSheetOption | ShareSheetOption[]>(),
cancelText: String, cancelText: String,
description: String, description: String,
@ -136,7 +138,6 @@ export default defineComponent({
return () => ( return () => (
<Popup <Popup
round
class={bem()} class={bem()}
position="bottom" position="bottom"
{...pick(props, popupKeys)} {...pick(props, popupKeys)}

View File

@ -117,3 +117,17 @@ test('should render cancel slot correctly', async () => {
expect(wrapper.find('.van-share-sheet__cancel').html()).toMatchSnapshot(); expect(wrapper.find('.van-share-sheet__cancel').html()).toMatchSnapshot();
}); });
test('should have "van-popup--round" class when setting the round prop', async () => {
const wrapper = mount(ShareSheet, {
props: {
show: true,
round: true,
},
});
expect(wrapper.find('.van-popup--round').exists()).toBeTruthy();
await wrapper.setProps({ round: false });
expect(wrapper.find('.van-popup--round').exists()).toBeFalsy();
});