import { forwardRef } from 'react' import Block from '../Primitives/Block/Block' import Text from '../Text/Text' import AvatarV2 from '../AvatarV2/AvatarV2' import { AvatarV2Size } from '../AvatarV2/avatarV2.types' import { useResponsiveTokens } from '../../hooks/useResponsiveTokens' import { TimelineTokensType } from './timeline.token' import { TimelineNodeStatus } from './types' import type { TimelineNodeProps } from './types' const TimelineNode = forwardRef( ( { title, headerRightSlot, datetime, datetimeLeftSlot, datetimeRightSlot, text, maxLines = 3, user, time, status = TimelineNodeStatus.NEUTRAL, avatarProps, children, ...rest }, ref ) => { const tokens = useResponsiveTokens('TIMELINE') const { subsection, indicator } = tokens const dotColor = tokens.statusColors[status] const body = text ?? (typeof children === 'string' ? children : null) const hasBody = Boolean( body || (children && typeof children !== 'string') ) const hasHeaderRow = (title != null && title !== '') || headerRightSlot != null || datetimeLeftSlot != null || (datetime != null && datetime !== '') || datetimeRightSlot != null return ( {hasHeaderRow && ( {title != null && title !== '' && ( {title} )} {headerRightSlot != null && ( {headerRightSlot} )} {datetimeLeftSlot != null && ( {datetimeLeftSlot} )} {datetime != null && datetime !== '' && ( {datetime} )} {datetimeRightSlot != null && ( {datetimeRightSlot} )} )} {hasBody && ( {body != null ? ( {body} ) : ( children )} )} {(user || time) && ( {user && ( <> {user.name} {time != null && time !== '' && ( <> {time} )} )} {!user && time != null && time !== '' && ( {time} )} )} ) } ) TimelineNode.displayName = 'Timeline.Node' export default TimelineNode