feat(Calendar): add top-info、bottom-info slot (#8716)

This commit is contained in:
neverland
2021-05-18 10:09:02 +08:00
committed by GitHub
parent c0fa715cf4
commit db41f5ad44
7 changed files with 82 additions and 21 deletions
+29 -9
View File
@@ -44,7 +44,7 @@ export default defineComponent({
emits: ['click'],
setup(props, { emit }) {
setup(props, { emit, slots }) {
const style = computed(() => {
const { item, index, color, offset, rowHeight } = props;
const style: CSSProperties = {
@@ -84,17 +84,37 @@ export default defineComponent({
}
};
const renderTopInfo = () => {
const { topInfo } = props.item;
if (topInfo || slots['top-info']) {
return (
<div class={bem('top-info')}>
{slots['top-info'] ? slots['top-info'](props.item) : topInfo}
</div>
);
}
};
const renderBottomInfo = () => {
const { bottomInfo } = props.item;
if (bottomInfo || slots['bottom-info']) {
return (
<div class={bem('bottom-info')}>
{slots['bottom-info']
? slots['bottom-info'](props.item)
: bottomInfo}
</div>
);
}
};
const renderContent = () => {
const { item, color, rowHeight } = props;
const { type, text, topInfo, bottomInfo } = item;
const { type, text } = item;
const TopInfo = topInfo && <div class={bem('top-info')}>{topInfo}</div>;
const BottomInfo = bottomInfo && (
<div class={bem('bottom-info')}>{bottomInfo}</div>
);
const Nodes = [TopInfo, text, BottomInfo];
const Nodes = [renderTopInfo(), text, renderBottomInfo()];
if (type === 'selected') {
return (