From 3a661745d02debeb5d2cd6cd928ba84d32c76a38 Mon Sep 17 00:00:00 2001 From: mikheykinnv Date: Mon, 8 Apr 2024 12:17:46 +0800 Subject: [PATCH] MSP-3134 add Modal component --- src/components/Modal/index.tsx | 43 ++++++++++++++++++++++++++++++ src/components/Modal/modal.scss | 47 +++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 src/components/Modal/index.tsx create mode 100644 src/components/Modal/modal.scss diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx new file mode 100644 index 0000000..d47161c --- /dev/null +++ b/src/components/Modal/index.tsx @@ -0,0 +1,43 @@ +import {Dispatch, MouseEvent, ReactNode, SetStateAction } from "react"; +import {Button} from "antd"; +import CloseBtn from "@components/CloseBtn"; +import './modal.scss'; + +interface ModalPropsType { + onOk?: () => void + title: string + children: ReactNode + setIsOpenModal: Dispatch> + footer?: {onOkText: string, onCanselText: string} +} + +const Modal = ({ onOk, footer, title, children, setIsOpenModal }: ModalPropsType) => { + const closeModal = () => { + setIsOpenModal(false); + }; + + const handleModalClick = (event: MouseEvent) => { + event.stopPropagation(); + }; + + return ( +
+
+

{title}

+
+ {children} +
+ {footer && +
+ + +
+ } + +
+ +
+ ); +}; + +export default Modal; \ No newline at end of file diff --git a/src/components/Modal/modal.scss b/src/components/Modal/modal.scss new file mode 100644 index 0000000..2fac7af --- /dev/null +++ b/src/components/Modal/modal.scss @@ -0,0 +1,47 @@ +.modal { + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + background-color: rgba(211, 211, 211, 0.8); + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; + z-index: 100; + &__wrap { + min-width: 310px; + min-height: 170px; + background: white; + color: white; + z-index: 10; + border-radius: 16px; + box-shadow: 0 5px 20px 0 rgba(0, 0, 0, 0.04); + position: relative; + } + + &__header { + height: 50px; + background: white; + overflow: hidden; + border-top-left-radius: 16px; + border-top-right-radius: 16px; + } + &__content { + padding: 10px; + font-size: 14px; + color: #2c3e50; + text-align: center; + } + &__footer { + position: absolute; + bottom: 8px; + right: 16px; + button:first-child { + margin-right: 8px; + } + } +} + +