From efa31126d00559587388bf97d8dd92530576394f Mon Sep 17 00:00:00 2001 From: MathieuG-P <40181755+Zagrios@users.noreply.github.com> Date: Tue, 17 May 2022 23:50:54 +0200 Subject: [PATCH] composant modal global --- .../components/modal/modal.component.tsx | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/renderer/components/modal/modal.component.tsx diff --git a/src/renderer/components/modal/modal.component.tsx b/src/renderer/components/modal/modal.component.tsx new file mode 100644 index 00000000..da476f26 --- /dev/null +++ b/src/renderer/components/modal/modal.component.tsx @@ -0,0 +1,29 @@ +import { ModalExitCode, ModalService, ModalType } from "renderer/services/modale.service"; + +import { useEffect, useState } from "react" +import { distinctUntilChanged } from "rxjs"; + +import { LoginModal } from "./modal-types/login-modal.component"; + +export function Modal() { + + const [modalType, setModalType] = useState(null as ModalType); + + const modalSevice = ModalService.getInsance(); + + useEffect(() => { + modalSevice.modalType$.pipe(distinctUntilChanged()).subscribe(type => { + setModalType(type) + }) + }, []) + + + return ( +
+ modalSevice.resolve({exitCode: ModalExitCode.NO_CHOICE})} className={`absolute top-0 bottom-0 right-0 left-0 transition-opacity bg-black ${modalType? "opacity-40" : "opacity-0"}`}> +
+ {modalType === ModalType.STEAM_LOGIN && } +
+
+ ) +}