From 97f60d94f6edaede34d4714dc0b1fadcbcddc166 Mon Sep 17 00:00:00 2001 From: "adeel.tajamul" Date: Wed, 18 May 2022 19:26:02 +0500 Subject: [PATCH] fix: updated post summary --- src/components/icons/Help.js | 16 ++++++++ src/components/icons/index.js | 1 + src/data/constants.js | 2 +- src/discussions/common/AuthorLabel.jsx | 4 +- src/discussions/common/time-locale.js | 19 +++++++++ src/discussions/posts/post/LikeButton.jsx | 4 +- src/discussions/posts/post/PostFooter.jsx | 22 +++++++--- .../posts/post/PostFooter.test.jsx | 8 ++-- src/discussions/posts/post/PostHeader.jsx | 40 ++++++++++--------- src/discussions/posts/post/PostLink.jsx | 12 +++--- src/discussions/posts/post/messages.js | 2 +- src/index.scss | 16 ++++++++ 12 files changed, 105 insertions(+), 41 deletions(-) create mode 100644 src/components/icons/Help.js create mode 100644 src/discussions/common/time-locale.js diff --git a/src/components/icons/Help.js b/src/components/icons/Help.js new file mode 100644 index 00000000..72fcd68b --- /dev/null +++ b/src/components/icons/Help.js @@ -0,0 +1,16 @@ +import * as React from 'react'; + +import { _extends } from './common'; + +export default function Help(props) { + return /* #__PURE__ */React.createElement('svg', _extends({ + width: 24, + height: 24, + viewBox: '0 0 24 24', + fill: 'none', + xmlns: 'http://www.w3.org/2000/svg', + }, props), /* #__PURE__ */React.createElement('path', { + d: 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z', + fill: '#2D494E', + })); +} diff --git a/src/components/icons/index.js b/src/components/icons/index.js index f2e74acb..6948c86c 100644 --- a/src/components/icons/index.js +++ b/src/components/icons/index.js @@ -1,3 +1,4 @@ +export { default as Help } from './Help'; export { default as QuestionAnswer } from './QuestionAnswer'; export { default as QuestionAnswerOutline } from './QuestionAnswerOutline'; export { default as StarFilled } from './StarFilled'; diff --git a/src/data/constants.js b/src/data/constants.js index e3646279..3869b2b6 100644 --- a/src/data/constants.js +++ b/src/data/constants.js @@ -74,7 +74,7 @@ export const RequestStatus = { * @enum {string} */ export const AvatarBorderAndLabelColors = { - Staff: 'warning-700', + Staff: 'staff-color', 'Community TA': 'success-700', }; diff --git a/src/discussions/common/AuthorLabel.jsx b/src/discussions/common/AuthorLabel.jsx index 7f08bfa0..157a86bd 100644 --- a/src/discussions/common/AuthorLabel.jsx +++ b/src/discussions/common/AuthorLabel.jsx @@ -28,7 +28,7 @@ function AuthorLabel({ } const labelContents = ( <> - {author} + {author} {icon && ( )} {authorLabelMessage && ( - + {authorLabelMessage} )} diff --git a/src/discussions/common/time-locale.js b/src/discussions/common/time-locale.js new file mode 100644 index 00000000..4e955aaa --- /dev/null +++ b/src/discussions/common/time-locale.js @@ -0,0 +1,19 @@ +// eslint-disable-next-line no-unused-vars +export default function timeLocale(number, index, totalSec) { + return [ + ['just now', 'right now'], + ['%ss', 'in %s seconds'], + ['1m', 'in 1 minute'], + ['%sm', 'in %s minutes'], + ['1h', 'in 1 hour'], + ['%sh', 'in %s hours'], + ['1d', 'in 1 day'], + ['%sd', 'in %s days'], + ['1w', 'in 1 week'], + ['%sw', 'in %s weeks'], + ['1M', 'in 1 month'], + ['%sM', 'in %s months'], + ['1y', 'in 1 year'], + ['%sy', 'in %s years'], + ][index]; +} diff --git a/src/discussions/posts/post/LikeButton.jsx b/src/discussions/posts/post/LikeButton.jsx index 9cb0066d..14d54582 100644 --- a/src/discussions/posts/post/LikeButton.jsx +++ b/src/discussions/posts/post/LikeButton.jsx @@ -24,7 +24,7 @@ function LikeButton({ }; return ( -
+
@@ -34,7 +34,7 @@ function LikeButton({ > {preview && post.commentCount > 1 && ( <> - - + + {post.commentCount} @@ -82,19 +83,28 @@ function PostFooter({ - · + + · + ) : null } - {timeago.format(post.createdAt, intl.locale)} + {timeago.format(post.createdAt, 'time-locale')} {!preview && post.closed && ( diff --git a/src/discussions/posts/post/PostFooter.test.jsx b/src/discussions/posts/post/PostFooter.test.jsx index 646b2f9d..27af98bd 100644 --- a/src/discussions/posts/post/PostFooter.test.jsx +++ b/src/discussions/posts/post/PostFooter.test.jsx @@ -62,19 +62,19 @@ describe('PostFooter', () => { it("shows 'x new' badge for new comments", () => { renderComponent(mockPost); - expect(screen.getByText('2 new')).toBeTruthy(); + expect(screen.getByText('2 New')).toBeTruthy(); }); it("doesn't have 'new' badge when there are 0 new comments", () => { renderComponent({ ...mockPost, unreadCommentCount: 0 }); - expect(screen.queryByText('2 new')).toBeFalsy(); - expect(screen.queryByText('0 new')).toBeFalsy(); + expect(screen.queryByText('2 New')).toBeFalsy(); + expect(screen.queryByText('0 New')).toBeFalsy(); }); it("doesn't has 'new' badge when the new-unread item is the post itself", () => { // commentCount === 1 means it's just the post without any further comments renderComponent({ ...mockPost, unreadCommentCount: 1, commentCount: 1 }); - expect(screen.queryByText('1 new')).toBeFalsy(); + expect(screen.queryByText('1 New')).toBeFalsy(); }); it('has the cohort icon only when group information is present', () => { diff --git a/src/discussions/posts/post/PostHeader.jsx b/src/discussions/posts/post/PostHeader.jsx index 0d466e51..089089e1 100644 --- a/src/discussions/posts/post/PostHeader.jsx +++ b/src/discussions/posts/post/PostHeader.jsx @@ -5,8 +5,8 @@ import { useSelector } from 'react-redux'; import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import { Avatar, Badge, Icon } from '@edx/paragon'; -import { Help } from '@edx/paragon/icons'; +import { Help } from '../../../components/icons'; import { AvatarBorderAndLabelColors, ThreadType } from '../../../data/constants'; import { ActionsDropdown, AuthorLabel } from '../../common'; import { selectAuthorAvatars } from '../data/selectors'; @@ -17,24 +17,26 @@ export function PostAvatar({ post, authorLabel, fromPostLink }) { const authorAvatars = useSelector(selectAuthorAvatars(post.author)); const borderColor = AvatarBorderAndLabelColors[authorLabel]; return ( -
- {post.type === ThreadType.QUESTION && ( - - )} - +
+
+ {post.type === ThreadType.QUESTION && ( + + )} + +
); } diff --git a/src/discussions/posts/post/PostLink.jsx b/src/discussions/posts/post/PostLink.jsx index 1ed1cd43..58b91f5a 100644 --- a/src/discussions/posts/post/PostLink.jsx +++ b/src/discussions/posts/post/PostLink.jsx @@ -40,7 +40,7 @@ function PostLink({ {post.pinned && (
@@ -48,7 +48,7 @@ function PostLink({
)}
-
-
+
+
{post.title}
{showAnsweredBadge && ( -
+
{intl.formatMessage(messages.answered)}
)} @@ -82,7 +82,7 @@ function PostLink({ />
-
+
diff --git a/src/discussions/posts/post/messages.js b/src/discussions/posts/post/messages.js index e3a4edf5..adfdbb12 100644 --- a/src/discussions/posts/post/messages.js +++ b/src/discussions/posts/post/messages.js @@ -98,7 +98,7 @@ const messages = defineMessages({ }, newLabel: { id: 'discussions.post.label.new', - defaultMessage: '{count} new', + defaultMessage: '{count} New', description: 'Label shown on the badge indicating new comments/posts like "3 new"', }, editedBy: { diff --git a/src/index.scss b/src/index.scss index 973532fb..a6746e91 100755 --- a/src/index.scss +++ b/src/index.scss @@ -13,3 +13,19 @@ $fa-font-path: "~font-awesome/fonts"; max-width: 100%; } } + +.text-staff-color { + color: #998200; +} + +.border-staff-color { + border-color: #998200; +} + +.font-size-14 { + font-size: 14px; +} + +.font-weight-500 { + font-weight: 500; +} \ No newline at end of file