Merge branch 'MSP-3134_add_modal_window' into 'main'
Resolve MSP-3134 "Add modal window" Closes MSP-3134 See merge request isp/isp-admin-ui!7
This commit is contained in:
commit
92ac13e20b
7 files changed
+172
-3
No files matched your search
@@ -1,3 +1,5 @@
|
|||||||
|
## 0.2.6
|
||||||
|
- Добавлено модальное окно
|
||||||
## 0.2.5
|
## 0.2.5
|
||||||
- UserMenu изменен и перенесен из Header в Menu из Layout, удален Header
|
- UserMenu изменен и перенесен из Header в Menu из Layout, удален Header
|
||||||
## 0.2.4
|
## 0.2.4
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "unsubscribe_landing",
|
"name": "unsubscribe_landing",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.2.5",
|
"version": "0.2.6",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
|
|||||||
@@ -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'
|
import './home-page.scss'
|
||||||
|
|
||||||
export default function HomePage() {
|
const HomePages = () => {
|
||||||
return <div className="home-page">Добро пожаловать!</div>
|
const { hasPermission } = useRole()
|
||||||
|
const { useToken } = theme
|
||||||
|
const { token } = useToken()
|
||||||
|
const [isOpenModal, setIsOpenModal] = useState(false)
|
||||||
|
|
||||||
|
const isPageAvailable = hasPermission(PermissionKeys.user_view)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main className="main" style={{ backgroundColor: token.colorBgLayout }}>
|
||||||
|
{isPageAvailable && (
|
||||||
|
<Button ghost type="primary">
|
||||||
|
Border
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<div>Проверка шрифтов</div>
|
||||||
|
|
||||||
|
{isOpenModal && (
|
||||||
|
<Modal setIsOpenModal={setIsOpenModal} title="modal title">
|
||||||
|
<div>modal content</div>
|
||||||
|
</Modal>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Button type="primary" onClick={() => setIsOpenModal(true)}>
|
||||||
|
Open Modal
|
||||||
|
</Button>
|
||||||
|
</main>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default HomePages
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
.close-btn {
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
padding: 5px !important;
|
||||||
|
position: absolute;
|
||||||
|
top: 8px;
|
||||||
|
right: 8px;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { Button } from 'antd'
|
||||||
|
|
||||||
|
import './close-btn.scss'
|
||||||
|
|
||||||
|
interface CloseBtnPropsType {
|
||||||
|
ariaLabel?: string
|
||||||
|
onClick: () => void
|
||||||
|
}
|
||||||
|
const CloseBtn = ({ onClick, ariaLabel }: CloseBtnPropsType) => {
|
||||||
|
return (
|
||||||
|
<Button className="close-btn" aria-label={ariaLabel} onClick={onClick}>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 50 50"
|
||||||
|
width="20px"
|
||||||
|
height="20px"
|
||||||
|
>
|
||||||
|
<path d="M 7.71875 6.28125 L 6.28125 7.71875 L 23.5625 25 L 6.28125 42.28125 L 7.71875 43.71875 L 25 26.4375 L 42.28125 43.71875 L 43.71875 42.28125 L 26.4375 25 L 43.71875 7.71875 L 42.28125 6.28125 L 25 23.5625 Z" />
|
||||||
|
</svg>
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CloseBtn
|
||||||
@@ -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<SetStateAction<boolean>>
|
||||||
|
footer?: { onOkText: string; onCanselText: string }
|
||||||
|
}
|
||||||
|
|
||||||
|
const Modal = ({
|
||||||
|
onOk,
|
||||||
|
footer,
|
||||||
|
title,
|
||||||
|
children,
|
||||||
|
setIsOpenModal
|
||||||
|
}: ModalPropsType) => {
|
||||||
|
const closeModal = () => {
|
||||||
|
setIsOpenModal(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleModalClick = (event: MouseEvent<HTMLDivElement>) => {
|
||||||
|
event.stopPropagation()
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="modal" onClick={closeModal}>
|
||||||
|
<div className="modal__wrap" onClick={handleModalClick}>
|
||||||
|
<h1 className="modal__title">{title}</h1>
|
||||||
|
<div className="modal__content">{children}</div>
|
||||||
|
{footer && (
|
||||||
|
<div className="modal__footer">
|
||||||
|
<Button type="default" onClick={closeModal}>
|
||||||
|
{footer.onCanselText}
|
||||||
|
</Button>
|
||||||
|
<Button type="default" onClick={onOk}>
|
||||||
|
{footer.onOkText}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<CloseBtn onClick={closeModal} ariaLabel="close" />
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Modal
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in new issue
Block a user