some html optimizations

This commit is contained in:
MathieuG-P
2022-10-20 00:52:56 +02:00
parent fbf2fff618
commit fdf8351adf
14 changed files with 85 additions and 81 deletions
@@ -12,25 +12,25 @@ export function NotificationItem({resolver, notification}: {resolver?: (value: N
const t = useTranslation();
const renderImage = () => {
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 = () => {
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";
}
})()
return (
<motion.div layout initial={{x: "110%"}} animate={{x: "0%"}} exit={{x:"110%"}} className="relative w-[270px] rounded-md overflow-hidden -left-[285px] mb-4 shadow-md shadow-black bg-gradient-to-br from-light-main-color-2 to-light-main-color-2 dark:from-main-color-2 dark:to-main-color-2 text-gray-800 dark:text-white">
<motion.li layout initial={{x: "110%"}} animate={{x: "0%"}} exit={{x:"110%"}} className="relative w-[270px] rounded-md overflow-hidden -left-[285px] mb-4 shadow-md shadow-black bg-gradient-to-br from-light-main-color-2 to-light-main-color-2 dark:from-main-color-2 dark:to-main-color-2 text-gray-800 dark:text-white">
<div className="w-full flex flex-col">
<div className="flex items-center justify-start pl-1">
<BsmImage className="h-14 mr-1" image={renderImage()}/>
<BsmImage className="h-14 mr-1" image={renderImage}/>
<div className="flex flex-col py-2">
<h1 className="font-bold leading-4 tracking-wide pr-5 my-1">{t(notification.title)}</h1>
{notification.desc && <p className="text-xs pr-1">{t(notification.desc)}</p>}
@@ -42,8 +42,8 @@ export function NotificationItem({resolver, notification}: {resolver?: (value: N
</div>
)}
</div>
<span className={`absolute w-full h-1 shadow-center left-0 top-0 ${renderNeonColors()}`}/>
<span className={`absolute w-full h-1 shadow-center left-0 top-0 ${renderNeonColors}`}/>
<BsmButton icon="cross" className="absolute top-2 right-2" withBar={false} onClick={() => resolver(NotificationResult.CLOSE)}/>
</motion.div>
</motion.li>
)
}
@@ -1,7 +1,7 @@
import { useObservable } from "renderer/hooks/use-observable.hook"
import { NotificationService } from "renderer/services/notification.service"
import { NotificationItem } from "./notification-item.component";
import { AnimatePresence, motion } from "framer-motion";
import { AnimatePresence } from "framer-motion";
export function NotificationOverlay() {
@@ -11,10 +11,10 @@ export function NotificationOverlay() {
return (
<motion.ul className="absolute h-full w-0 top-0 right-0 z-40 bg-red-500 pt-10">
<ul className="absolute h-full w-0 top-0 right-0 z-40 pt-10">
<AnimatePresence>
{notifications?.map(n => <NotificationItem key={n.id} resolver={n.resolver} notification={n.notification}/>)}
</AnimatePresence>
</motion.ul>
</ul>
)
}