Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Client] / #39 / fix : css #97

Merged
merged 3 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions src/GamePages/InGame.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React, { useState, useEffect, useRef } from 'react';
import Canvas from './components/Canvas3';
import ListnerCanvas from './components/ListnerCanvas';
import Timer from './components/Timer';
import User from './components/User';
import BackBtn from './components/BackBtn';
Expand All @@ -10,14 +8,12 @@ import Chat from './components/Chat';
import io from 'socket.io-client';
import GameStartBtn from './components/GameStartBtn';
import Words from '../Words';
import GameOver from './components/IsInGameMsg';
import { useHistory } from 'react-router-dom';
import Board from './components/Canvas';
import Logo from './components/Logo';


const socket = io.connect('http://localhost:4000', {
transports: ['websocket', 'polling'],
transports: ['websocket'],
path: '/socket.io',
});

Expand Down Expand Up @@ -102,16 +98,23 @@ export default function InGame({ accessToken, isLogIn, loginCheck, userInfo }) {
return chat.map(({ name, message }, index) => (
<div key={index}>
<h3>
{name}: <span>{message}</span>
{name}: <span>{message}</span>{' '}
</h3>
</div>
));
};

// const onMessageSubmit = (e) => {
// const { name, message } = state;
// socket.current.emit('message', { name, message });
// e.preventDefault();
// setState({ message: '', name });
// };

const onMessageSubmit = (e) => {
e.preventDefault();
const { name, message } = state;
socketRef.current.emit('message', { name, message });
socket.emit('message', { name, message });
setState({ message: '', name });
};

Expand Down Expand Up @@ -141,12 +144,13 @@ export default function InGame({ accessToken, isLogIn, loginCheck, userInfo }) {
//! --------------------------method--------------------------

useEffect(() => {
// * 메세지
socketRef.current = socket;
socketRef.current.on('message', ({ name, message }) => {
setChat([...chat, { name, message }]);
socket.on('message', ({ name, message }) => {
if (chat.length > 4) {
return setChat([]);
}
return setChat([...chat, { name, message }]);
});
// return () => socketRef.current.disconnect();
console.log('채팅이야!!!!!', chat);
}, [chat]);

useEffect(() => {
Expand Down Expand Up @@ -184,7 +188,7 @@ export default function InGame({ accessToken, isLogIn, loginCheck, userInfo }) {
});

socket.on('renew userlist', (list) => {
setUserlist(list);
setUserlist([...list]);
});
});

Expand All @@ -196,7 +200,9 @@ export default function InGame({ accessToken, isLogIn, loginCheck, userInfo }) {

let parsedUrl = window.location.href.split('/');
let roomNum = parsedUrl[parsedUrl.length - 1];
console.log(roomNum);
socket.emit('send roomNum', roomNum);
console.log('userlist', userlist);
}, []);

useEffect(() => {
Expand All @@ -218,7 +224,6 @@ export default function InGame({ accessToken, isLogIn, loginCheck, userInfo }) {
<div className="result_box">
<Board />
<Logo />
<Canvas className="canvas" />
{isPresenter ? (
<SelectWords
Word1={Word1}
Expand Down
4 changes: 1 addition & 3 deletions src/GamePages/components/Chat.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React, { useState, useEffect } from 'react';
import moment from 'moment';
import TextField from '@material-ui/core/TextField';

export default function Chat({
Expand All @@ -16,7 +14,7 @@ export default function Chat({
{renderChat()}
</div>

<form onSubmit={(e) => onMessageSubmit(e)}>
<form onSubmit={onMessageSubmit}>
<div className="msgBtn">
<TextField
name="message"
Expand Down
8 changes: 8 additions & 0 deletions src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -930,15 +930,23 @@ canvas {
}

.card {
<<<<<<< HEAD
=======
border: 2px solid #0f4d86;
>>>>>>> b3d2fa2f4bd5a1a35c87b3fda67e7f91c185472c
background-color: white;
border-radius: 15px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
<<<<<<< HEAD
border: 5px solid #0f4d86;
border-radius: 15px;
=======
width: 600px;
height: 400px;
>>>>>>> b3d2fa2f4bd5a1a35c87b3fda67e7f91c185472c
}
.card h1 {
text-align: center;
Expand Down