From d71a53d9ee7e1d35a844ad6b2e33f92507a99e15 Mon Sep 17 00:00:00 2001 From: Awais Ansari <79941147+awais-ansari@users.noreply.github.com> Date: Tue, 26 Jul 2022 17:01:48 +0500 Subject: [PATCH] fix: post avatar alignment and size (#214) * fix: post avatar alignment and size * refactor: post header scss class --- src/components/icons/Issue.jsx | 26 ++++++++++ src/components/icons/Question.jsx | 37 +++++--------- src/components/icons/index.js | 1 + src/discussions/posts/post/PostHeader.jsx | 62 +++++++++++++---------- src/discussions/posts/post/PostLink.jsx | 2 +- src/index.scss | 15 ++++++ 6 files changed, 93 insertions(+), 50 deletions(-) create mode 100644 src/components/icons/Issue.jsx diff --git a/src/components/icons/Issue.jsx b/src/components/icons/Issue.jsx new file mode 100644 index 00000000..94cb1a8e --- /dev/null +++ b/src/components/icons/Issue.jsx @@ -0,0 +1,26 @@ +import React from 'react'; + +export default function Issue() { + return ( + + ); +} diff --git a/src/components/icons/Question.jsx b/src/components/icons/Question.jsx index ff050534..c35a96f6 100644 --- a/src/components/icons/Question.jsx +++ b/src/components/icons/Question.jsx @@ -4,32 +4,23 @@ export default function Question() { return ( ); } diff --git a/src/components/icons/index.js b/src/components/icons/index.js index 26c2279d..dbe72c0f 100644 --- a/src/components/icons/index.js +++ b/src/components/icons/index.js @@ -1,3 +1,4 @@ +export { default as Issue } from './Issue'; export { default as People } from './People'; export { default as PushPin } from './PushPin'; export { default as Question } from './Question'; diff --git a/src/discussions/posts/post/PostHeader.jsx b/src/discussions/posts/post/PostHeader.jsx index 6b6b0366..b5378cb3 100644 --- a/src/discussions/posts/post/PostHeader.jsx +++ b/src/discussions/posts/post/PostHeader.jsx @@ -1,57 +1,65 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import PropTypes from 'prop-types'; +import classNames from 'classnames'; import { useSelector } from 'react-redux'; import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import { Avatar, Badge, Icon } from '@edx/paragon'; -import { Question } from '../../../components/icons'; +import { Issue, Question } from '../../../components/icons'; import { AvatarOutlineAndLabelColors, 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, authorLabel, fromPostLink }) { +export function PostAvatar({ + post, authorLabel, fromPostLink, read, +}) { const authorAvatars = useSelector(selectAuthorAvatars(post.author)); const outlineColor = AvatarOutlineAndLabelColors[authorLabel]; - const avatarSize = () => { - let size = '2rem'; - if (post.type !== ThreadType.QUESTION && !fromPostLink) { + const avatarSize = useMemo(() => { + let size = '1.75rem'; + if (post.type === ThreadType.DISCUSSION && !fromPostLink) { size = '2.375rem'; } else if (post.type === ThreadType.QUESTION) { - size = '1.5rem'; + size = '1.375rem'; } 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 ( -