-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#3] feat: Common Modal->ModalContainer
- Loading branch information
1 parent
48bbf82
commit f075576
Showing
5 changed files
with
51 additions
and
95 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,47 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
type Props = { | ||
isPopup?: boolean; | ||
contentComponent?: React.ReactNode; | ||
onClickOverlay?: (e: React.MouseEvent<HTMLElement>) => void; | ||
onClickClose?: (e: React.MouseEvent<HTMLElement>) => void; | ||
}; | ||
|
||
const ModalContainer = ({ | ||
isPopup = false, | ||
contentComponent, | ||
onClickOverlay, | ||
onClickClose, | ||
}: Props) => { | ||
return isPopup ? ( | ||
<Overlay onClick={onClickOverlay}>{contentComponent}</Overlay> | ||
) : ( | ||
<></> | ||
); | ||
}; | ||
|
||
export default ModalContainer; | ||
|
||
const Overlay = styled.div` | ||
display: flex; | ||
position: fixed; | ||
left: 0; | ||
top: 0; | ||
width: 100vw; | ||
height: 100vh; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
ModalContainer.defaultProps = { | ||
isPopup: false, | ||
onClickOverlay: () => { | ||
console.log('modal overlay clicked'); | ||
}, | ||
onClickClose: () => { | ||
console.log('modal close clicked'); | ||
}, | ||
contentComponent: '', | ||
}; |
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 @@ | ||
export { default } from './ModalContainer'; |
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