Toggle navigation
Toggle navigation
This project
Loading...
Sign in
강동현
/
nodejs-game
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Overnap
2021-06-10 04:16:00 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
efedecbfc36d8126fbb2104f05e2400da8595d08
efedecbf
1 parent
883f3c31
RoundInfo 컴포넌트 추가 및 적용
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
web/src/components/room/GameBoard.tsx
web/src/components/room/RoundInfo.tsx
web/src/components/room/GameBoard.tsx
View file @
efedecb
...
...
@@ -3,6 +3,7 @@ import { useLocation } from 'react-router';
import SocketContext from '../../contexts/SocketContext';
import { MessageType, RawMessage } from '../common/types';
import { Canvas } from './Canvas';
import { RoundInfo } from './RoundInfo';
import { Role, RoundData } from './types';
import { Word } from './Word';
...
...
@@ -21,6 +22,7 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => {
const [ isDrawer, setIsDrawer ] = useState(false);
const [ words, setWords ] = useState<string[]>([]);
const [ wordChosen, setWordChosen ] = useState('');
const [ round, setRound ] = useState(0);
const handleWordSet = useCallback((rawMessage: RawMessage) => {
if (rawMessage.type === MessageType.GAME_WORDSET) {
...
...
@@ -40,6 +42,7 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => {
const index = data.roles.findIndex(x => x.username === location.state.username);
setIsDrawer(data.roles[index].role === 'drawer');
setWordChosen('');
setRound(data.round);
}
}, []);
...
...
@@ -69,6 +72,7 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => {
<div className='w-full flex flex-col justify-center items-center'>
{words.map((word, i) => (<Word key={word} index={i} word={word} setWordChosen={setWordChosen} setWords={setWords} />))}
</div>
<RoundInfo round={round} wordChosen={wordChosen}/>
<Canvas isDrawer={isDrawer && wordChosen !== ''}/>
</div>
);
...
...
web/src/components/room/RoundInfo.tsx
0 → 100644
View file @
efedecb
import React from 'react';
import SocketContext from '../../contexts/SocketContext';
import { RoundData } from './types';
interface RoundInfoProps {
round: number;
wordChosen: string;
}
export const RoundInfo: React.FC<RoundInfoProps> = ({ round, wordChosen }) => {
return (
<div className='w-full p-3 flex items-center place-content-between'>
<div>대충 타이머 위치</div>
<div>{wordChosen}</div>
<div>R{round}</div>
</div>
);
}
\ No newline at end of file
Please
register
or
login
to post a comment