add react modal and use it for days wishes

This commit is contained in:
memeriau
2022-01-29 22:55:07 +01:00
parent 2bfd8d2a7b
commit c2f4946da0
16 changed files with 203 additions and 17 deletions

View File

@@ -0,0 +1,38 @@
import { FC, ReactNode, useCallback } from "react"
import RModal from "react-modal"
import { useSelector } from "react-redux"
import { reactAppId } from "../../app"
import styles from "./styles.module.scss"
import { hideModal, selectActiveModalId } from "../../store/ui"
import useAction from "../../utils/useAction"
type Props = {
children: ReactNode
modalId: string
}
RModal.setAppElement(`#${reactAppId}`)
const Modal: FC<Props> = ({ modalId, children }): JSX.Element => {
const activeModalId = useSelector(selectActiveModalId)
const execHideModal = useAction(hideModal)
const onClose = useCallback(() => execHideModal(), [execHideModal])
const modalIsActive = activeModalId === modalId
return (
<RModal
isOpen={modalIsActive}
className={styles.modalContent}
overlayClassName={styles.modalOverlay}
onRequestClose={onClose}
>
<button type="submit" className={styles.closeButton} onClick={onClose}>
&#10005;
</button>
{children}
</RModal>
)
}
export default Modal

View File

@@ -0,0 +1,38 @@
@import "../../theme/variables";
@import "../../theme/mixins";
.modalOverlay {
position: fixed;
z-index: 100;
inset: 0;
background-color: rgba(0, 0, 0, 0.3);
}
.modalContent {
@include horizontal-vertical-center();
position: absolute;
bottom: auto;
right: auto;
padding: 15px;
outline: 0;
background-color: $color-white;
border-radius: 15px;
border: $border-large;
}
.closeButton {
position: absolute;
padding: 0;
z-index: 10;
top: 10px;
right: 10px;
width: 20px;
height: 20px;
border-radius: 0;
line-height: 20px;
color: $color-grey-dark;
text-align: center;
background: none;
cursor: pointer;
}