@@ -8,11 +8,17 @@ import {
8
8
ReadIcon ,
9
9
TagIcon ,
10
10
} from '@primer/octicons-react' ;
11
- import { type FC , type MouseEvent , useCallback , useContext } from 'react' ;
12
-
11
+ import {
12
+ type FC ,
13
+ type MouseEvent ,
14
+ useCallback ,
15
+ useContext ,
16
+ useState ,
17
+ } from 'react' ;
13
18
import { AppContext } from '../context/App' ;
14
19
import { type Account , IconColor } from '../types' ;
15
20
import type { Notification } from '../typesGitHub' ;
21
+ import { cn } from '../utils/cn' ;
16
22
import {
17
23
formatForDisplay ,
18
24
formatNotificationUpdatedAt ,
@@ -41,8 +47,10 @@ export const NotificationRow: FC<IProps> = ({ notification, account }) => {
41
47
unsubscribeNotification,
42
48
notifications,
43
49
} = useContext ( AppContext ) ;
50
+ const [ animateExit , setAnimateExit ] = useState ( false ) ;
44
51
45
52
const handleNotification = useCallback ( ( ) => {
53
+ setAnimateExit ( true ) ;
46
54
openNotification ( notification ) ;
47
55
48
56
if ( settings . markAsDoneOnOpen ) {
@@ -89,10 +97,14 @@ export const NotificationRow: FC<IProps> = ({ notification, account }) => {
89
97
return (
90
98
< div
91
99
id = { notification . id }
92
- className = "flex py-2 px-3 bg-white dark:bg-gray-dark dark:text-white hover:bg-gray-100 dark:hover:bg-gray-darker border-b border-gray-100 dark:border-gray-darker group"
100
+ className = { cn (
101
+ 'group flex border-b border-gray-100 bg-white px-3 py-2 hover:bg-gray-100 dark:border-gray-darker dark:bg-gray-dark dark:text-white dark:hover:bg-gray-darker' ,
102
+ animateExit &&
103
+ 'translate-x-full opacity-0 transition duration-[350ms] ease-in-out' ,
104
+ ) }
93
105
>
94
106
< div
95
- className = { ` flex justify-center items-center mr-3 w-5 ${ iconColor } ` }
107
+ className = { cn ( ' flex justify-center items-center mr-3 w-5' , iconColor ) }
96
108
title = { notificationTitle }
97
109
>
98
110
< NotificationIcon size = { 18 } aria-label = { notification . subject . type } />
@@ -204,7 +216,10 @@ export const NotificationRow: FC<IProps> = ({ notification, account }) => {
204
216
type = "button"
205
217
className = "focus:outline-none h-full hover:text-green-500"
206
218
title = "Mark as Done"
207
- onClick = { ( ) => markNotificationDone ( notification ) }
219
+ onClick = { ( ) => {
220
+ setAnimateExit ( true ) ;
221
+ markNotificationDone ( notification ) ;
222
+ } }
208
223
>
209
224
< CheckIcon size = { 16 } aria-label = "Mark as Done" />
210
225
</ button >
@@ -222,7 +237,10 @@ export const NotificationRow: FC<IProps> = ({ notification, account }) => {
222
237
type = "button"
223
238
className = "focus:outline-none h-full hover:text-green-500"
224
239
title = "Mark as Read"
225
- onClick = { ( ) => markNotificationRead ( notification ) }
240
+ onClick = { ( ) => {
241
+ setAnimateExit ( true ) ;
242
+ markNotificationRead ( notification ) ;
243
+ } }
226
244
>
227
245
< ReadIcon size = { 14 } aria-label = "Mark as Read" />
228
246
</ button >
0 commit comments