From 340e1c42de6cec2bc95622b7a57493007453e1ed Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sun, 2 Jun 2024 15:02:57 -0500 Subject: [PATCH 1/2] feat: use pills for notification footer metrics --- src/components/NotificationRow.tsx | 34 +- .../NotificationRow.test.tsx.snap | 980 +++++++++++------- src/utils/constants.ts | 3 + 3 files changed, 613 insertions(+), 404 deletions(-) diff --git a/src/components/NotificationRow.tsx b/src/components/NotificationRow.tsx index b322f0fe2..caaded09c 100644 --- a/src/components/NotificationRow.tsx +++ b/src/components/NotificationRow.tsx @@ -17,6 +17,7 @@ import { AppContext } from '../context/App'; import { IconColor } from '../types'; import type { Notification } from '../typesGitHub'; import { openExternalLink } from '../utils/comms'; +import Constants from '../utils/constants'; import { formatForDisplay, formatNotificationUpdatedAt, @@ -86,7 +87,7 @@ export const NotificationRow: FC = ({ notification, hostname }) => { notification.subject.type, ]); - const commentsLabel = `${notification.subject.comments} ${ + const commentsPillDescription = `${notification.subject.comments} ${ notification.subject.comments > 1 ? 'comments' : 'comment' }`; @@ -156,22 +157,31 @@ export const NotificationRow: FC = ({ notification, hostname }) => { title={icon.description} className="ml-1" > - + ); }) : null} {notification.subject?.comments > 0 && ( - - + + )} diff --git a/src/components/__snapshots__/NotificationRow.test.tsx.snap b/src/components/__snapshots__/NotificationRow.test.tsx.snap index 6b24aaae0..2d1e6d2dc 100644 --- a/src/components/__snapshots__/NotificationRow.test.tsx.snap +++ b/src/components/__snapshots__/NotificationRow.test.tsx.snap @@ -83,61 +83,82 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun class="ml-1" title="octocat approved these changes" > - - - + + + + + 1 + - - - + + + + + 1 + - - - + + + + + 1 + @@ -292,61 +313,82 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun class="ml-1" title="octocat approved these changes" > - - - + + + + + 1 + - - - + + + + + 1 + - - - + + + + + 1 + @@ -558,61 +600,82 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun class="ml-1" title="octocat approved these changes" > - - - + + + + + 1 + - - - + + + + + 1 + - - - + + + + + 2 + @@ -767,61 +830,82 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun class="ml-1" title="octocat approved these changes" > - - - + + + + + 1 + - - - + + + + + 1 + - - - + + + + + 2 + @@ -1033,41 +1117,55 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun class="ml-1" title="octocat approved these changes" > - - - + + + + + 1 + - - - + + + + + 1 + @@ -1222,41 +1320,55 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun class="ml-1" title="octocat approved these changes" > - - - + + + + + 1 + - - - + + + + + 1 + @@ -1462,41 +1574,55 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`] class="ml-1" title="octocat approved these changes" > - - - + + + + + 1 + - - - + + + + + 1 + @@ -1645,41 +1771,55 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`] class="ml-1" title="octocat approved these changes" > - - - + + + + + 1 + - - - + + + + + 1 + @@ -1885,41 +2025,55 @@ exports[`components/NotificationRow.tsx should render itself & its children when class="ml-1" title="octocat approved these changes" > - - - + + + + + 1 + - - - + + + + + 1 + @@ -2068,41 +2222,55 @@ exports[`components/NotificationRow.tsx should render itself & its children when class="ml-1" title="octocat approved these changes" > - - - + + + + + 1 + - - - + + + + + 1 + @@ -2314,41 +2482,55 @@ exports[`components/NotificationRow.tsx should render itself & its children with class="ml-1" title="octocat approved these changes" > - - - + + + + + 1 + - - - + + + + + 1 + @@ -2503,41 +2685,55 @@ exports[`components/NotificationRow.tsx should render itself & its children with class="ml-1" title="octocat approved these changes" > - - - + + + + + 1 + - - - + + + + + 1 + diff --git a/src/utils/constants.ts b/src/utils/constants.ts index c6a92a41d..a7295819e 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -24,6 +24,9 @@ export const Constants = { READ_CLASS_NAME: 'opacity-50 dark:opacity-50', + PILL_CLASS_NAME: + 'rounded-full text-xs px-2 bg-gray-100 hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700', + // GitHub Docs GITHUB_DOCS: { OAUTH_URL: From 903bf8e8ad705277c4e763f7f45e6addae04f265 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sun, 2 Jun 2024 15:06:19 -0500 Subject: [PATCH 2/2] feat: use pills for notification footer metrics --- src/components/NotificationRow.tsx | 8 +- .../NotificationRow.test.tsx.snap | 84 +++++++------------ 2 files changed, 32 insertions(+), 60 deletions(-) diff --git a/src/components/NotificationRow.tsx b/src/components/NotificationRow.tsx index caaded09c..d7b43fe86 100644 --- a/src/components/NotificationRow.tsx +++ b/src/components/NotificationRow.tsx @@ -163,9 +163,9 @@ export const NotificationRow: FC = ({ notification, hostname }) => { > {' '} + /> {review.users.length} @@ -177,9 +177,9 @@ export const NotificationRow: FC = ({ notification, hostname }) => { diff --git a/src/components/__snapshots__/NotificationRow.test.tsx.snap b/src/components/__snapshots__/NotificationRow.test.tsx.snap index 2d1e6d2dc..58f5668d1 100644 --- a/src/components/__snapshots__/NotificationRow.test.tsx.snap +++ b/src/components/__snapshots__/NotificationRow.test.tsx.snap @@ -89,7 +89,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 1 @@ -116,7 +115,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 1 @@ -143,7 +141,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 1 @@ -319,7 +316,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 1 @@ -346,7 +342,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 1 @@ -373,7 +368,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 1 @@ -606,7 +600,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 1 @@ -633,7 +626,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 1 @@ -660,7 +652,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 2 @@ -836,7 +827,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 1 @@ -863,7 +853,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 1 @@ -890,7 +879,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 2 @@ -1123,7 +1111,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 1 @@ -1150,7 +1137,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 1 @@ -1326,7 +1312,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 1 @@ -1353,7 +1338,7 @@ exports[`components/NotificationRow.tsx rendering for notification comments coun > - 1 @@ -1580,7 +1564,7 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`] > - 1 @@ -1607,7 +1590,7 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`] > - 1 @@ -1777,7 +1759,7 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`] > - 1 @@ -1804,7 +1785,7 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`] > - 1 @@ -2031,7 +2011,7 @@ exports[`components/NotificationRow.tsx should render itself & its children when > - 1 @@ -2058,7 +2037,7 @@ exports[`components/NotificationRow.tsx should render itself & its children when > - 1 @@ -2228,7 +2206,7 @@ exports[`components/NotificationRow.tsx should render itself & its children when > - 1 @@ -2255,7 +2232,7 @@ exports[`components/NotificationRow.tsx should render itself & its children when > - 1 @@ -2488,7 +2464,7 @@ exports[`components/NotificationRow.tsx should render itself & its children with > - 1 @@ -2515,7 +2490,7 @@ exports[`components/NotificationRow.tsx should render itself & its children with > - 1 @@ -2691,7 +2665,7 @@ exports[`components/NotificationRow.tsx should render itself & its children with > - 1 @@ -2718,7 +2691,7 @@ exports[`components/NotificationRow.tsx should render itself & its children with > - 1