-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/allowlist' into develop
- Loading branch information
Showing
13 changed files
with
539 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { | ||
Box, | ||
Flex, | ||
Modal, | ||
ModalBody, | ||
ModalCloseButton, | ||
ModalContent, | ||
ModalHeader, | ||
ModalOverlay, | ||
ModalProps, | ||
} from '@chakra-ui/react'; | ||
import cx from 'classnames'; | ||
|
||
import styles from './styles.module.scss'; | ||
import { ReactNode } from 'react'; | ||
import { useDispatch } from 'react-redux'; | ||
import { closeModal } from '@/stores/states/modal/reducer'; | ||
|
||
export interface ModalComponentProps { | ||
id: string; | ||
render: Function; | ||
title?: string | ReactNode; | ||
className?: string; | ||
actions?: object; | ||
modalProps?: ModalProps; | ||
onClose?: Function; | ||
theme?: 'light' | 'dark'; | ||
contentPadding?: number; | ||
hideCloseButton?: boolean; | ||
size?: string; | ||
disableBgClose?: boolean; | ||
} | ||
|
||
const ModalComponent = (props: ModalComponentProps) => { | ||
const { | ||
id, | ||
render, | ||
title, | ||
className, | ||
actions, | ||
modalProps, | ||
onClose, | ||
contentPadding, | ||
hideCloseButton = false, | ||
disableBgClose = false, | ||
} = props; | ||
|
||
const dispatch = useDispatch(); | ||
|
||
const handleClose = () => { | ||
dispatch(closeModal({ id })); | ||
if (onClose) onClose(props); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
isOpen | ||
onClose={handleClose} | ||
isCentered | ||
closeOnOverlayClick={!disableBgClose} | ||
{...modalProps} | ||
> | ||
<ModalOverlay /> | ||
<ModalContent | ||
className={className} | ||
minW={{ base: '90%', sm: '440px' }} | ||
padding={contentPadding} | ||
// height={'90%'} | ||
> | ||
<Flex | ||
className="modal-header-wrap" | ||
justifyContent={'space-between'} | ||
alignItems="center" | ||
mb={[3]} | ||
> | ||
{!!title && ( | ||
<Box flex={1}> | ||
<ModalHeader | ||
style={{ | ||
fontFamily: 'var(--chakra-fonts-body)', | ||
fontSize: 24, | ||
textTransform: | ||
typeof title === 'string' ? 'capitalize' : 'none', | ||
fontWeight: 600, | ||
}} | ||
> | ||
{title} | ||
</ModalHeader> | ||
</Box> | ||
)} | ||
<Box | ||
display={hideCloseButton ? 'none' : 'block'} | ||
style={ | ||
contentPadding | ||
? { | ||
paddingTop: 20, | ||
paddingRight: 20, | ||
} | ||
: {} | ||
} | ||
> | ||
<ModalCloseButton | ||
size={'sm'} | ||
className={cx(styles.modalButtonClose)} | ||
/> | ||
</Box> | ||
</Flex> | ||
|
||
<ModalBody className={cx(styles.modalBody)}> | ||
{render && render(actions)} | ||
</ModalBody> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ModalComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use client'; | ||
|
||
import last from 'lodash/last'; | ||
import cx from 'classnames'; | ||
import ModalComponent, { ModalComponentProps } from './ModalComponent'; | ||
import styles from './styles.module.scss'; | ||
import { closeModal, openModal } from '@/stores/states/modal/reducer'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { modalSelector } from '@/stores/states/modal/selector'; | ||
|
||
const ModalManager = () => { | ||
const modals: ModalComponentProps[] = useSelector(modalSelector) | ||
.modals as unknown as ModalComponentProps[]; | ||
const dispatch = useDispatch(); | ||
|
||
if (!modals.length) return null; | ||
|
||
const onBackdropClick = () => { | ||
const id = last(modals)?.id || ''; | ||
dispatch(closeModal({ id })); | ||
}; | ||
|
||
return ( | ||
<div className={cx(styles.wrapper, modals.length > 0 && styles.show)}> | ||
<div className={styles.backdrop} onClick={onBackdropClick} /> | ||
{modals.map(modal => ( | ||
<ModalComponent | ||
key={modal.id} | ||
actions={{ openModal, closeModal }} | ||
id={modal.id} | ||
title={modal.title} | ||
render={modal.render} | ||
className={modal.className} | ||
modalProps={modal.modalProps} | ||
onClose={modal.onClose} | ||
theme={modal.theme} | ||
hideCloseButton={modal.hideCloseButton} | ||
disableBgClose={modal.disableBgClose} | ||
/> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ModalManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.noPadding { | ||
padding: 0; | ||
} | ||
.modalContent { | ||
border: none; | ||
} | ||
.modalBody { | ||
-ms-overflow-style: none; /* IE and Edge */ | ||
scrollbar-width: none; /* Firefox */ | ||
&::-webkit-scrollbar { | ||
display: none; | ||
} | ||
} | ||
.modalDark { | ||
background-color: var(--bs-gray-dark); | ||
color: #fcfcfd; | ||
button { | ||
filter: invert(100%) sepia(0%) saturate(0%) hue-rotate(10deg) | ||
brightness(104%) contrast(102%); | ||
} | ||
} | ||
|
||
.modalButtonClose { | ||
box-shadow: none !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,3 +57,8 @@ | |
border-radius: 0 !important; | ||
} | ||
} | ||
|
||
.modalContent { | ||
border-radius: 0px !important; | ||
min-width: unset !important; | ||
} |
Oops, something went wrong.