From 5b92f7e96845d5daebe9e09b055b77c34b79e55e Mon Sep 17 00:00:00 2001 From: Vinh Date: Wed, 15 Apr 2020 18:28:07 +0200 Subject: [PATCH] =?UTF-8?q?[CORL-1014]=C2=A0Style=20comments=20based=20on?= =?UTF-8?q?=20number=20of=20reactions=20(#2930)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add ability to style comments based on number of reactions * feat: add coral-indent class * fix: tests * fix: snapshots --- src/core/client/stream/classes.ts | 20 +- .../Comment/CommentContainer.spec.tsx | 5 + .../Comments/Comment/CommentContainer.tsx | 11 +- .../CommentContainer.spec.tsx.snap | 191 +++++++++++++++++- .../__snapshots__/Indent.spec.tsx.snap | 6 +- .../__snapshots__/permalinkView.spec.tsx.snap | 20 +- ...permalinkViewLoadMoreParents.spec.tsx.snap | 16 +- .../__snapshots__/editComment.spec.tsx.snap | 16 +- .../__snapshots__/loadMore.spec.tsx.snap | 8 +- .../__snapshots__/postComment.spec.tsx.snap | 4 +- .../postLocalReply.spec.tsx.snap | 24 +-- .../__snapshots__/postReply.spec.tsx.snap | 8 +- .../renderCommunityGuidelines.spec.tsx.snap | 8 +- .../__snapshots__/renderReplies.spec.tsx.snap | 16 +- .../__snapshots__/renderStream.spec.tsx.snap | 8 +- .../showAllReplies.spec.tsx.snap | 6 +- .../showConversation.spec.tsx.snap | 4 +- .../__snapshots__/sortStream.spec.tsx.snap | 8 +- .../test/comments/stream/reaction.spec.tsx | 3 + 19 files changed, 290 insertions(+), 92 deletions(-) diff --git a/src/core/client/stream/classes.ts b/src/core/client/stream/classes.ts index 09fbe8353..1de1c61c7 100644 --- a/src/core/client/stream/classes.ts +++ b/src/core/client/stream/classes.ts @@ -272,6 +272,12 @@ const CLASSES = { */ $root: "coral coral-comment", + /** + * reacted signifies the number of reactions of the comment. + * The no of reactions is appended: e.g. `coral-reacted-1`. + */ + reacted: "coral coral-reacted", + /** * topBar is the uppper bar of the comment. */ @@ -386,13 +392,13 @@ const CLASSES = { * indentation classes for the different levels. */ indent: [ - "", - "coral coral-indent-1", - "coral coral-indent-2", - "coral coral-indent-3", - "coral coral-indent-4", - "coral coral-indent-5", - "coral coral-indent-6", + "coral coral-indent coral-indent-0", + "coral coral-indent coral-indent-1", + "coral coral-indent coral-indent-2", + "coral coral-indent coral-indent-3", + "coral coral-indent coral-indent-4", + "coral coral-indent coral-indent-5", + "coral coral-indent coral-indent-6", ], }, diff --git a/src/core/client/stream/tabs/Comments/Comment/CommentContainer.spec.tsx b/src/core/client/stream/tabs/Comments/Comment/CommentContainer.spec.tsx index d3cfd2c07..22ac5d659 100644 --- a/src/core/client/stream/tabs/Comments/Comment/CommentContainer.spec.tsx +++ b/src/core/client/stream/tabs/Comments/Comment/CommentContainer.spec.tsx @@ -34,6 +34,11 @@ function createDefaultProps(add: DeepPartial = {}): Props { username: "Marvin", badges: [], }, + actionCounts: { + reaction: { + total: 0, + }, + }, parent: null, body: "Woof", createdAt: "1995-12-17T03:24:00.000Z", diff --git a/src/core/client/stream/tabs/Comments/Comment/CommentContainer.tsx b/src/core/client/stream/tabs/Comments/Comment/CommentContainer.tsx index 0e17c1d46..3b1f518d1 100644 --- a/src/core/client/stream/tabs/Comments/Comment/CommentContainer.tsx +++ b/src/core/client/stream/tabs/Comments/Comment/CommentContainer.tsx @@ -295,7 +295,11 @@ export class CommentContainer extends Component { } return (
@@ -514,6 +518,11 @@ const enhanced = withContext(({ eventEmitter }) => ({ eventEmitter }))( pending lastViewerAction deleted + actionCounts { + reaction { + total + } + } ...ReplyCommentFormContainer_comment ...EditCommentFormContainer_comment ...ReactionButtonContainer_comment diff --git a/src/core/client/stream/tabs/Comments/Comment/__snapshots__/CommentContainer.spec.tsx.snap b/src/core/client/stream/tabs/Comments/Comment/__snapshots__/CommentContainer.spec.tsx.snap index 65e2b4cbe..d34e7479c 100644 --- a/src/core/client/stream/tabs/Comments/Comment/__snapshots__/CommentContainer.spec.tsx.snap +++ b/src/core/client/stream/tabs/Comments/Comment/__snapshots__/CommentContainer.spec.tsx.snap @@ -2,7 +2,7 @@ exports[`hide reply button 1`] = `
@@ -21,6 +21,11 @@ exports[`hide reply button 1`] = ` className="coral coral-reactButton coral-comment-reactButton" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -72,6 +77,11 @@ exports[`hide reply button 1`] = ` className="coral coral-reportButton coral-comment-reportButton" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -116,6 +126,11 @@ exports[`hide reply button 1`] = ` className="coral coral-username coral-comment-username" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -142,6 +157,11 @@ exports[`hide reply button 1`] = ` className="coral coral-userTag coral-comment-userTag" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -183,6 +203,11 @@ exports[`hide reply button 1`] = ` className="coral coral-userBadge coral-comment-userBadge" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -213,7 +238,7 @@ exports[`hide reply button 1`] = ` exports[`renders body only 1`] = `
@@ -232,6 +257,11 @@ exports[`renders body only 1`] = ` className="coral coral-reactButton coral-comment-reactButton" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -290,6 +320,11 @@ exports[`renders body only 1`] = ` className="coral coral-reportButton coral-comment-reportButton" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -334,6 +369,11 @@ exports[`renders body only 1`] = ` className="coral coral-username coral-comment-username" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -360,6 +400,11 @@ exports[`renders body only 1`] = ` className="coral coral-userTag coral-comment-userTag" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -401,6 +446,11 @@ exports[`renders body only 1`] = ` className="coral coral-userBadge coral-comment-userBadge" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -431,7 +481,7 @@ exports[`renders body only 1`] = ` exports[`renders disabled reply when commenting has been disabled 1`] = `
@@ -450,6 +500,11 @@ exports[`renders disabled reply when commenting has been disabled 1`] = ` className="coral coral-reactButton coral-comment-reactButton" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -508,6 +563,11 @@ exports[`renders disabled reply when commenting has been disabled 1`] = ` className="coral coral-reportButton coral-comment-reportButton" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -552,6 +612,11 @@ exports[`renders disabled reply when commenting has been disabled 1`] = ` className="coral coral-username coral-comment-username" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -578,6 +643,11 @@ exports[`renders disabled reply when commenting has been disabled 1`] = ` className="coral coral-userTag coral-comment-userTag" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -619,6 +689,11 @@ exports[`renders disabled reply when commenting has been disabled 1`] = ` className="coral coral-userBadge coral-comment-userBadge" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -649,7 +724,7 @@ exports[`renders disabled reply when commenting has been disabled 1`] = ` exports[`renders disabled reply when story is closed 1`] = `
@@ -668,6 +743,11 @@ exports[`renders disabled reply when story is closed 1`] = ` className="coral coral-reactButton coral-comment-reactButton" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -726,6 +806,11 @@ exports[`renders disabled reply when story is closed 1`] = ` className="coral coral-reportButton coral-comment-reportButton" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -770,6 +855,11 @@ exports[`renders disabled reply when story is closed 1`] = ` className="coral coral-username coral-comment-username" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -796,6 +886,11 @@ exports[`renders disabled reply when story is closed 1`] = ` className="coral coral-userTag coral-comment-userTag" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -837,6 +932,11 @@ exports[`renders disabled reply when story is closed 1`] = ` className="coral coral-userBadge coral-comment-userBadge" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -867,7 +967,7 @@ exports[`renders disabled reply when story is closed 1`] = ` exports[`renders in reply to 1`] = `
@@ -886,6 +986,11 @@ exports[`renders in reply to 1`] = ` className="coral coral-reactButton coral-comment-reactButton" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -948,6 +1053,11 @@ exports[`renders in reply to 1`] = ` className="coral coral-reportButton coral-comment-reportButton" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -996,6 +1106,11 @@ exports[`renders in reply to 1`] = ` className="coral coral-username coral-comment-username" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -1026,6 +1141,11 @@ exports[`renders in reply to 1`] = ` className="coral coral-userTag coral-comment-userTag" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -1071,6 +1191,11 @@ exports[`renders in reply to 1`] = ` className="coral coral-userBadge coral-comment-userBadge" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -1105,7 +1230,7 @@ exports[`renders in reply to 1`] = ` exports[`renders username and body 1`] = `
@@ -1124,6 +1249,11 @@ exports[`renders username and body 1`] = ` className="coral coral-reactButton coral-comment-reactButton" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -1182,6 +1312,11 @@ exports[`renders username and body 1`] = ` className="coral coral-reportButton coral-comment-reportButton" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -1226,6 +1361,11 @@ exports[`renders username and body 1`] = ` className="coral coral-username coral-comment-username" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -1252,6 +1392,11 @@ exports[`renders username and body 1`] = ` className="coral coral-userTag coral-comment-userTag" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -1293,6 +1438,11 @@ exports[`renders username and body 1`] = ` className="coral coral-userBadge coral-comment-userBadge" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -1323,7 +1473,7 @@ exports[`renders username and body 1`] = ` exports[`renders with tombstone when comment has been deleted 1`] = `
@@ -1332,7 +1482,7 @@ exports[`renders with tombstone when comment has been deleted 1`] = ` exports[`shows conversation link 1`] = `
@@ -1351,6 +1501,11 @@ exports[`shows conversation link 1`] = ` className="coral coral-reactButton coral-comment-reactButton" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -1409,6 +1564,11 @@ exports[`shows conversation link 1`] = ` className="coral coral-reportButton coral-comment-reportButton" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -1459,6 +1619,11 @@ exports[`shows conversation link 1`] = ` className="coral coral-username coral-comment-username" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -1485,6 +1650,11 @@ exports[`shows conversation link 1`] = ` className="coral coral-userTag coral-comment-userTag" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", @@ -1526,6 +1696,11 @@ exports[`shows conversation link 1`] = ` className="coral coral-userBadge coral-comment-userBadge" comment={ Object { + "actionCounts": Object { + "reaction": Object { + "total": 0, + }, + }, "author": Object { "badges": Array [], "id": "author-id", diff --git a/src/core/client/stream/tabs/Comments/__snapshots__/Indent.spec.tsx.snap b/src/core/client/stream/tabs/Comments/__snapshots__/Indent.spec.tsx.snap index f5f658bfb..dcba4ab1a 100644 --- a/src/core/client/stream/tabs/Comments/__snapshots__/Indent.spec.tsx.snap +++ b/src/core/client/stream/tabs/Comments/__snapshots__/Indent.spec.tsx.snap @@ -5,7 +5,7 @@ exports[`renders level0 1`] = ` className="Indent-root" >
Hello World @@ -19,7 +19,7 @@ exports[`renders level1 1`] = ` className="Indent-root" >
Hello World @@ -33,7 +33,7 @@ exports[`renders without border 1`] = ` className="Indent-root" >
Hello World diff --git a/src/core/client/stream/test/comments/permalink/__snapshots__/permalinkView.spec.tsx.snap b/src/core/client/stream/test/comments/permalink/__snapshots__/permalinkView.spec.tsx.snap index 10dc7414f..2cca16d5f 100644 --- a/src/core/client/stream/test/comments/permalink/__snapshots__/permalinkView.spec.tsx.snap +++ b/src/core/client/stream/test/comments/permalink/__snapshots__/permalinkView.spec.tsx.snap @@ -105,7 +105,7 @@ exports[`renders permalink view 1`] = `