diff --git a/src/data/constants.js b/src/data/constants.js index 016c27d7..14358108 100644 --- a/src/data/constants.js +++ b/src/data/constants.js @@ -68,6 +68,16 @@ export const RequestStatus = { DENIED: 'denied', }; +/** + * Enum for author label and avatar border color classes. + * @readonly + * @enum {string} + */ +export const AvatarBorderAndLabelColors = { + Staff: 'warning-700', + 'Community TA': 'success-700', +}; + /** * Enum for thread ordering. * @readonly diff --git a/src/discussions/comments/comment/CommentHeader.jsx b/src/discussions/comments/comment/CommentHeader.jsx index 737e2e11..b8932f26 100644 --- a/src/discussions/comments/comment/CommentHeader.jsx +++ b/src/discussions/comments/comment/CommentHeader.jsx @@ -7,7 +7,7 @@ import { injectIntl } from '@edx/frontend-platform/i18n'; import { Avatar, Icon } from '@edx/paragon'; import { CheckCircle, Verified } from '@edx/paragon/icons'; -import { ThreadType } from '../../../data/constants'; +import { AvatarBorderAndLabelColors, ThreadType } from '../../../data/constants'; import { AuthorLabel } from '../../common'; import ActionsDropdown from '../../common/ActionsDropdown'; import { selectAuthorAvatars } from '../../posts/data/selectors'; @@ -19,11 +19,17 @@ function CommentHeader({ actionHandlers, }) { const authorAvatars = useSelector(selectAuthorAvatars(comment.author)); + const colorClass = AvatarBorderAndLabelColors[comment.authorLabel]; return (
- - + +
{comment.endorsed && (postType === 'question' diff --git a/src/discussions/comments/comment/Reply.jsx b/src/discussions/comments/comment/Reply.jsx index a51806cd..5e067e35 100644 --- a/src/discussions/comments/comment/Reply.jsx +++ b/src/discussions/comments/comment/Reply.jsx @@ -7,7 +7,7 @@ import * as timeago from 'timeago.js'; import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import { Avatar, useToggle } from '@edx/paragon'; -import { ContentActions } from '../../../data/constants'; +import { AvatarBorderAndLabelColors, ContentActions } from '../../../data/constants'; import { ActionsDropdown, AlertBanner, AuthorLabel, DeleteConfirmation, } from '../../common'; @@ -32,6 +32,7 @@ function Reply({ [ContentActions.REPORT]: () => dispatch(editComment(reply.id, { flagged: !reply.abuseFlagged })), }; const authorAvatars = useSelector(selectAuthorAvatars(reply.author)); + const colorClass = AvatarBorderAndLabelColors[reply.authorLabel]; return (
- +
- + ); - const className = classNames('d-flex align-items-center'); + const className = classNames('d-flex align-items-center', labelColor); return linkToProfile ? React.createElement('a', { href: '#nowhere', className }, labelContents) : React.createElement('div', { className }, labelContents); @@ -55,11 +56,13 @@ AuthorLabel.propTypes = { author: PropTypes.string.isRequired, authorLabel: PropTypes.string, linkToProfile: PropTypes.bool, + labelColor: PropTypes.string, }; AuthorLabel.defaultProps = { linkToProfile: false, authorLabel: null, + labelColor: '', }; export default injectIntl(AuthorLabel); diff --git a/src/discussions/posts/post/LikeButton.jsx b/src/discussions/posts/post/LikeButton.jsx index 6473380c..ba28b3a9 100644 --- a/src/discussions/posts/post/LikeButton.jsx +++ b/src/discussions/posts/post/LikeButton.jsx @@ -36,7 +36,7 @@ function LikeButton( > +
dispatch(updateExistingThread(post.id, { voted: !post.voted }))} diff --git a/src/discussions/posts/post/PostHeader.jsx b/src/discussions/posts/post/PostHeader.jsx index 533335b0..0d466e51 100644 --- a/src/discussions/posts/post/PostHeader.jsx +++ b/src/discussions/posts/post/PostHeader.jsx @@ -7,16 +7,17 @@ import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import { Avatar, Badge, Icon } from '@edx/paragon'; import { Help } from '@edx/paragon/icons'; -import { ThreadType } from '../../../data/constants'; +import { AvatarBorderAndLabelColors, ThreadType } from '../../../data/constants'; import { ActionsDropdown, AuthorLabel } from '../../common'; import { selectAuthorAvatars } from '../data/selectors'; import messages from './messages'; import { postShape } from './proptypes'; -export function PostAvatar({ post }) { +export function PostAvatar({ post, authorLabel, fromPostLink }) { const authorAvatars = useSelector(selectAuthorAvatars(post.author)); + const borderColor = AvatarBorderAndLabelColors[authorLabel]; return ( -
+
{post.type === ThreadType.QUESTION && ( )} @@ -39,6 +41,13 @@ export function PostAvatar({ post }) { PostAvatar.propTypes = { post: postShape.isRequired, + authorLabel: PropTypes.string, + fromPostLink: PropTypes.bool, +}; + +PostAvatar.defaultProps = { + authorLabel: null, + fromPostLink: false, }; function PostHeader({ @@ -48,10 +57,10 @@ function PostHeader({ actionHandlers, }) { const showAnsweredBadge = preview && post.hasEndorsed && post.type === ThreadType.QUESTION; - + const authorLabelColor = AvatarBorderAndLabelColors[post.authorLabel]; return (
- +
{preview @@ -65,7 +74,11 @@ function PostHeader({
) :

{post.title}

} - +
{!preview diff --git a/src/discussions/posts/post/PostLink.jsx b/src/discussions/posts/post/PostLink.jsx index 9d432f51..bac4c35b 100644 --- a/src/discussions/posts/post/PostLink.jsx +++ b/src/discussions/posts/post/PostLink.jsx @@ -7,7 +7,7 @@ import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import { Badge, Icon } from '@edx/paragon'; import { Bookmark } from '@edx/paragon/icons'; -import { Routes, ThreadType } from '../../../data/constants'; +import { AvatarBorderAndLabelColors, Routes, ThreadType } from '../../../data/constants'; import AuthorLabel from '../../common/AuthorLabel'; import { DiscussionContext } from '../../common/context'; import { discussionsPath } from '../../utils'; @@ -32,6 +32,7 @@ function PostLink({ postId: post.id, }); const showAnsweredBadge = post.hasEndorsed && post.type === ThreadType.QUESTION; + const authorLabelColor = AvatarBorderAndLabelColors[post.authorLabel]; return ( - +
-
+
{post.title}
@@ -73,6 +74,7 @@ function PostLink({