Skip to content

Commit

Permalink
feat: popover support empty slot
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Mar 17, 2022
1 parent 85197c4 commit 71e1100
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions components/popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { computed, defineComponent, ref } from 'vue';
import Tooltip from '../tooltip';
import abstractTooltipProps from '../tooltip/abstractTooltipProps';
import PropTypes from '../_util/vue-types';
import { initDefaultProps } from '../_util/props-util';
import { filterEmpty, initDefaultProps } from '../_util/props-util';
import { withInstall } from '../_util/type';
import useConfigInject from '../_util/hooks/useConfigInject';
import omit from '../_util/omit';
Expand Down Expand Up @@ -39,10 +39,14 @@ const Popover = defineComponent({
const { prefixCls, configProvider } = useConfigInject('popover', props);
const rootPrefixCls = computed(() => configProvider.getPrefixCls());
const getOverlay = () => {
const { title = slots.title?.(), content = slots.content?.() } = props;
const { title = filterEmpty(slots.title?.()), content = filterEmpty(slots.content?.()) } =
props;
const hasTitle = !!(Array.isArray(title) ? title.length : title);
const hasContent = !!(Array.isArray(content) ? content.length : title);
if (!hasTitle && !hasContent) return undefined;
return (
<>
{title && <div class={`${prefixCls.value}-title`}>{title}</div>}
{hasTitle && <div class={`${prefixCls.value}-title`}>{title}</div>}
<div class={`${prefixCls.value}-inner-content`}>{content}</div>
</>
);
Expand Down

0 comments on commit 71e1100

Please sign in to comment.