-
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.
Merge pull request #105 from 42Blank/feat/pong-socketio-multi
Pong: Socket 연결 및 게임 목록 기능 구현
- Loading branch information
Showing
18 changed files
with
374 additions
and
64 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { useHandleSocket } from './useHandleSocket'; | ||
export { useGetUser } from './useGetUser'; | ||
export { useGetCurrentChatRoom } from './useGetCurrentChatRoom'; | ||
export { useGetCurrentGameRoom } from './useGetCurrentGameRoom'; | ||
export { useLogout } from './useLogout'; |
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,14 @@ | ||
import { useRecoilValue } from 'recoil'; | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
import { gameRoomListState } from 'store'; | ||
|
||
export function useGetCurrentGameRoom() { | ||
const uuid = useLocation().pathname.split('/')[2]; | ||
const gameRoomList = useRecoilValue(gameRoomListState); | ||
|
||
const foundGameRoom = gameRoomList.find(gameRoom => gameRoom.id === uuid); | ||
if (!foundGameRoom) throw Error('게임방을 찾을 수 없습니다!'); | ||
|
||
return foundGameRoom; | ||
} |
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
38 changes: 38 additions & 0 deletions
38
frontend/src/pages/GameListPage/NewGameModalBody.styles.ts
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,38 @@ | ||
import { css } from '@emotion/css'; | ||
|
||
export const newGameFormStyle = css` | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
`; | ||
|
||
export const newGameInnerDivStyle = css` | ||
flex: 1; | ||
`; | ||
|
||
export const formSectionDivStyle = css` | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 10px 20px; | ||
width: calc(100% - 40px); | ||
`; | ||
|
||
export const formSectionButtonWrapper = css` | ||
width: 100%; | ||
height: 50px; | ||
display: flex; | ||
justify-content: space-around; | ||
align-items: center; | ||
border-top: 1px solid black; // TODO: 색상 상수화 | ||
& button { | ||
width: 50%; | ||
height: 100%; | ||
} | ||
& button:first-child { | ||
border-right: 1px solid black; // TODO: 색상 상수화 | ||
} | ||
`; |
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 { FormEvent } from 'react'; | ||
import { useSetRecoilState } from 'recoil'; | ||
import { newGameRoomState } from 'store'; | ||
|
||
import { | ||
formSectionButtonWrapper, | ||
formSectionDivStyle, | ||
newGameFormStyle, | ||
newGameInnerDivStyle, | ||
} from './NewGameModalBody.styles'; | ||
|
||
interface Props { | ||
onClickClose: () => void; | ||
} | ||
|
||
export const NewGameModalBody = ({ onClickClose }: Props) => { | ||
const setNewGameRoom = useSetRecoilState(newGameRoomState); | ||
// const nameRef = useRef<HTMLInputElement>(null); | ||
|
||
function handleOnClick(e: FormEvent) { | ||
// roomTitle 필요없어서 처내야함. | ||
e.preventDefault(); | ||
setNewGameRoom({ | ||
created: true, | ||
}); | ||
onClickClose(); | ||
} | ||
|
||
return ( | ||
<div className={newGameFormStyle}> | ||
<div className={newGameInnerDivStyle}> | ||
<div className={formSectionDivStyle}> | ||
<label htmlFor="new-chat-name">이름따위설정할수없다</label> | ||
{/* <input id="new-chat-name" ref={nameRef} type="text" placeholder="최대 20자" required /> */} | ||
</div> | ||
</div> | ||
<div className={formSectionButtonWrapper}> | ||
<button type="button" onClick={onClickClose}> | ||
닫기 | ||
</button> | ||
<button type="button" onClick={handleOnClick}> | ||
생성 | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; |
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
Oops, something went wrong.
867ce7c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy completed!