Overnap

export default로 일괄 변경

import React from 'react';
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
import { socket, SocketProvider } from './contexts/SocketContext';
import { Login } from './pages/Login';
import { Room } from './pages/Room';
import { Rooms } from './pages/Rooms';
import Login from './pages/Login';
import Room from './pages/Room';
import Rooms from './pages/Rooms';
const App: React.FC = () => {
return (
......
import React from 'react';
export const Footer: React.FC = () => {
const Footer: React.FC = () => {
return (
<div className="mt-auto flex justify-center items-center">
<a href="http://khuhub.khu.ac.kr/2020105578/nodejs-game">
......@@ -18,4 +18,6 @@ export const Footer: React.FC = () => {
</div>
</div>
);
}
\ No newline at end of file
}
export default Footer;
\ No newline at end of file
......
import React from 'react';
import { Footer } from './Footer';
import Footer from './Footer';
export const Main: React.FC = ({ children }) => {
const Main: React.FC = ({ children }) => {
return (
<div className="flex flex-col items-center w-screen h-screen">
{children}
<Footer/>
</div>
);
}
\ No newline at end of file
}
export default Main;
\ No newline at end of file
......
......@@ -9,7 +9,7 @@ interface CanvasProps {
isDrawer: boolean;
}
export const Canvas: React.FC<CanvasProps> = ({ isDrawer }) => {
const Canvas: React.FC<CanvasProps> = ({ isDrawer }) => {
const socket = useContext(SocketContext);
const canvasRef = useRef<HTMLCanvasElement>(null);
......@@ -185,4 +185,6 @@ export const Canvas: React.FC<CanvasProps> = ({ isDrawer }) => {
<canvas ref={canvasRef} width='640' height='480' />
</div>
);
}
\ No newline at end of file
}
export default Canvas;
\ No newline at end of file
......
import React, { useCallback, useContext, useEffect, useRef, useState } from 'react';
import SocketContext from '../../contexts/SocketContext';
import { MessageType, RawMessage } from '../common/types';
import { ChatLine } from './ChatLine';
import ChatLine from './ChatLine';
import { ChatData } from './types';
interface ChatProps {
......@@ -9,7 +9,7 @@ interface ChatProps {
h: string;
}
export const Chat: React.FC<ChatProps> = (props) => {
const Chat: React.FC<ChatProps> = (props) => {
const socket = useContext(SocketContext);
const [ input, setInput ] = useState('');
const [ chatLines, setChatLines ] = useState<ChatData[]>([]);
......@@ -86,4 +86,6 @@ export const Chat: React.FC<ChatProps> = (props) => {
onKeyPress={handleEnter}></input>
</div>
);
}
\ No newline at end of file
}
export default Chat;
\ No newline at end of file
......
......@@ -5,9 +5,11 @@ interface ChatLineProps {
chatData: ChatData;
}
export const ChatLine: React.FC<ChatLineProps> = ({ chatData }) => {
const ChatLine: React.FC<ChatLineProps> = ({ chatData }) => {
return (
<div className='w-full px-3 py-1.5 bg-white
text-gray-700 text-sm'>{chatData.sender} : {chatData.message}</div>
);
}
export default ChatLine;
\ No newline at end of file
......
......@@ -2,10 +2,10 @@ import React, { useCallback, useContext, useEffect, useState } from 'react';
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 Canvas from './Canvas';
import RoundInfo from './RoundInfo';
import { RoundData } from './types';
import { Word } from './Word';
import Word from './Word';
interface GameBoardLocation {
state: { username: string }
......@@ -15,7 +15,7 @@ interface GameBoardProps {
isInGame: boolean
}
export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => {
const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => {
const socket = useContext(SocketContext);
const location: GameBoardLocation = useLocation();
......@@ -91,4 +91,6 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => {
<RoundInfo round={round} wordChosen={wordChosen} />
</div>
);
}
\ No newline at end of file
}
export default GameBoard;
\ No newline at end of file
......
......@@ -12,7 +12,7 @@ interface ReadyProps {
users: User[];
}
export const Ready: React.FC<ReadyProps> = ({ users }) => {
const Ready: React.FC<ReadyProps> = ({ users }) => {
const socket = useContext(SocketContext);
const location: ReadyLocation = useLocation();
......@@ -58,3 +58,5 @@ export const Ready: React.FC<ReadyProps> = ({ users }) => {
onClick={() => handleReady()}>{isAdmin ? 'Start' : 'Ready'}</button>
);
}
export default Ready;
\ No newline at end of file
......
......@@ -5,11 +5,13 @@ interface RoomInfoProps {
roomData: RoomData;
}
export const RoomInfo: React.FC<RoomInfoProps> = ({ roomData }) => {
const RoomInfo: React.FC<RoomInfoProps> = ({ roomData }) => {
return (
<div className='m-3 my-8 w-5/6 flex items-center place-content-between'>
<div>{roomData.name}</div>
<div>{roomData.users.length}/{roomData.maxUsers}</div>
</div>
);
}
\ No newline at end of file
}
export default RoomInfo;
\ No newline at end of file
......
import React from 'react';
import { Timer } from './Timer';
import Timer from './Timer';
interface RoundInfoProps {
round: number;
wordChosen: string;
}
export const RoundInfo: React.FC<RoundInfoProps> = ({ round, wordChosen }) => {
const RoundInfo: React.FC<RoundInfoProps> = ({ round, wordChosen }) => {
return (
<div className='p-3 m-3 h-14 rounded shadow flex items-center place-content-between'>
<Timer />
......@@ -14,4 +14,6 @@ export const RoundInfo: React.FC<RoundInfoProps> = ({ round, wordChosen }) => {
<div>Round {round}/5</div>
</div>
);
}
\ No newline at end of file
}
export default RoundInfo;
\ No newline at end of file
......
......@@ -7,7 +7,7 @@ interface timer {
time: number;
};
export const Timer: React.FC = () => {
const Timer: React.FC = () => {
const socket = useContext(SocketContext);
const [ time, setTime ] = useState(0);
......@@ -52,4 +52,6 @@ export const Timer: React.FC = () => {
🕒 {time}
</div>
);
}
\ No newline at end of file
}
export default Timer;
\ No newline at end of file
......
import React from 'react';
import { User } from './types';
import { UserStatus } from './UserStatus';
import UserStatus from './UserStatus';
interface UserInfoProps {
users: User[];
}
export const UserInfo: React.FC<UserInfoProps> = ({ users }) => {
const UserInfo: React.FC<UserInfoProps> = ({ users }) => {
return (
<div className='w-7/12 h-60 flex justify-center'>
{users.map((user) => (<UserStatus key={user.username} user={user} />))}
</div>
);
}
\ No newline at end of file
}
export default UserInfo
\ No newline at end of file
......
......@@ -7,7 +7,7 @@ interface UserRoleProps {
isInGame: boolean;
}
export const UserRole: React.FC<UserRoleProps> = ({ isInGame }) => {
const UserRole: React.FC<UserRoleProps> = ({ isInGame }) => {
const socket = useContext(SocketContext);
const [ roles, setRoles ] = useState<RoleData[]>([]);
......@@ -39,3 +39,5 @@ export const UserRole: React.FC<UserRoleProps> = ({ isInGame }) => {
</div>
);
}
export default UserRole;
......
......@@ -5,7 +5,7 @@ interface UserStatusProps {
user: User;
}
export const UserStatus: React.FC<UserStatusProps> = ({ user }) => {
const UserStatus: React.FC<UserStatusProps> = ({ user }) => {
return (
<div className='p-3 h-12 m-4 rounded-lg shadow'>
<div className={`${user.admin ? 'text-blue-500' :
......@@ -15,4 +15,6 @@ export const UserStatus: React.FC<UserStatusProps> = ({ user }) => {
{user.nickname}</div>
</div>
)
}
\ No newline at end of file
}
export default UserStatus;
\ No newline at end of file
......
......@@ -9,7 +9,7 @@ interface WordProps {
setWords: (value: React.SetStateAction<string[]>) => void;
}
export const Word: React.FC<WordProps> = (props) => {
const Word: React.FC<WordProps> = (props) => {
const socket = useContext(SocketContext);
const handleChoose = useCallback(() => {
......@@ -35,3 +35,5 @@ export const Word: React.FC<WordProps> = (props) => {
onClick={() => handleChoose()}>{props.word}</button>
);
}
export default Word;
\ No newline at end of file
......
......@@ -8,7 +8,7 @@ interface CreateLocation {
state: { username: string }
}
export const Create: React.FC = () => {
const Create: React.FC = () => {
const history = useHistory();
const socket = useContext(SocketContext);
const [ roomName, setRoomName ] = useState('');
......@@ -54,3 +54,5 @@ export const Create: React.FC = () => {
</div>
);
}
export default Create;
\ No newline at end of file
......
......@@ -4,7 +4,7 @@ interface RefreshProps {
refreshRooms: () => void
}
export const Refresh: React.FC<RefreshProps> = ({ refreshRooms }) => {
const Refresh: React.FC<RefreshProps> = ({ refreshRooms }) => {
return (
<button className="bg-green-500 active:bg-green-600
text-white uppercase text-xl
......@@ -15,3 +15,5 @@ export const Refresh: React.FC<RefreshProps> = ({ refreshRooms }) => {
onClick={() => refreshRooms()}>⟳</button>
);
}
export default Refresh;
\ No newline at end of file
......
......@@ -13,7 +13,7 @@ interface RoomBlockProps {
room: Room
}
export const RoomBlock: React.FC<RoomBlockProps> = ({ room }) => {
const RoomBlock: React.FC<RoomBlockProps> = ({ room }) => {
const history = useHistory();
const socket = useContext(SocketContext);
const location: RoomBlockLocation = useLocation();
......@@ -57,3 +57,5 @@ export const RoomBlock: React.FC<RoomBlockProps> = ({ room }) => {
</button>
);
}
export default RoomBlock;
\ No newline at end of file
......
import React, { useCallback, useContext, useState } from 'react';
import { useHistory } from 'react-router';
import { Main } from '../components/common/Main';
import Main from '../components/common/Main';
import { MessageResponse, MessageType, RawMessage } from '../components/common/types';
import SocketContext from '../contexts/SocketContext';
export const Login: React.FC = () => {
const Login: React.FC = () => {
const history = useHistory();
const socket = useContext(SocketContext);
const [ username, setUsername ] = useState("");
......@@ -51,3 +51,5 @@ export const Login: React.FC = () => {
</Main>
)
}
export default Login;
\ No newline at end of file
......
import React, { useCallback, useContext, useEffect, useState } from 'react';
import { useHistory, useLocation } from 'react-router';
import { Main } from '../components/common/Main';
import Main from '../components/common/Main';
import { MessageResponse, MessageType, RawMessage } from '../components/common/types';
import { Chat } from '../components/room/Chat';
import { GameBoard } from '../components/room/GameBoard';
import { Ready } from '../components/room/Ready';
import { RoomInfo } from '../components/room/RoomInfo';
import Chat from '../components/room/Chat';
import GameBoard from '../components/room/GameBoard';
import Ready from '../components/room/Ready';
import RoomInfo from '../components/room/RoomInfo';
import { RoomData, UpdateRoomUser } from '../components/room/types';
import { UserInfo } from '../components/room/UserInfo';
import { UserRole } from '../components/room/UserRole';
import UserInfo from '../components/room/UserInfo';
import UserRole from '../components/room/UserRole';
import SocketContext from '../contexts/SocketContext';
interface RoomLocation {
state: { roomData: RoomData }
}
export const Room: React.FC = () => {
const Room: React.FC = () => {
const history = useHistory();
const socket = useContext(SocketContext);
const location: RoomLocation = useLocation();
......@@ -123,4 +123,6 @@ export const Room: React.FC = () => {
</div>
</Main>
);
}
\ No newline at end of file
}
export default Room;
\ No newline at end of file
......
import React, { useCallback, useContext, useEffect, useState } from 'react';
import { useHistory } from 'react-router';
import { Main } from '../components/common/Main';
import Main from '../components/common/Main';
import { MessageResponse, MessageType, RawMessage } from '../components/common/types';
import { Create } from '../components/rooms/Create';
import { Refresh } from '../components/rooms/Refrsh';
import { RoomBlock } from '../components/rooms/RoomBlock';
import Create from '../components/rooms/Create';
import Refresh from '../components/rooms/Refrsh';
import RoomBlock from '../components/rooms/RoomBlock';
import { Room } from '../components/rooms/types';
import SocketContext from '../contexts/SocketContext';
export const Rooms: React.FC = () => {
const Rooms: React.FC = () => {
const history = useHistory();
const socket = useContext(SocketContext);
const [ rooms, setRooms ] = useState<Room[]>([]);
......@@ -42,3 +42,5 @@ export const Rooms: React.FC = () => {
</Main>
)
}
export default Rooms;
\ No newline at end of file
......