import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { cssClasses } from '@douyinfe/semi-foundation/card/constants'; import cls from 'classnames'; const prefixcls = cssClasses.PREFIX; export type Shadows = 'hover' | 'show'; export interface MetaProps { /** Avatar */ avatar?: React.ReactNode; /** Style class name */ className?: string; /** Description */ description?: React.ReactNode; /** Inline style */ style?: React.CSSProperties; /** Title */ title?: React.ReactNode; } class Meta extends PureComponent { static propTypes = { avatar: PropTypes.node, className: PropTypes.string, description: PropTypes.node, style: PropTypes.object, title: PropTypes.node }; render() { const { avatar, className, description, style, title, ...others } = this.props; const metaCls = cls(`${prefixcls}-meta`, className); const avatarNode = avatar && (
{avatar}
); const titleNode = title && (
{title}
); const descriptionNode = description && (
{description}
); const wrapper = title || description ? (
{titleNode} {descriptionNode}
) : null; return (
{avatarNode} {wrapper}
); } } export default Meta;