mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-08-10 06:29:46 +08:00
feat(ActionSheet): add close-icon prop (#5016)
This commit is contained in:
parent
f871c84b18
commit
5d157c409b
@ -26,6 +26,7 @@ export type ActionSheetProps = PopupMixinProps & {
|
|||||||
title?: string;
|
title?: string;
|
||||||
actions?: ActionSheetItem[];
|
actions?: ActionSheetItem[];
|
||||||
duration: number;
|
duration: number;
|
||||||
|
closeIcon: string;
|
||||||
cancelText?: string;
|
cancelText?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
closeOnClickAction?: boolean;
|
closeOnClickAction?: boolean;
|
||||||
@ -52,7 +53,7 @@ function ActionSheet(
|
|||||||
return (
|
return (
|
||||||
<div class={[bem('header'), BORDER_BOTTOM]}>
|
<div class={[bem('header'), BORDER_BOTTOM]}>
|
||||||
{title}
|
{title}
|
||||||
<Icon name="close" class={bem('close')} onClick={onCancel} />
|
<Icon name={props.closeIcon} class={bem('close')} onClick={onCancel} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -158,6 +159,10 @@ ActionSheet.props = {
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
|
closeIcon: {
|
||||||
|
type: String,
|
||||||
|
default: 'close'
|
||||||
|
},
|
||||||
safeAreaInsetBottom: {
|
safeAreaInsetBottom: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
|
@ -6,6 +6,13 @@ exports[`callback events 1`] = `
|
|||||||
</button><button class="van-action-sheet__item van-hairline--top"><span class="van-action-sheet__name">Option</span><span class="van-action-sheet__subname">Subname</span></button><button class="van-action-sheet__cancel">Cancel</button></div>
|
</button><button class="van-action-sheet__item van-hairline--top"><span class="van-action-sheet__name">Option</span><span class="van-action-sheet__subname">Subname</span></button><button class="van-action-sheet__cancel">Cancel</button></div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`close-icon prop 1`] = `
|
||||||
|
<div class="van-popup van-popup--round van-popup--bottom van-popup--safe-area-inset-bottom van-action-sheet" name="van-popup-slide-bottom">
|
||||||
|
<div class="van-action-sheet__header van-hairline--bottom">Title<i class="van-icon van-icon-cross van-action-sheet__close">
|
||||||
|
<!----></i></div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`color option 1`] = `<div class="van-popup van-popup--round van-popup--bottom van-popup--safe-area-inset-bottom van-action-sheet" name="van-popup-slide-bottom"><button class="van-action-sheet__item van-hairline--top" style="color: red;"><span class="van-action-sheet__name">Option</span></button></div>`;
|
exports[`color option 1`] = `<div class="van-popup van-popup--round van-popup--bottom van-popup--safe-area-inset-bottom van-action-sheet" name="van-popup-slide-bottom"><button class="van-action-sheet__item van-hairline--top" style="color: red;"><span class="van-action-sheet__name">Option</span></button></div>`;
|
||||||
|
|
||||||
exports[`description prop 1`] = `
|
exports[`description prop 1`] = `
|
||||||
@ -16,6 +23,12 @@ exports[`description prop 1`] = `
|
|||||||
|
|
||||||
exports[`disable lazy-render 1`] = `<div class="van-popup van-popup--round van-popup--bottom van-popup--safe-area-inset-bottom van-action-sheet" style="display: none;" name="van-popup-slide-bottom"><button class="van-action-sheet__item van-hairline--top"><span class="van-action-sheet__name">Option</span></button><button class="van-action-sheet__item van-hairline--top"><span class="van-action-sheet__name">Option</span></button><button class="van-action-sheet__cancel">Cancel</button></div>`;
|
exports[`disable lazy-render 1`] = `<div class="van-popup van-popup--round van-popup--bottom van-popup--safe-area-inset-bottom van-action-sheet" style="display: none;" name="van-popup-slide-bottom"><button class="van-action-sheet__item van-hairline--top"><span class="van-action-sheet__name">Option</span></button><button class="van-action-sheet__item van-hairline--top"><span class="van-action-sheet__name">Option</span></button><button class="van-action-sheet__cancel">Cancel</button></div>`;
|
||||||
|
|
||||||
exports[`render title and default slot 1`] = ``;
|
exports[`render title and default slot 1`] = `
|
||||||
|
<div class="van-popup van-popup--round van-popup--bottom van-popup--safe-area-inset-bottom van-action-sheet" name="van-popup-slide-bottom">
|
||||||
|
<div class="van-action-sheet__header van-hairline--bottom">Title<i class="van-icon van-icon-close van-action-sheet__close">
|
||||||
|
<!----></i></div>
|
||||||
|
<div class="van-action-sheet__content">Default</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`round prop 1`] = `<div class="van-popup van-popup--round van-popup--bottom van-popup--safe-area-inset-bottom van-action-sheet" name="van-popup-slide-bottom"><button class="van-action-sheet__item van-hairline--top"><span class="van-action-sheet__name">Option</span></button></div>`;
|
exports[`round prop 1`] = `<div class="van-popup van-popup--round van-popup--bottom van-popup--safe-area-inset-bottom van-action-sheet" name="van-popup-slide-bottom"><button class="van-action-sheet__item van-hairline--top"><span class="van-action-sheet__name">Option</span></button></div>`;
|
||||||
|
@ -96,6 +96,7 @@ test('disable lazy-render', () => {
|
|||||||
test('render title and default slot', () => {
|
test('render title and default slot', () => {
|
||||||
const wrapper = mount(ActionSheet, {
|
const wrapper = mount(ActionSheet, {
|
||||||
propsData: {
|
propsData: {
|
||||||
|
value: true,
|
||||||
title: 'Title'
|
title: 'Title'
|
||||||
},
|
},
|
||||||
scopedSlots: {
|
scopedSlots: {
|
||||||
@ -174,3 +175,15 @@ test('description prop', () => {
|
|||||||
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('close-icon prop', () => {
|
||||||
|
const wrapper = mount(ActionSheet, {
|
||||||
|
propsData: {
|
||||||
|
value: true,
|
||||||
|
title: 'Title',
|
||||||
|
closeIcon: 'cross'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user