2017-08-09 14:34:10 +08:00
|
|
|
import classNames from 'classnames';
|
2023-05-05 20:52:44 +08:00
|
|
|
import React from 'react';
|
2022-05-07 14:31:54 +08:00
|
|
|
import type { ConfigConsumerProps } from '../config-provider';
|
2022-12-25 18:34:42 +08:00
|
|
|
import { ConfigContext } from '../config-provider';
|
2017-08-09 14:34:10 +08:00
|
|
|
|
|
|
|
export interface CardMetaProps {
|
|
|
|
prefixCls?: string;
|
|
|
|
style?: React.CSSProperties;
|
|
|
|
className?: string;
|
|
|
|
avatar?: React.ReactNode;
|
|
|
|
title?: React.ReactNode;
|
|
|
|
description?: React.ReactNode;
|
|
|
|
}
|
|
|
|
|
2022-12-25 18:34:42 +08:00
|
|
|
const Meta: React.FC<CardMetaProps> = (props) => {
|
|
|
|
const { prefixCls: customizePrefixCls, className, avatar, title, description, ...others } = props;
|
|
|
|
|
|
|
|
const { getPrefixCls } = React.useContext<ConfigConsumerProps>(ConfigContext);
|
|
|
|
|
|
|
|
const prefixCls = getPrefixCls('card', customizePrefixCls);
|
|
|
|
|
|
|
|
const classString = classNames(`${prefixCls}-meta`, className);
|
|
|
|
|
|
|
|
const avatarDom: React.ReactNode = avatar ? (
|
|
|
|
<div className={`${prefixCls}-meta-avatar`}>{avatar}</div>
|
|
|
|
) : null;
|
|
|
|
|
|
|
|
const titleDom: React.ReactNode = title ? (
|
|
|
|
<div className={`${prefixCls}-meta-title`}>{title}</div>
|
|
|
|
) : null;
|
|
|
|
|
|
|
|
const descriptionDom: React.ReactNode = description ? (
|
|
|
|
<div className={`${prefixCls}-meta-description`}>{description}</div>
|
|
|
|
) : null;
|
|
|
|
|
|
|
|
const MetaDetail: React.ReactNode =
|
|
|
|
titleDom || descriptionDom ? (
|
|
|
|
<div className={`${prefixCls}-meta-detail`}>
|
|
|
|
{titleDom}
|
|
|
|
{descriptionDom}
|
|
|
|
</div>
|
|
|
|
) : null;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div {...others} className={classString}>
|
|
|
|
{avatarDom}
|
|
|
|
{MetaDetail}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2019-02-19 13:37:38 +08:00
|
|
|
|
|
|
|
export default Meta;
|