mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 02:16:12 +08:00
feat(ActionSheet): add cancel slot (#8333)
This commit is contained in:
parent
ceebc22e63
commit
393d7cb7af
@ -78,11 +78,11 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const renderCancel = () => {
|
const renderCancel = () => {
|
||||||
if (props.cancelText) {
|
if (slots.cancel || props.cancelText) {
|
||||||
return [
|
return [
|
||||||
<div class={bem('gap')} />,
|
<div class={bem('gap')} />,
|
||||||
<button type="button" class={bem('cancel')} onClick={onCancel}>
|
<button type="button" class={bem('cancel')} onClick={onCancel}>
|
||||||
{props.cancelText}
|
{slots.cancel ? slots.cancel() : props.cancelText}
|
||||||
</button>,
|
</button>,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -212,9 +212,10 @@ export default {
|
|||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
| ----------- | ------------------ |
|
| ---------------- | ------------------------------------ |
|
||||||
| default | Custom content |
|
| default | Custom content |
|
||||||
| description | Custom description |
|
| description | Custom description above the options |
|
||||||
|
| cancel `v3.0.10` | Custom the content of cancel button |
|
||||||
|
|
||||||
### Less Variables
|
### Less Variables
|
||||||
|
|
||||||
|
@ -228,9 +228,10 @@ export default {
|
|||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
| 名称 | 说明 |
|
| 名称 | 说明 |
|
||||||
| ----------- | -------------------- |
|
| ---------------- | -------------------- |
|
||||||
| default | 自定义面板的展示内容 |
|
| default | 自定义面板的展示内容 |
|
||||||
| description | 自定义描述文案 |
|
| description | 自定义描述文案 |
|
||||||
|
| cancel `v3.0.10` | 自定义取消按钮内容 |
|
||||||
|
|
||||||
### 样式变量
|
### 样式变量
|
||||||
|
|
||||||
|
@ -5,6 +5,14 @@ exports[`should allow to custom close icon with closeIcon prop 1`] = `
|
|||||||
</i>
|
</i>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`should render cancel slot correctly 1`] = `
|
||||||
|
<button type="button"
|
||||||
|
class="van-action-sheet__cancel"
|
||||||
|
>
|
||||||
|
Custom Cancel
|
||||||
|
</button>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`should render default slot correctly 1`] = `
|
exports[`should render default slot correctly 1`] = `
|
||||||
<transition-stub>
|
<transition-stub>
|
||||||
<div class="van-overlay">
|
<div class="van-overlay">
|
||||||
|
@ -182,6 +182,19 @@ test('should render description correctly', () => {
|
|||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render cancel slot correctly', () => {
|
||||||
|
const wrapper = mount(ActionSheet, {
|
||||||
|
props: {
|
||||||
|
show: true,
|
||||||
|
},
|
||||||
|
slots: {
|
||||||
|
cancel: () => 'Custom Cancel',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.find('.van-action-sheet__cancel').html()).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
test('should render description slot when match snapshot', () => {
|
test('should render description slot when match snapshot', () => {
|
||||||
const wrapper = mount(ActionSheet, {
|
const wrapper = mount(ActionSheet, {
|
||||||
props: {
|
props: {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<demo-block card>
|
||||||
<van-cell is-link @touchstart.stop="keyboard = 'default'">
|
<van-cell is-link @touchstart.stop="keyboard = 'default'">
|
||||||
{{ t('button1') }}
|
{{ t('button1') }}
|
||||||
</van-cell>
|
</van-cell>
|
||||||
@ -25,6 +26,7 @@
|
|||||||
:placeholder="t('clickToInput')"
|
:placeholder="t('clickToInput')"
|
||||||
@touchstart.stop="keyboard = 'bindValue'"
|
@touchstart.stop="keyboard = 'bindValue'"
|
||||||
/>
|
/>
|
||||||
|
</demo-block>
|
||||||
|
|
||||||
<van-number-keyboard
|
<van-number-keyboard
|
||||||
:show="keyboard === 'default'"
|
:show="keyboard === 'default'"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`should render demo and match snapshot 1`] = `
|
exports[`should render demo and match snapshot 1`] = `
|
||||||
|
<div>
|
||||||
<div class="van-cell van-cell--clickable"
|
<div class="van-cell van-cell--clickable"
|
||||||
role="button"
|
role="button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
@ -80,6 +81,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<transition-stub>
|
<transition-stub>
|
||||||
<div class="van-number-keyboard">
|
<div class="van-number-keyboard">
|
||||||
<div class="van-number-keyboard__body">
|
<div class="van-number-keyboard__body">
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<demo-block card>
|
||||||
<van-cell center :title="t('basicUsage')">
|
<van-cell center :title="t('basicUsage')">
|
||||||
<van-stepper v-model="stepper1" />
|
<van-stepper v-model="stepper1" />
|
||||||
</van-cell>
|
</van-cell>
|
||||||
@ -43,6 +44,7 @@
|
|||||||
disable-input
|
disable-input
|
||||||
/>
|
/>
|
||||||
</van-cell>
|
</van-cell>
|
||||||
|
</demo-block>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`should render demo and match snapshot 1`] = `
|
exports[`should render demo and match snapshot 1`] = `
|
||||||
|
<div>
|
||||||
<div class="van-cell van-cell--center">
|
<div class="van-cell van-cell--center">
|
||||||
<div class="van-cell__title">
|
<div class="van-cell__title">
|
||||||
<span>
|
<span>
|
||||||
@ -280,4 +281,5 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
`;
|
`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user