From 4c0f417469fb15adbe33cab9bb66459225653e68 Mon Sep 17 00:00:00 2001 From: MAZE Date: Sun, 16 Jun 2024 19:32:40 +0330 Subject: [PATCH] feat: add persist mode to the modal --- src/components/modal/modal.tsx | 75 +++++++++++-------- .../countdown-timer/countdown-timer.tsx | 2 +- 2 files changed, 44 insertions(+), 33 deletions(-) diff --git a/src/components/modal/modal.tsx b/src/components/modal/modal.tsx index 2049620..5a41181 100644 --- a/src/components/modal/modal.tsx +++ b/src/components/modal/modal.tsx @@ -14,6 +14,7 @@ interface ModalProps { children: React.ReactNode; lockBody?: boolean; onClose: () => void; + persist?: boolean; show: boolean; wide?: boolean; } @@ -22,6 +23,7 @@ export function Modal({ children, lockBody = true, onClose, + persist = false, show, wide, }: ModalProps) { @@ -50,40 +52,49 @@ export function Modal({ return () => document.removeEventListener('keydown', keyListener); }, [onClose, show]); + const animationProps = persist + ? { + animate: show ? 'show' : 'hidden', + } + : { + animate: 'show', + exit: 'hidden', + initial: 'hidden', + }; + + const content = ( + +
+ +
+ + + {children} + +
+
+
+ ); + return ( - - {show && ( - -
- -
- - - - {children} - -
-
-
- )} -
+ {persist ? ( +
{content}
+ ) : ( + {show && content} + )}
); } diff --git a/src/components/toolbox/countdown-timer/countdown-timer.tsx b/src/components/toolbox/countdown-timer/countdown-timer.tsx index 64642e7..5c6c71c 100644 --- a/src/components/toolbox/countdown-timer/countdown-timer.tsx +++ b/src/components/toolbox/countdown-timer/countdown-timer.tsx @@ -12,7 +12,7 @@ interface TimerProps { export function CountdownTimer({ onClose, show }: TimerProps) { return ( - +

Countdown Timer