Skip to content

Commit ac7a3b2

Browse files
authored
feat: adopt RelativeTime primer component (#1750)
* feat: migrate to RelativeTime component Signed-off-by: Adam Setch <[email protected]> * feat: migrate to RelativeTime component Signed-off-by: Adam Setch <[email protected]> --------- Signed-off-by: Adam Setch <[email protected]>
1 parent 5000c7a commit ac7a3b2

File tree

6 files changed

+711
-269
lines changed

6 files changed

+711
-269
lines changed
Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import type { FC, MouseEvent } from 'react';
22

33
import { FeedPersonIcon, MarkGithubIcon } from '@primer/octicons-react';
4-
import { Avatar } from '@primer/react';
4+
import { Avatar, RelativeTime, Stack, Text } from '@primer/react';
55

66
import { IconColor, Opacity, Size } from '../../types';
77
import type { Notification } from '../../typesGitHub';
88
import { cn } from '../../utils/cn';
9-
import {
10-
formatNotificationUpdatedAt,
11-
isNonHumanUser,
12-
} from '../../utils/helpers';
9+
import { isNonHumanUser } from '../../utils/helpers';
1310
import { openUserProfile } from '../../utils/links';
1411
import { formatReason } from '../../utils/reason';
1512
import { Pills } from './Pills';
@@ -23,13 +20,8 @@ export const NotificationFooter: FC<INotificationFooter> = ({
2320
}: INotificationFooter) => {
2421
const reason = formatReason(notification.reason);
2522

26-
const updatedAt = formatNotificationUpdatedAt(notification);
27-
const updatedLabel = notification.subject.user
28-
? `${notification.subject.user.login} updated ${updatedAt}`
29-
: `Updated ${updatedAt}`;
30-
3123
return (
32-
<div className="flex flex-wrap items-center gap-1">
24+
<Stack direction="horizontal" align="center" gap="condensed" wrap="wrap">
3325
{notification.subject.user ? (
3426
<Avatar
3527
title={`View profile: ${notification.subject.user.login}`}
@@ -53,19 +45,15 @@ export const NotificationFooter: FC<INotificationFooter> = ({
5345
)}
5446
</>
5547
)}
56-
<span
57-
className={cn('text-xs capitalize', Opacity.MEDIUM)}
58-
title={reason.description}
59-
>
60-
{reason.title}
61-
</span>
62-
<span
63-
className={cn('text-xs capitalize', Opacity.MEDIUM)}
64-
title={updatedLabel}
65-
>
66-
{updatedAt}
48+
<span className={cn('text-xs', Opacity.MEDIUM)}>
49+
<Stack direction="horizontal" gap="condensed">
50+
<Text title={reason.description}>{reason.title}</Text>
51+
<Text>&bull;</Text>
52+
<RelativeTime datetime={notification.updated_at} />
53+
</Stack>
6754
</span>
55+
6856
<Pills notification={notification} />
69-
</div>
57+
</Stack>
7058
);
7159
};

src/renderer/components/notifications/__snapshots__/AccountNotifications.test.tsx.snap

Lines changed: 140 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)