Skip to content

Commit 37d5907

Browse files
committed
refactor: notification row layout
Signed-off-by: Adam Setch <[email protected]>
1 parent 43fab04 commit 37d5907

File tree

8 files changed

+2421
-2226
lines changed

8 files changed

+2421
-2226
lines changed

src/renderer/components/notifications/NotificationFooter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const NotificationFooter: FC<INotificationFooter> = ({
2929
>
3030
{notification.subject.user ? (
3131
<Box
32-
title={`View profile: ${notification.subject.user.login}`}
32+
title={notification.subject.user.login}
3333
onClick={(event: MouseEvent<HTMLElement>) => {
3434
// Don't trigger onClick of parent element.
3535
event.stopPropagation();

src/renderer/components/notifications/NotificationRow.tsx

Lines changed: 76 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from 'react';
88

99
import { BellSlashIcon, CheckIcon, ReadIcon } from '@primer/octicons-react';
10-
import { IconButton, Tooltip } from '@primer/react';
10+
import { Box, IconButton, Stack, Text, Tooltip } from '@primer/react';
1111

1212
import { AppContext } from '../../context/App';
1313
import { GroupBy, Opacity, Size } from '../../types';
@@ -87,87 +87,102 @@ export const NotificationRow: FC<INotificationRow> = ({
8787
const groupByDate = settings.groupBy === GroupBy.DATE;
8888

8989
return (
90-
<div
90+
<Box
9191
id={notification.id}
9292
className={cn(
93-
'group flex border-b pl-3 pr-1 py-1.5 text-gitify-font border-gitify-notification-border hover:bg-gitify-notification-hover',
93+
'group border-b',
94+
'pl-3 pr-1 py-1.5',
95+
'text-gitify-font border-gitify-notification-border hover:bg-gitify-notification-hover',
9496
(isAnimated || animateExit) &&
9597
'translate-x-full opacity-0 transition duration-[350ms] ease-in-out',
9698
(isRead || showAsRead) && Opacity.READ,
9799
)}
98100
>
99-
<div className="mr-3 flex items-center justify-center">
101+
<Stack
102+
direction="horizontal"
103+
align="center"
104+
gap="condensed"
105+
className="relative"
106+
>
100107
<Tooltip text={notificationType} direction="e">
101108
<NotificationIcon size={Size.LARGE} className={iconColor} />
102109
</Tooltip>
103-
</div>
104-
105-
<div
106-
className="flex-1 truncate cursor-pointer"
107-
onClick={() => handleNotification()}
108-
>
109-
<NotificationHeader notification={notification} />
110110

111-
<div
112-
className="flex gap-1 items-center mb-1 truncate text-sm"
113-
title={notificationTitle}
114-
data-testid="notification-row"
111+
<Stack
112+
direction="vertical"
113+
gap="none"
114+
className="cursor-pointer truncate w-full mr-1"
115+
onClick={() => handleNotification()}
115116
>
116-
<span className="truncate">{notification.subject.title}</span>
117-
<span
118-
className={cn(
119-
'text-xxs',
120-
Opacity.READ,
121-
(groupByDate || !settings.showNumber) && 'hidden',
122-
)}
117+
<NotificationHeader notification={notification} />
118+
119+
<Stack
120+
direction="horizontal"
121+
align="start"
122+
justify="space-between"
123+
gap="condensed"
124+
title={notificationTitle}
125+
className="text-sm mb-1 truncate"
126+
data-testid="notification-row"
123127
>
124-
{notificationNumber}
125-
</span>
126-
</div>
127-
128-
<NotificationFooter notification={notification} />
129-
</div>
128+
<Text className="block truncate flex-shrink overflow-ellipsis">
129+
{notification.subject.title}
130+
</Text>
131+
<Text
132+
className={cn(
133+
'text-xxs ml-auto',
134+
Opacity.READ,
135+
(groupByDate || !settings.showNumber) && 'hidden',
136+
)}
137+
>
138+
{notificationNumber}
139+
</Text>
140+
</Stack>
141+
142+
<NotificationFooter notification={notification} />
143+
</Stack>
144+
145+
{!animateExit && (
146+
<HoverGroup>
147+
{isMarkAsDoneFeatureSupported(notification.account) && (
148+
<IconButton
149+
aria-label="Mark as done"
150+
icon={CheckIcon}
151+
size="small"
152+
variant="invisible"
153+
onClick={() => {
154+
setAnimateExit(!settings.delayNotificationState);
155+
setShowAsRead(settings.delayNotificationState);
156+
markNotificationsAsDone([notification]);
157+
}}
158+
data-testid="notification-mark-as-done"
159+
/>
160+
)}
130161

131-
{!animateExit && (
132-
<HoverGroup>
133-
{isMarkAsDoneFeatureSupported(notification.account) && (
134162
<IconButton
135-
aria-label="Mark as done"
136-
icon={CheckIcon}
163+
aria-label="Mark as read"
164+
icon={ReadIcon}
137165
size="small"
138166
variant="invisible"
139167
onClick={() => {
140168
setAnimateExit(!settings.delayNotificationState);
141169
setShowAsRead(settings.delayNotificationState);
142-
markNotificationsAsDone([notification]);
170+
markNotificationsAsRead([notification]);
143171
}}
144-
data-testid="notification-mark-as-done"
172+
data-testid="notification-mark-as-read"
145173
/>
146-
)}
147-
148-
<IconButton
149-
aria-label="Mark as read"
150-
icon={ReadIcon}
151-
size="small"
152-
variant="invisible"
153-
onClick={() => {
154-
setAnimateExit(!settings.delayNotificationState);
155-
setShowAsRead(settings.delayNotificationState);
156-
markNotificationsAsRead([notification]);
157-
}}
158-
data-testid="notification-mark-as-read"
159-
/>
160-
161-
<IconButton
162-
aria-label="Unsubscribe from thread"
163-
icon={BellSlashIcon}
164-
size="small"
165-
variant="invisible"
166-
onClick={unsubscribeFromThread}
167-
data-testid="notification-unsubscribe-from-thread"
168-
/>
169-
</HoverGroup>
170-
)}
171-
</div>
174+
175+
<IconButton
176+
aria-label="Unsubscribe from thread"
177+
icon={BellSlashIcon}
178+
size="small"
179+
variant="invisible"
180+
onClick={unsubscribeFromThread}
181+
data-testid="notification-unsubscribe-from-thread"
182+
/>
183+
</HoverGroup>
184+
)}
185+
</Stack>
186+
</Box>
172187
);
173188
};

0 commit comments

Comments
 (0)