1- import type { CSSProperties } from "react" ;
2- import React , { type FC , useState } from "react" ;
1+ import type { CSSProperties , FC } from "react" ;
2+ import React , { useState } from "react" ;
33
44import CloseIcon from "./CloseIcon" ;
55import { useSirenContext } from "./SirenProvider" ;
@@ -32,17 +32,19 @@ import useSiren from "../utils/sirenHook";
3232 * <Card
3333 * notification={notification}
3434 * cardProps={{ hideAvatar: false }}
35+ * darkMode={false}
3536 * styles={customStyles}
3637 * onCardClick={(notification) => console.log('Notification clicked', notification)}
37- * deleteById ={(id) => console.log('Notification deleted', id)}
38+ * deleteNotificationById ={(id) => console.log('Notification deleted', id)}
3839 * />
3940 *
4041 * @param {NotificationCardProps } props - The properties passed to the Card component.
4142 * @param {Object } props.notification - The notification data to display in the card.
4243 * @param {Object } [props.cardProps] - Optional properties to customize the appearance of the card.
4344 * @param {Object } props.styles - Custom styles applied to the card and its elements.
45+ * @param {boolean } props.darkMode - Flag to determine the dark mode status.
4446 * @param {Function } [props.onCardClick] - Callback function executed when the card is clicked.
45- * @param {Function } [props.deleteById ] - Callback function executed when the delete action is triggered.
47+ * @param {Function } [props.deleteNotificationById ] - Callback function executed when the delete action is triggered.
4648 * @returns {ReactElement } The rendered Card component.
4749 */
4850
@@ -63,6 +65,8 @@ const Card: FC<NotificationCardProps> = ({
6365 const { id } = useSirenContext ( ) ;
6466
6567 const [ deleteAnimationStyle , setDeleteAnimationStyle ] = useState ( '' ) ;
68+ const [ imageLoaded , setImageLoaded ] = useState ( true ) ;
69+ const [ imageSource , setImageSource ] = useState ( thumbnailUrl ?? '' ) ;
6670
6771 const defaultAvatar = darkMode ? defaultAvatarDark : defaultAvatarLight ;
6872 const failedImage = darkMode ? failedImageDark : failedImageLight ;
@@ -113,10 +117,6 @@ const Card: FC<NotificationCardProps> = ({
113117 event . stopPropagation ( ) ;
114118 } ;
115119
116- const [ imageLoaded , setImageLoaded ] = useState ( true ) ; // Initially assume image is loaded
117-
118- const [ imageSource , setImageSource ] = useState ( thumbnailUrl ? thumbnailUrl : '' ) ;
119-
120120 const onErrorMedia = ( ) : void => {
121121 setImageLoaded ( false ) ;
122122 setImageSource ( failedImage ) ;
@@ -133,6 +133,7 @@ const Card: FC<NotificationCardProps> = ({
133133 onClick = { handleNotificationCardClick }
134134 aria-label = { `siren-notification-card-${ notification . id } ` }
135135 data-testid = { `card-${ notification . id } ` }
136+ role = "button"
136137 >
137138 { ! hideAvatar && (
138139 < div
@@ -145,6 +146,7 @@ const Card: FC<NotificationCardProps> = ({
145146 } }
146147 aria-label = { `siren-notification-avatar-${ notification . id } ` }
147148 onClick = { handleAvatarClick }
149+ role = "button"
148150 />
149151 ) }
150152 < div className = "siren-sdk-card-content-wrapper" >
@@ -168,7 +170,9 @@ const Card: FC<NotificationCardProps> = ({
168170 className = "siren-sdk-card-thumbnail-container"
169171 style = { { ...( onMediaThumbnailClick && { cursor : "pointer" } ) ,
170172 backgroundColor : darkMode ? '#4C4C4C' : '#F0F2F5' } }
171- onClick = { handleMediaClick } >
173+ onClick = { handleMediaClick }
174+ role = "button"
175+ >
172176 < img
173177 className = { `siren-sdk-card-thumbnail-image ${ thumbnailUrl && imageLoaded ? 'siren-sdk-card-thumbnail-with-image' : '' } ` }
174178 src = { imageSource }
@@ -192,6 +196,7 @@ const Card: FC<NotificationCardProps> = ({
192196 className = "siren-sdk-delete-button"
193197 onClick = { onDelete }
194198 aria-label = { `siren-notification-delete-${ notification . id } ` }
199+ role = "button"
195200 >
196201 < CloseIcon
197202 color = { styles ?. deleteIcon . color }
0 commit comments