import * as React from 'react'; import classNames from 'classnames'; import type { ConfigConsumerProps } from '../config-provider'; import { ConfigContext } from '../config-provider'; export interface CardMetaProps { prefixCls?: string; style?: React.CSSProperties; className?: string; avatar?: React.ReactNode; title?: React.ReactNode; description?: React.ReactNode; } const Meta: React.FC = (props) => { const { prefixCls: customizePrefixCls, className, avatar, title, description, ...others } = props; const { getPrefixCls } = React.useContext(ConfigContext); const prefixCls = getPrefixCls('card', customizePrefixCls); const classString = classNames(`${prefixCls}-meta`, className); const avatarDom: React.ReactNode = avatar ? (
{avatar}
) : null; const titleDom: React.ReactNode = title ? (
{title}
) : null; const descriptionDom: React.ReactNode = description ? (
{description}
) : null; const MetaDetail: React.ReactNode = titleDom || descriptionDom ? (
{titleDom} {descriptionDom}
) : null; return (
{avatarDom} {MetaDetail}
); }; export default Meta;