-
Notifications
You must be signed in to change notification settings - Fork 269
/
Copy pathNotificationHeader.tsx
54 lines (49 loc) · 1.55 KB
/
NotificationHeader.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { MarkGithubIcon } from '@primer/octicons-react';
import { type FC, type MouseEvent, useContext } from 'react';
import { AppContext } from '../../context/App';
import { type Link, Opacity, Size } from '../../types';
import type { Notification } from '../../typesGitHub';
import { cn } from '../../utils/cn';
import { openExternalLink } from '../../utils/comms';
import { AvatarIcon } from '../icons/AvatarIcon';
interface INotificationHeader {
notification: Notification;
}
export const NotificationHeader: FC<INotificationHeader> = ({
notification,
}: INotificationHeader) => {
const { settings } = useContext(AppContext);
const repoAvatarUrl = notification.repository.owner.avatar_url;
const repoSlug = notification.repository.full_name;
const groupByDate = settings.groupBy === 'DATE';
return (
groupByDate && (
<div
className={cn(
'mb-1 flex items-center gap-1 text-xs font-medium',
Opacity.MEDIUM,
)}
>
<span>
<AvatarIcon
title={repoSlug}
url={repoAvatarUrl}
size={Size.XSMALL}
defaultIcon={MarkGithubIcon}
/>
</span>
<span
title={repoSlug}
className="cursor-pointer truncate opacity-90"
onClick={(event: MouseEvent<HTMLElement>) => {
// Don't trigger onClick of parent element.
event.stopPropagation();
openExternalLink(notification.repository.html_url as Link);
}}
>
{repoSlug}
</span>
</div>
)
);
};