diff --git a/src/renderer/components/notification/notification-item.component.tsx b/src/renderer/components/notification/notification-item.component.tsx index a4ad83c7..a0838bd9 100644 --- a/src/renderer/components/notification/notification-item.component.tsx +++ b/src/renderer/components/notification/notification-item.component.tsx @@ -1,5 +1,5 @@ import { NotificationResult, NotificationType, Notification } from "renderer/services/notification.service" -import { motion } from "framer-motion" +import { motion, PanInfo } from "framer-motion" import { BsmImage } from "../shared/bsm-image.component"; import BeatRunningImg from "../../../../assets/images/apngs/beat-running.png"; import BeatConflictImg from "../../../../assets/images/apngs/beat-conflict.png"; @@ -10,27 +10,37 @@ import { useTranslation } from "renderer/hooks/use-translation.hook"; export function NotificationItem({resolver, notification}: {resolver?: (value: NotificationResult|string) => void, notification: Notification}) { - const t = useTranslation(); + const t = useTranslation(); - const renderImage = (() => { - if(notification.type === NotificationType.SUCCESS){ return BeatRunningImg; } - if(notification.type === NotificationType.WARNING){ return BeatWaitingImg; } - if(notification.type === NotificationType.ERROR){ return BeatConflictImg; } - return BeatImpatientImg; - })() + const renderImage = (() => { + if(notification.type === NotificationType.SUCCESS){ return BeatRunningImg; } + if(notification.type === NotificationType.WARNING){ return BeatWaitingImg; } + if(notification.type === NotificationType.ERROR){ return BeatConflictImg; } + return BeatImpatientImg; + })(); - const renderNeonColors = (() => { - if(notification.type === NotificationType.SUCCESS){ return "bg-green-400 shadow-green-400"; } - if(notification.type === NotificationType.WARNING){ return "bg-yellow-400 shadow-yellow-400"; } - if(notification.type === NotificationType.ERROR){ return "bg-red-500 shadow-red-500"; } - return "bg-gray-800 shadow-gray-800 dark:bg-white dark:shadow-white"; - })() + const renderNeonColors = (() => { + if(notification.type === NotificationType.SUCCESS){ return "bg-green-400 shadow-green-400"; } + if(notification.type === NotificationType.WARNING){ return "bg-yellow-400 shadow-yellow-400"; } + if(notification.type === NotificationType.ERROR){ return "bg-red-500 shadow-red-500"; } + return "bg-gray-800 shadow-gray-800 dark:bg-white dark:shadow-white"; + })(); + + + const handleDragEnd = (e: MouseEvent, info: PanInfo) => { + const offset = info.offset.x; + const velocity = info.velocity.x; + + if(offset > 30 && velocity > 300){ + resolver(NotificationResult.CLOSE); + } + } return ( - +
- +

{t(notification.title)}

{notification.desc &&

{t(notification.desc)}

}