@@ -8,11 +8,17 @@ import {
88 ReadIcon ,
99 TagIcon ,
1010} 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' ;
1318import { AppContext } from '../context/App' ;
1419import { type Account , IconColor } from '../types' ;
1520import type { Notification } from '../typesGitHub' ;
21+ import { cn } from '../utils/cn' ;
1622import {
1723 formatForDisplay ,
1824 formatNotificationUpdatedAt ,
@@ -41,8 +47,10 @@ export const NotificationRow: FC<IProps> = ({ notification, account }) => {
4147 unsubscribeNotification,
4248 notifications,
4349 } = useContext ( AppContext ) ;
50+ const [ animateExit , setAnimateExit ] = useState ( false ) ;
4451
4552 const handleNotification = useCallback ( ( ) => {
53+ setAnimateExit ( true ) ;
4654 openNotification ( notification ) ;
4755
4856 if ( settings . markAsDoneOnOpen ) {
@@ -89,10 +97,14 @@ export const NotificationRow: FC<IProps> = ({ notification, account }) => {
8997 return (
9098 < div
9199 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+ ) }
93105 >
94106 < 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 ) }
96108 title = { notificationTitle }
97109 >
98110 < NotificationIcon size = { 18 } aria-label = { notification . subject . type } />
@@ -204,7 +216,10 @@ export const NotificationRow: FC<IProps> = ({ notification, account }) => {
204216 type = "button"
205217 className = "focus:outline-none h-full hover:text-green-500"
206218 title = "Mark as Done"
207- onClick = { ( ) => markNotificationDone ( notification ) }
219+ onClick = { ( ) => {
220+ setAnimateExit ( true ) ;
221+ markNotificationDone ( notification ) ;
222+ } }
208223 >
209224 < CheckIcon size = { 16 } aria-label = "Mark as Done" />
210225 </ button >
@@ -222,7 +237,10 @@ export const NotificationRow: FC<IProps> = ({ notification, account }) => {
222237 type = "button"
223238 className = "focus:outline-none h-full hover:text-green-500"
224239 title = "Mark as Read"
225- onClick = { ( ) => markNotificationRead ( notification ) }
240+ onClick = { ( ) => {
241+ setAnimateExit ( true ) ;
242+ markNotificationRead ( notification ) ;
243+ } }
226244 >
227245 < ReadIcon size = { 14 } aria-label = "Mark as Read" />
228246 </ button >
0 commit comments