import * as React from 'react'; import Tooltip from '../tooltip'; export interface CommentProps { /** List of action items rendered below the comment content */ actions?: Array; /** The element to display as the comment author. */ author: string; /** The element to display as the comment avatar - generally an antd Avatar */ avatar: React.ReactNode; /** The main content of the comment */ children: React.ReactNode; /** Additional style for the comment content */ contentStyle?: React.CSSProperties; /** Additional style for the comment head */ headStyle?: React.CSSProperties; /** Optional ID for the comment */ id?: string; /** Additional style for the comment inner wrapper */ innerStyle?: React.CSSProperties; /** Comment prefix className defaults to '.ant-comment' */ prefixCls?: string; /** Additional style for the comment */ style?: React.CSSProperties; /** A time element containing the time to be displayed */ time?: React.ReactNode; /** A time element to be displayed as the time tooltip */ tooltipTime?: React.ReactNode; } export default class Comment extends React.Component { getAction(actions: React.ReactNode[]) { if (!actions || !actions.length) { return null; } const actionList = actions.map((action, index) => (
  • {action}
  • ), ); return actionList; } render() { const { actions, author, avatar, children, contentStyle = {}, headStyle = {}, innerStyle = {}, prefixCls = 'ant-comment', style = {}, time, tooltipTime, ...otherProps } = this.props; const avatarDom = typeof avatar === 'string' ? : avatar; let timeDom; if (time) { timeDom = {time} } if (time && tooltipTime) { timeDom = ( {time} ) } const head = (
    {avatarDom}
    {author} {timeDom}
    ); const actionDom = actions && actions.length ? : null; const content = (
    {children}
    {actionDom}
    ); return (
    {head} {content}
    ); } }