|
7 | 7 | } from 'react'; |
8 | 8 |
|
9 | 9 | 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'; |
11 | 11 |
|
12 | 12 | import { AppContext } from '../../context/App'; |
13 | 13 | import { GroupBy, Opacity, Size } from '../../types'; |
@@ -87,87 +87,102 @@ export const NotificationRow: FC<INotificationRow> = ({ |
87 | 87 | const groupByDate = settings.groupBy === GroupBy.DATE; |
88 | 88 |
|
89 | 89 | return ( |
90 | | - <div |
| 90 | + <Box |
91 | 91 | id={notification.id} |
92 | 92 | 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', |
94 | 96 | (isAnimated || animateExit) && |
95 | 97 | 'translate-x-full opacity-0 transition duration-[350ms] ease-in-out', |
96 | 98 | (isRead || showAsRead) && Opacity.READ, |
97 | 99 | )} |
98 | 100 | > |
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 | + > |
100 | 107 | <Tooltip text={notificationType} direction="e"> |
101 | 108 | <NotificationIcon size={Size.LARGE} className={iconColor} /> |
102 | 109 | </Tooltip> |
103 | | - </div> |
104 | | - |
105 | | - <div |
106 | | - className="flex-1 truncate cursor-pointer" |
107 | | - onClick={() => handleNotification()} |
108 | | - > |
109 | | - <NotificationHeader notification={notification} /> |
110 | 110 |
|
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()} |
115 | 116 | > |
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" |
123 | 127 | > |
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 | + )} |
130 | 161 |
|
131 | | - {!animateExit && ( |
132 | | - <HoverGroup> |
133 | | - {isMarkAsDoneFeatureSupported(notification.account) && ( |
134 | 162 | <IconButton |
135 | | - aria-label="Mark as done" |
136 | | - icon={CheckIcon} |
| 163 | + aria-label="Mark as read" |
| 164 | + icon={ReadIcon} |
137 | 165 | size="small" |
138 | 166 | variant="invisible" |
139 | 167 | onClick={() => { |
140 | 168 | setAnimateExit(!settings.delayNotificationState); |
141 | 169 | setShowAsRead(settings.delayNotificationState); |
142 | | - markNotificationsAsDone([notification]); |
| 170 | + markNotificationsAsRead([notification]); |
143 | 171 | }} |
144 | | - data-testid="notification-mark-as-done" |
| 172 | + data-testid="notification-mark-as-read" |
145 | 173 | /> |
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> |
172 | 187 | ); |
173 | 188 | }; |
0 commit comments