import React, { useMemo } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import { Avatar, Badge, Icon } from '@edx/paragon'; import { Issue, Question } from '../../../components/icons'; import { AvatarOutlineAndLabelColors, ThreadType } from '../../../data/constants'; import { AuthorLabel } from '../../common'; import { useAlertBannerVisible } from '../../data/hooks'; import messages from './messages'; import { postShape } from './proptypes'; export function PostAvatar({ post, authorLabel, fromPostLink, read, }) { const outlineColor = AvatarOutlineAndLabelColors[authorLabel]; const avatarSize = useMemo(() => { let size = '2rem'; if (post.type === ThreadType.DISCUSSION && !fromPostLink) { size = '2rem'; } else if (post.type === ThreadType.QUESTION) { size = '1.5rem'; } return size; }, [post.type]); const avatarSpacing = useMemo(() => { let spacing = 'mr-3 '; if (post.type === ThreadType.DISCUSSION && fromPostLink) { spacing += 'pt-2 ml-0.5'; } else if (post.type === ThreadType.DISCUSSION) { spacing += 'ml-0.5 mt-0.5'; } return spacing; }, [post.type]); return (