-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #378 from boostcampwm-2022/dev
실서버에 0.3.0 버전을 배포합니다.
- Loading branch information
Showing
78 changed files
with
872 additions
and
199 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
25 changes: 25 additions & 0 deletions
25
client/src/components/commons/Modal/ModalProvider/ModalProvider.tsx
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 @@ | ||
import React, { ReactPortal } from "react"; | ||
import { createPortal } from "react-dom"; | ||
|
||
import useModalStore from "@/store/useModalStore"; | ||
import PostMoreModal from "@/components/main/PostScroll/Post/PostFooter/RightBlockItems/PostMoreModal/PostMoreModal"; | ||
import { MODAL_KEY, ModalProps } from "@/types/modal"; | ||
|
||
const MODALS = new Map<MODAL_KEY, React.FC<ModalProps>>([ | ||
[MODAL_KEY.POST_MORE, PostMoreModal], | ||
]); | ||
|
||
const ModalProvider = (): ReactPortal => { | ||
const modals = useModalStore((state) => state.modals); | ||
const Modals = modals.map(({ key, props }) => { | ||
const Modal = MODALS.get(key) as React.FC<ModalProps>; | ||
return <Modal key={key} {...props} />; | ||
}); | ||
|
||
return createPortal( | ||
<>{Modals}</>, | ||
document.getElementById("modal") as Element | ||
); | ||
}; | ||
|
||
export default ModalProvider; |
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,35 @@ | ||
import React, { ReactNode, useRef } from "react"; | ||
|
||
import ModalContainer from "@/components/commons/Modal/core/ModalContainer/ModalContainer"; | ||
import ModalWrapper from "@/components/commons/Modal/core/ModalWrapper/ModalWrapper"; | ||
import ModalOverlay from "@/components/commons/Modal/core/ModalOverlay/ModalOverlay"; | ||
import useOutsideClickHandler from "@/hooks/useOutsideClickHandler"; | ||
import ModalTitle from "@/components/commons/Modal/core/ModalTitle/ModalTitle"; | ||
import ModalContents from "@/components/commons/Modal/core/ModalContents/ModalContents"; | ||
|
||
interface ModalProps { | ||
title?: string; | ||
onClose?: Function; | ||
children?: ReactNode; | ||
} | ||
|
||
const Modal = ({ title, onClose, children }: ModalProps): JSX.Element => { | ||
const modalRef = useRef<HTMLDivElement | null>(null); | ||
const handleModalClose = (): void => { | ||
onClose?.(); | ||
}; | ||
useOutsideClickHandler(modalRef, handleModalClose); | ||
|
||
return ( | ||
<ModalContainer> | ||
<ModalOverlay> | ||
<ModalWrapper ref={modalRef}> | ||
<ModalTitle title={title} /> | ||
<ModalContents>{children}</ModalContents> | ||
</ModalWrapper> | ||
</ModalOverlay> | ||
</ModalContainer> | ||
); | ||
}; | ||
|
||
export default Modal; |
15 changes: 15 additions & 0 deletions
15
client/src/components/commons/Modal/core/ModalContainer/ModalContainer.tsx
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,15 @@ | ||
import React, { ReactNode, ReactPortal } from "react"; | ||
import { createPortal } from "react-dom"; | ||
|
||
interface ModalContainerProps { | ||
children: ReactNode; | ||
} | ||
|
||
const ModalContainer = ({ children }: ModalContainerProps): ReactPortal => { | ||
const modalElement = document.getElementById("modal") as HTMLElement; | ||
const modalContents = <>{children}</>; | ||
|
||
return createPortal(modalContents, modalElement); | ||
}; | ||
|
||
export default ModalContainer; |
6 changes: 6 additions & 0 deletions
6
client/src/components/commons/Modal/core/ModalContents/ModalContents.scss
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,6 @@ | ||
@import "@/styles/_theme.scss"; | ||
|
||
.modal-contents { | ||
font-size: $font-medium; | ||
color: $text-color; | ||
} |
13 changes: 13 additions & 0 deletions
13
client/src/components/commons/Modal/core/ModalContents/ModalContents.tsx
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,13 @@ | ||
import React, { ReactNode } from "react"; | ||
|
||
import "./ModalContents.scss"; | ||
|
||
interface ModalContentsProps { | ||
children?: ReactNode; | ||
} | ||
|
||
const ModalContents = ({ children }: ModalContentsProps): JSX.Element => { | ||
return <div className="modal-contents">{children}</div>; | ||
}; | ||
|
||
export default ModalContents; |
12 changes: 12 additions & 0 deletions
12
client/src/components/commons/Modal/core/ModalOverlay/ModalOverlay.scss
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,12 @@ | ||
$highest-z-index: 90000; // 가장 높은 z-index 값으로 설정 | ||
|
||
.modal-overlay { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
z-index: $highest-z-index; | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba(0, 0, 0, 0.2); // 모달 배경 색 | ||
backdrop-filter: blur(2px); | ||
} |
13 changes: 13 additions & 0 deletions
13
client/src/components/commons/Modal/core/ModalOverlay/ModalOverlay.tsx
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,13 @@ | ||
import React, { ReactNode } from "react"; | ||
|
||
import "./ModalOverlay.scss"; | ||
|
||
interface ModalOverlayProps { | ||
children: ReactNode; | ||
} | ||
|
||
const ModalOverlay = ({ children }: ModalOverlayProps): JSX.Element => { | ||
return <div className="modal-overlay">{children}</div>; | ||
}; | ||
|
||
export default ModalOverlay; |
11 changes: 11 additions & 0 deletions
11
client/src/components/commons/Modal/core/ModalTitle/ModalTitle.scss
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,11 @@ | ||
@import "@/styles/_theme.scss"; | ||
|
||
.modal-title { | ||
width: 100%; | ||
height: 5rem; | ||
font-size: $font-large; | ||
// div 텍스트 중앙 정렬 | ||
line-height: 5rem; | ||
text-align: center; | ||
border-bottom: $border-small $line-color; | ||
} |
13 changes: 13 additions & 0 deletions
13
client/src/components/commons/Modal/core/ModalTitle/ModalTitle.tsx
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,13 @@ | ||
import React from "react"; | ||
|
||
import "./ModalTitle.scss"; | ||
|
||
interface ModalTitleProps { | ||
title?: string; | ||
} | ||
|
||
const ModalTitle = ({ title }: ModalTitleProps): JSX.Element => { | ||
return <div className="modal-title">{title ?? ""}</div>; | ||
}; | ||
|
||
export default ModalTitle; |
19 changes: 19 additions & 0 deletions
19
client/src/components/commons/Modal/core/ModalWrapper/ModalWrapper.scss
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,19 @@ | ||
@import "@/styles/_theme.scss"; | ||
|
||
.modal-wrapper { | ||
position: absolute; | ||
// 좌측 상단 위치를 modal 중앙에 위치 | ||
top: 50%; | ||
left: 50%; | ||
box-sizing: border-box; | ||
width: fit-content; | ||
min-width: 20rem; | ||
height: fit-content; | ||
min-height: 5rem; | ||
background-color: $weview-white; | ||
border: $border-small $line-color; | ||
border-radius: $radius-modal; | ||
box-shadow: $shadow-box; | ||
// wrapper 의 중앙을 modal 중앙에 위치 | ||
transform: translate(-50%, -50%); | ||
} |
19 changes: 19 additions & 0 deletions
19
client/src/components/commons/Modal/core/ModalWrapper/ModalWrapper.tsx
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,19 @@ | ||
import React, { forwardRef, ReactNode } from "react"; | ||
|
||
import "./ModalWrapper.scss"; | ||
|
||
interface ModalWrapperProps { | ||
children: ReactNode; | ||
} | ||
|
||
const ModalWrapper = forwardRef<HTMLDivElement, ModalWrapperProps>( | ||
({ children }, ref): JSX.Element => { | ||
return ( | ||
<div className="modal-wrapper" ref={ref}> | ||
{children} | ||
</div> | ||
); | ||
} | ||
); | ||
|
||
export default ModalWrapper; |
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
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
14 changes: 4 additions & 10 deletions
14
client/src/components/main/Modal/ModalContainer/ModalContainer.scss
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
17 changes: 17 additions & 0 deletions
17
client/src/components/main/Modal/ModalWrapper/ModalWrapper.scss
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 |
---|---|---|
@@ -1,9 +1,26 @@ | ||
@import "@/styles/_global-style.scss"; | ||
@import "@/styles/theme.scss"; | ||
@import "@/styles/responsive"; | ||
|
||
.modal-background { | ||
position: absolute; | ||
top: 0; | ||
z-index: $modal-background-z-index !important; | ||
display: flex; | ||
align-items: center; | ||
width: 100vw; | ||
height: 100vh; | ||
min-height: 100vh; | ||
background-color: rgba(0, 0, 0, 0.75); | ||
} | ||
|
||
.modal-close-button { | ||
position: absolute; | ||
top: 2rem; | ||
right: 2rem; | ||
z-index: $modal-content-z-index; | ||
font-size: 2rem; | ||
color: $line-color; | ||
cursor: pointer; | ||
transform: scale(2); | ||
} |
Oops, something went wrong.