-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModal.tsx
45 lines (40 loc) · 1022 Bytes
/
Modal.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { useAppSelector } from '../hooks/redux'
import { useActions } from '../hooks/actions'
import { ReactNode } from 'react'
interface IModal {
children: ReactNode
isOpenFav?: boolean
}
const Modal: React.FC<IModal> = ({ children, isOpenFav }) => {
const { closeAllModals } = useActions()
const { isOpenLanguage, isOpenAddFav, isRemovingFav, isRemovingHistory } =
useAppSelector((state) => state.modal)
return (
<div
className={
isOpenLanguage ||
isOpenAddFav ||
isOpenFav ||
isRemovingFav ||
isRemovingHistory
? 'modal-wrapper open'
: 'modal-wrapper'
}
onClick={() => closeAllModals(false)}
>
<div
className={
isOpenFav
? 'modal description'
: isRemovingFav || isRemovingHistory
? 'modal removing'
: 'modal'
}
onClick={(e) => e.stopPropagation()}
>
{children}
</div>
</div>
)
}
export default Modal