mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-30 06:11:03 +00:00
refactor: update notification item components to use button elements for better accessibility
This commit is contained in:
@@ -25,7 +25,7 @@ export function LocalNotificationItem({
|
|||||||
notification,
|
notification,
|
||||||
onDismiss,
|
onDismiss,
|
||||||
onMarkAsRead,
|
onMarkAsRead,
|
||||||
}: LocalNotificationItemProps) {
|
}: Readonly<LocalNotificationItemProps>) {
|
||||||
const { t } = useTranslation("notifications_page");
|
const { t } = useTranslation("notifications_page");
|
||||||
const { formatDistance } = useDate();
|
const { formatDistance } = useDate();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -64,18 +64,12 @@ export function LocalNotificationItem({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<button
|
||||||
|
type="button"
|
||||||
className={cn("notification-item", {
|
className={cn("notification-item", {
|
||||||
"notification-item--unread": !notification.isRead,
|
"notification-item--unread": !notification.isRead,
|
||||||
})}
|
})}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
onKeyDown={(e) => {
|
|
||||||
if (e.key === "Enter" || e.key === " ") {
|
|
||||||
handleClick();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
role="button"
|
|
||||||
tabIndex={0}
|
|
||||||
>
|
>
|
||||||
<div className="notification-item__picture">
|
<div className="notification-item__picture">
|
||||||
{notification.pictureUrl ? (
|
{notification.pictureUrl ? (
|
||||||
@@ -104,6 +98,6 @@ export function LocalNotificationItem({
|
|||||||
>
|
>
|
||||||
<XIcon size={16} />
|
<XIcon size={16} />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,20 +172,14 @@ export function NotificationItem({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<button
|
||||||
|
type="button"
|
||||||
className={cn("notification-item", {
|
className={cn("notification-item", {
|
||||||
"notification-item--unread":
|
"notification-item--unread":
|
||||||
!notification.isRead ||
|
!notification.isRead ||
|
||||||
notification.type === "FRIEND_REQUEST_RECEIVED",
|
notification.type === "FRIEND_REQUEST_RECEIVED",
|
||||||
})}
|
})}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
onKeyDown={(e) => {
|
|
||||||
if (e.key === "Enter" || e.key === " ") {
|
|
||||||
handleClick();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
role="button"
|
|
||||||
tabIndex={0}
|
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={cn("notification-item__picture", {
|
className={cn("notification-item__picture", {
|
||||||
@@ -229,6 +223,6 @@ export function NotificationItem({
|
|||||||
<XIcon size={16} />
|
<XIcon size={16} />
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user