mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Calendar): add subtitle slot (#8980)
This commit is contained in:
parent
8bc924ea62
commit
779f3363c2
@ -489,10 +489,10 @@ export default defineComponent({
|
|||||||
const renderCalendar = () => (
|
const renderCalendar = () => (
|
||||||
<div class={bem()}>
|
<div class={bem()}>
|
||||||
<CalendarHeader
|
<CalendarHeader
|
||||||
v-slots={{ title: slots.title }}
|
v-slots={pick(slots, ['title', 'subtitle'])}
|
||||||
title={props.title}
|
title={props.title}
|
||||||
showTitle={props.showTitle}
|
|
||||||
subtitle={state.subtitle}
|
subtitle={state.subtitle}
|
||||||
|
showTitle={props.showTitle}
|
||||||
showSubtitle={props.showSubtitle}
|
showSubtitle={props.showSubtitle}
|
||||||
firstDayOfWeek={dayOffset.value}
|
firstDayOfWeek={dayOffset.value}
|
||||||
/>
|
/>
|
||||||
|
@ -26,7 +26,8 @@ export default defineComponent({
|
|||||||
|
|
||||||
const renderSubtitle = () => {
|
const renderSubtitle = () => {
|
||||||
if (props.showSubtitle) {
|
if (props.showSubtitle) {
|
||||||
return <div class={bem('header-subtitle')}>{props.subtitle}</div>;
|
const title = slots.subtitle ? slots.subtitle() : props.subtitle;
|
||||||
|
return <div class={bem('header-subtitle')}>{title}</div>;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -332,6 +332,7 @@ Following props are supported when the type is multiple
|
|||||||
| Name | Description | SlotProps |
|
| Name | Description | SlotProps |
|
||||||
| --------------------- | ------------------------- | ---------- |
|
| --------------------- | ------------------------- | ---------- |
|
||||||
| title | Custom title | - |
|
| title | Custom title | - |
|
||||||
|
| subtitle `v3.1.3` | Custom subtitle | - |
|
||||||
| footer | Custom footer | - |
|
| footer | Custom footer | - |
|
||||||
| top-info `v3.0.17` | Custom top info of day | _day: Day_ |
|
| top-info `v3.0.17` | Custom top info of day | _day: Day_ |
|
||||||
| bottom-info `v3.0.17` | Custom bottom info of day | _day: Day_ |
|
| bottom-info `v3.0.17` | Custom bottom info of day | _day: Day_ |
|
||||||
|
@ -338,6 +338,7 @@ export default {
|
|||||||
| 名称 | 说明 | 参数 |
|
| 名称 | 说明 | 参数 |
|
||||||
| --------------------- | ------------------------ | ---------- |
|
| --------------------- | ------------------------ | ---------- |
|
||||||
| title | 自定义标题 | - |
|
| title | 自定义标题 | - |
|
||||||
|
| subtitle `v3.1.3` | 自定义日历副标题 | - |
|
||||||
| footer | 自定义底部区域内容 | - |
|
| footer | 自定义底部区域内容 | - |
|
||||||
| top-info `v3.0.17` | 自定义日期上方的提示信息 | _day: Day_ |
|
| top-info `v3.0.17` | 自定义日期上方的提示信息 | _day: Day_ |
|
||||||
| bottom-info `v3.0.17` | 自定义日期下方的提示信息 | _day: Day_ |
|
| bottom-info `v3.0.17` | 自定义日期下方的提示信息 | _day: Day_ |
|
||||||
|
@ -900,28 +900,14 @@ exports[`row-height prop 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should render top-info and bottom-info slot correctly 1`] = `
|
exports[`should render title、footer、subtitle slot correctly 1`] = `
|
||||||
<div role="gridcell"
|
|
||||||
style="margin-left: 71.42857142857143%;"
|
|
||||||
class="van-calendar__day van-calendar__day--disabled"
|
|
||||||
>
|
|
||||||
<div class="van-calendar__top-info">
|
|
||||||
top: 1
|
|
||||||
</div>
|
|
||||||
1
|
|
||||||
<div class="van-calendar__bottom-info">
|
|
||||||
bottom: 1
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`title & footer slot 1`] = `
|
|
||||||
<div class="van-calendar">
|
<div class="van-calendar">
|
||||||
<div class="van-calendar__header">
|
<div class="van-calendar__header">
|
||||||
<div class="van-calendar__header-title">
|
<div class="van-calendar__header-title">
|
||||||
Custom Title
|
Custom Title
|
||||||
</div>
|
</div>
|
||||||
<div class="van-calendar__header-subtitle">
|
<div class="van-calendar__header-subtitle">
|
||||||
|
Custom Subtitle
|
||||||
</div>
|
</div>
|
||||||
<div class="van-calendar__weekdays">
|
<div class="van-calendar__weekdays">
|
||||||
<span class="van-calendar__weekday">
|
<span class="van-calendar__weekday">
|
||||||
@ -1132,3 +1118,18 @@ exports[`title & footer slot 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`should render top-info and bottom-info slot correctly 1`] = `
|
||||||
|
<div role="gridcell"
|
||||||
|
style="margin-left: 71.42857142857143%;"
|
||||||
|
class="van-calendar__day van-calendar__day--disabled"
|
||||||
|
>
|
||||||
|
<div class="van-calendar__top-info">
|
||||||
|
top: 1
|
||||||
|
</div>
|
||||||
|
1
|
||||||
|
<div class="van-calendar__bottom-info">
|
||||||
|
bottom: 1
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
@ -344,7 +344,7 @@ test('formatter prop', async () => {
|
|||||||
expect(wrapper.html()).toMatchSnapshot();
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('title & footer slot', async () => {
|
test('should render title、footer、subtitle slot correctly', async () => {
|
||||||
const wrapper = mount(Calendar, {
|
const wrapper = mount(Calendar, {
|
||||||
props: {
|
props: {
|
||||||
minDate,
|
minDate,
|
||||||
@ -356,6 +356,7 @@ test('title & footer slot', async () => {
|
|||||||
slots: {
|
slots: {
|
||||||
title: () => 'Custom Title',
|
title: () => 'Custom Title',
|
||||||
footer: () => 'Custom Footer',
|
footer: () => 'Custom Footer',
|
||||||
|
subtitle: () => 'Custom Subtitle',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user