Ott 245 favorite error modal (#102)
parent
a116bbfad2
commit
01124ce8ca
|
After Width: | Height: | Size: 1.0 KiB |
@ -0,0 +1,38 @@ |
|||||||
|
import type { ReactNode } from 'react' |
||||||
|
|
||||||
|
import React, { |
||||||
|
useRef, |
||||||
|
} from 'react' |
||||||
|
import ReactDOM from 'react-dom' |
||||||
|
|
||||||
|
import { |
||||||
|
ModalContainer, |
||||||
|
ModalWindow, |
||||||
|
ModalCloseButton, |
||||||
|
} from './styled' |
||||||
|
|
||||||
|
type TModalProps = { |
||||||
|
children: ReactNode, |
||||||
|
close: ()=> void, |
||||||
|
isOpen: boolean, |
||||||
|
} |
||||||
|
|
||||||
|
export const Modal = ({ |
||||||
|
children, |
||||||
|
close, |
||||||
|
isOpen, |
||||||
|
}: TModalProps) => { |
||||||
|
const modalRoot = useRef(document.getElementById('modal-root')) |
||||||
|
|
||||||
|
return isOpen |
||||||
|
? ReactDOM.createPortal( |
||||||
|
<ModalContainer> |
||||||
|
<ModalWindow> |
||||||
|
<ModalCloseButton onClick={close} /> |
||||||
|
{children} |
||||||
|
</ModalWindow> |
||||||
|
</ModalContainer>, |
||||||
|
modalRoot.current as Element, |
||||||
|
) |
||||||
|
: null |
||||||
|
}; |
||||||
@ -0,0 +1,32 @@ |
|||||||
|
import styled from 'styled-components/macro' |
||||||
|
|
||||||
|
import { CloseButton } from 'features/Common/CloseButton' |
||||||
|
|
||||||
|
export const ModalContainer = styled.div` |
||||||
|
position: fixed; |
||||||
|
top: 0; |
||||||
|
left: 0; |
||||||
|
height: 100vh; |
||||||
|
width: 100vw; |
||||||
|
display: flex; |
||||||
|
align-items: center; |
||||||
|
justify-content: center; |
||||||
|
z-index: 3; |
||||||
|
color: white; |
||||||
|
font-weight: 600; |
||||||
|
` |
||||||
|
export const ModalWindow = styled.div` |
||||||
|
background: #3F3F3F; |
||||||
|
position: relative; |
||||||
|
padding: 15px; |
||||||
|
box-shadow: 0px 5px 30px rgba(0, 0, 0, 0.7); |
||||||
|
border-radius: 10px; |
||||||
|
` |
||||||
|
|
||||||
|
export const ModalCloseButton = styled(CloseButton)` |
||||||
|
margin-right: 19px; |
||||||
|
margin-top: 16px; |
||||||
|
width: 12.82px; |
||||||
|
height: 12.82px; |
||||||
|
cursor: pointer; |
||||||
|
` |
||||||
Loading…
Reference in new issue