-
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.
Browse files
Browse the repository at this point in the history
[feat/#46] 모달 Provider, useModal hook 추가, 폰트 추가
- Loading branch information
Showing
17 changed files
with
216 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" as="style" crossorigin href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.min.css" /> | ||
<!-- <script src="https://unpkg.com/ml5@1/dist/ml5.min.js"></script> --> | ||
<title>자세 공작소</title> | ||
</head> | ||
|
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
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,43 @@ | ||
import { ModalsDispatchContext, ModalsStateContext } from "@/contexts/ModalsContext" | ||
import { useContext } from "react" | ||
import CreateCrewModal from "./CreateCrewModal" | ||
import InviteCrewModal from "./InviteCrewModal" | ||
import JoinCrewModal from "./JoinCrewModal" | ||
import WithdrawCrewModal from "./WithdrawCrewModal" | ||
|
||
export const modals = { | ||
createCrewModal: CreateCrewModal, | ||
inviteCrewModal: InviteCrewModal, | ||
joinCrewModal: JoinCrewModal, | ||
withdrawCrewModal: WithdrawCrewModal, | ||
} | ||
|
||
const Modals = (): React.ReactNode => { | ||
const openedModals = useContext(ModalsStateContext) | ||
const { close } = useContext(ModalsDispatchContext) | ||
|
||
return openedModals.map((modal, index) => { | ||
const { Component, props } = modal | ||
if (!props) return null | ||
|
||
const { onSubmit, onClose, ...rest } = props | ||
|
||
const handleClose = async (): Promise<void> => { | ||
if (typeof onClose === "function") { | ||
await onClose() | ||
} | ||
close(Component) | ||
} | ||
|
||
const handleSubmit = async (): Promise<void> => { | ||
if (typeof onSubmit === "function") { | ||
await onSubmit() | ||
} | ||
handleClose() | ||
} | ||
|
||
// eslint-disable-next-line max-len | ||
return <Component key={index} onClose={handleClose} onSubmit={handleSubmit} {...rest} /> | ||
}) | ||
} | ||
export default Modals |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { default as Camera } from "./Camera" | ||
export { default as PoseDetector } from "./PoseDetector" | ||
export { default as Modal } from "./Modal" | ||
export { default as ModalContainer } 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentType, createContext } from "react" | ||
|
||
export type ModalProps = { | ||
id?: number | ||
onClose?: () => void | ||
onSubmit?: () => void | ||
} | ||
|
||
export type ModalComponent = ComponentType<any> | ||
export type ModalsState = Array<{ Component: ModalComponent; props?: ModalProps }> | ||
export type ModalsDispatch = { | ||
open: (Component: ModalComponent, props: ModalProps) => void | ||
close: (Component: ModalComponent) => void | ||
} | ||
|
||
export const ModalsStateContext = createContext<ModalsState>([]) | ||
|
||
export const ModalsDispatchContext = createContext<ModalsDispatch>({ | ||
open: () => {}, | ||
close: () => {}, | ||
}) |
Oops, something went wrong.