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", diff --git a/src/pages/HomePage/index.tsx b/src/pages/HomePage/index.tsx index 7e844ac..8feaa73 100644 --- a/src/pages/HomePage/index.tsx +++ b/src/pages/HomePage/index.tsx @@ -1,5 +1,42 @@ +import { Button, theme } from 'antd' +import { useState } from 'react' + +import { useRole } from '@hooks/useRole.tsx' + +import { PermissionKeys } from '@type/roles.type.ts' + +import Modal from 'src/widgets/Modal' + import './home-page.scss' -export default function HomePage() { - return
Добро пожаловать!
+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 diff --git a/src/ui/CloseBtn/close-btn.scss b/src/ui/CloseBtn/close-btn.scss new file mode 100644 index 0000000..3f0e0fc --- /dev/null +++ b/src/ui/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/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/widgets/Modal/modal.scss b/src/widgets/Modal/modal.scss new file mode 100644 index 0000000..2fac7af --- /dev/null +++ b/src/widgets/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; + } + } +} + +