notifications fully translated

This commit is contained in:
MathieuG-P
2022-07-14 18:37:40 +02:00
parent ded026e9bd
commit 3f9b79bf36
13 changed files with 447 additions and 71 deletions
@@ -8,6 +8,7 @@ import defaultImage from '../../../../assets/images/default-version-img.jpg'
import dateFormat from "dateformat";
import { BsmImage } from "../shared/bsm-image.component";
import { IpcService } from "renderer/services/ipc.service";
import { useTranslation } from "renderer/hooks/use-translation.hook";
export const AvailableVersionItem = memo(function AvailableVersionItem(props: {version: BSVersion}) {
@@ -15,6 +16,7 @@ export const AvailableVersionItem = memo(function AvailableVersionItem(props: {v
const ipcService = IpcService.getInstance();
const [selected, setSelected] = useState(false);
const t = useTranslation();
const formatedDate = (() => { return dateFormat(+props.version.ReleaseDate*1000, "ddd. dS mmm yyyy"); })()
@@ -50,7 +52,7 @@ export const AvailableVersionItem = memo(function AvailableVersionItem(props: {v
{ props.version.ReleaseURL && (
<a onClickCapture={e => { e.stopPropagation(); openReleasePage(); }} className="relative flex flex-row justify-between items-center rounded-full bg-black bg-opacity-30 text-white pb-[1px] hover:bg-opacity-50">
<SteamIcon className="w-[25px] h-[25px] transition-transform group-hover:rotate-[-360deg] duration-300"/>
<span className="relative -left-[2px] text-sm w-0 text-center overflow-hidden h-full whitespace-nowrap pb-[3px] transition-all group-hover:w-24 duration-300">Release Page</span>
<span className="relative -left-[2px] text-sm w-fit max-w-0 text-center overflow-hidden h-full whitespace-nowrap pb-[3px] transition-all group-hover:max-w-[200px] group-hover:px-1 duration-300">{t("pages.available-versions.steam-release")}</span>
</a>
)}
</div>
@@ -6,41 +6,44 @@ import BeatConflictImg from "../../../../assets/images/apngs/beat-conflict.png";
import BeatWaitingImg from "../../../../assets/images/apngs/beat-waiting.png";
import BeatImpatientImg from "../../../../assets/images/apngs/beat-impatient.png";
import { BsmButton } from "../shared/bsm-button.component";
import { useTranslation } from "renderer/hooks/use-translation.hook";
export function NotificationItem({resolver, notification}: {resolver?: (value: NotificationResult|string) => void, notification: Notification}) {
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 t = useTranslation();
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 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";
}
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">
<div className="w-full flex flex-col">
<div className="flex items-center justify-start pl-1">
<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">{notification.title}</h1>
{notification.desc && <p className="text-xs">{notification.desc}</p>}
</div>
<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">
<div className="w-full flex flex-col">
<div className="flex items-center justify-start pl-1">
<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">{t(notification.desc)}</p>}
</div>
{notification.actions && (
<div className="flex pb-1 w-full flex-wrap px-[2px]">
{notification.actions.map(a => <span onClick={() => resolver(a.id)} className={`px-1 cursor-pointer flex-1 grow rounded-md text-center bg-blue-500 hover:brightness-110 transition-all text-gray-200 whitespace-nowrap m-[3px] ${a.cancel && "!bg-gray-500"}`}>{a.title}</span>)}
</div>
)}
</div>
<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>
</div>
{notification.actions && (
<div className="flex pb-1 w-full flex-wrap px-[2px]">
{notification.actions.map(a => <span onClick={() => resolver(a.id)} className={`px-1 cursor-pointer flex-1 grow rounded-md text-center bg-blue-500 hover:brightness-110 transition-all text-gray-200 whitespace-nowrap m-[3px] ${a.cancel && "!bg-gray-500"}`}>{t(a.title)}</span>)}
</div>
)}
</div>
<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>
)
}