From 8082b7fbefcd8177e14cf9e46fe36df2defc3ef3 Mon Sep 17 00:00:00 2001 From: mikheykinnv Date: Mon, 8 Apr 2024 12:17:26 +0800 Subject: [PATCH 1/5] MSP-3134 add closeBtn component --- src/components/CloseBtn/close-btn.scss | 8 ++++++++ src/components/CloseBtn/index.tsx | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/components/CloseBtn/close-btn.scss create mode 100644 src/components/CloseBtn/index.tsx diff --git a/src/components/CloseBtn/close-btn.scss b/src/components/CloseBtn/close-btn.scss new file mode 100644 index 0000000..3f0e0fc --- /dev/null +++ b/src/components/CloseBtn/close-btn.scss @@ -0,0 +1,8 @@ +.close-btn { + border: none; + background: transparent; + padding: 5px !important; + position: absolute; + top: 8px; + right: 8px; +} \ No newline at end of file diff --git a/src/components/CloseBtn/index.tsx b/src/components/CloseBtn/index.tsx new file mode 100644 index 0000000..33f2441 --- /dev/null +++ b/src/components/CloseBtn/index.tsx @@ -0,0 +1,22 @@ +import {Button} from "antd"; +import './close-btn.scss' +interface CloseBtnPropsType { + ariaLabel?: string + onClick: () => void +} +const CloseBtn = ({onClick, ariaLabel}: CloseBtnPropsType) => { + return ( + + ); +}; + +export default CloseBtn; \ No newline at end of file From 3a661745d02debeb5d2cd6cd928ba84d32c76a38 Mon Sep 17 00:00:00 2001 From: mikheykinnv Date: Mon, 8 Apr 2024 12:17:46 +0800 Subject: [PATCH 2/5] 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; + } + } +} + + From ab902d855eb2d83d0e5e25f92408214b56d1e1fb Mon Sep 17 00:00:00 2001 From: mikheykinnv Date: Mon, 8 Apr 2024 12:19:20 +0800 Subject: [PATCH 3/5] MSP-3134 connect Modal component --- src/pages/HomePage/index.tsx | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/pages/HomePage/index.tsx b/src/pages/HomePage/index.tsx index 7e844ac..e6f4c17 100644 --- a/src/pages/HomePage/index.tsx +++ b/src/pages/HomePage/index.tsx @@ -1,5 +1,34 @@ -import './home-page.scss' +import {useState} from "react"; +import Modal from "src/widgets/Modal"; +import { Button, theme } from 'antd'; +import { useRole } from '@hooks/useRole.tsx'; -export default function HomePage() { - return
Добро пожаловать!
+import { PermissionKeys } from '@type/roles.type.ts' + +import './home.scss' + +const HomePages = () => { + const { hasPermission } = useRole() + const { useToken } = theme + const { token } = useToken() + const [isOpenModal, setIsOpenModal] = useState(false) + + const isPageAvailable = hasPermission(PermissionKeys.user_view) + + return ( +
+ {isPageAvailable && ( + + )} +
Проверка шрифтов
+ + {isOpenModal &&
modal content
} + + +
+ ) } + +export default HomePages From ec02fb7af08ac4127df420661c809b0ae6b633fe Mon Sep 17 00:00:00 2001 From: mikheykinnv Date: Mon, 8 Apr 2024 12:41:42 +0800 Subject: [PATCH 4/5] MSP-3134 move folders --- src/components/CloseBtn/index.tsx | 22 -------- src/components/Modal/index.tsx | 43 ---------------- src/pages/HomePage/index.tsx | 24 ++++++--- .../CloseBtn/close-btn.scss | 0 src/ui/CloseBtn/index.tsx | 24 +++++++++ src/widgets/Modal/index.tsx | 51 +++++++++++++++++++ src/{components => widgets}/Modal/modal.scss | 0 7 files changed, 91 insertions(+), 73 deletions(-) delete mode 100644 src/components/CloseBtn/index.tsx delete mode 100644 src/components/Modal/index.tsx rename src/{components => ui}/CloseBtn/close-btn.scss (100%) create mode 100644 src/ui/CloseBtn/index.tsx create mode 100644 src/widgets/Modal/index.tsx rename src/{components => widgets}/Modal/modal.scss (100%) diff --git a/src/components/CloseBtn/index.tsx b/src/components/CloseBtn/index.tsx deleted file mode 100644 index 33f2441..0000000 --- a/src/components/CloseBtn/index.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import {Button} from "antd"; -import './close-btn.scss' -interface CloseBtnPropsType { - ariaLabel?: string - onClick: () => void -} -const CloseBtn = ({onClick, ariaLabel}: CloseBtnPropsType) => { - return ( - - ); -}; - -export default CloseBtn; \ No newline at end of file diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx deleted file mode 100644 index d47161c..0000000 --- a/src/components/Modal/index.tsx +++ /dev/null @@ -1,43 +0,0 @@ -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/pages/HomePage/index.tsx b/src/pages/HomePage/index.tsx index e6f4c17..8feaa73 100644 --- a/src/pages/HomePage/index.tsx +++ b/src/pages/HomePage/index.tsx @@ -1,17 +1,19 @@ -import {useState} from "react"; -import Modal from "src/widgets/Modal"; -import { Button, theme } from 'antd'; -import { useRole } from '@hooks/useRole.tsx'; +import { Button, theme } from 'antd' +import { useState } from 'react' + +import { useRole } from '@hooks/useRole.tsx' import { PermissionKeys } from '@type/roles.type.ts' -import './home.scss' +import Modal from 'src/widgets/Modal' + +import './home-page.scss' const HomePages = () => { const { hasPermission } = useRole() const { useToken } = theme const { token } = useToken() - const [isOpenModal, setIsOpenModal] = useState(false) + const [isOpenModal, setIsOpenModal] = useState(false) const isPageAvailable = hasPermission(PermissionKeys.user_view) @@ -24,9 +26,15 @@ const HomePages = () => { )}
Проверка шрифтов
- {isOpenModal &&
modal content
} + {isOpenModal && ( + +
modal content
+
+ )} - + ) } diff --git a/src/components/CloseBtn/close-btn.scss b/src/ui/CloseBtn/close-btn.scss similarity index 100% rename from src/components/CloseBtn/close-btn.scss rename to src/ui/CloseBtn/close-btn.scss diff --git a/src/ui/CloseBtn/index.tsx b/src/ui/CloseBtn/index.tsx new file mode 100644 index 0000000..7cfef8a --- /dev/null +++ b/src/ui/CloseBtn/index.tsx @@ -0,0 +1,24 @@ +import { Button } from 'antd' + +import './close-btn.scss' + +interface CloseBtnPropsType { + ariaLabel?: string + onClick: () => void +} +const CloseBtn = ({ onClick, ariaLabel }: CloseBtnPropsType) => { + return ( + + ) +} + +export default CloseBtn diff --git a/src/widgets/Modal/index.tsx b/src/widgets/Modal/index.tsx new file mode 100644 index 0000000..9e7aad8 --- /dev/null +++ b/src/widgets/Modal/index.tsx @@ -0,0 +1,51 @@ +import { Button } from 'antd' +import { Dispatch, MouseEvent, ReactNode, SetStateAction } from 'react' +import CloseBtn from 'src/ui/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 diff --git a/src/components/Modal/modal.scss b/src/widgets/Modal/modal.scss similarity index 100% rename from src/components/Modal/modal.scss rename to src/widgets/Modal/modal.scss From c4878b944bef68d95ad5b1b7c9a486541af8fcae Mon Sep 17 00:00:00 2001 From: mikheykinnv Date: Mon, 8 Apr 2024 12:28:18 +0800 Subject: [PATCH 5/5] MSP-3134 up version 0.2.6 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c78e3d..93a1726 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## 0.2.6 +- Добавлено модальное окно ## 0.2.5 - UserMenu изменен и перенесен из Header в Menu из Layout, удален Header ## 0.2.4 diff --git a/package.json b/package.json index 42aba9c..12ce48d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "unsubscribe_landing", "private": true, - "version": "0.2.5", + "version": "0.2.6", "type": "module", "scripts": { "start": "vite",