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

phaser refactoring #169

Merged
merged 6 commits into from
Dec 8, 2022
2 changes: 1 addition & 1 deletion frontend/src/component/Call/callingItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const CallingItem = ({
const [friends, setFriends] = useRecoilState(friendsState);

const handleRejectCall = () => {
friends.id &&
friends[id] &&
setFriends({
...friends,
[id]: {
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/component/Call/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ const Call = () => {
return (
<div css={callingWrapper}>
{friendList.map(friend => (
<CallingItem id={friend.id} nickname={friend.nickname} isSend={false} />
<CallingItem
key={friend.id}
id={friend.id}
nickname={friend.nickname}
isSend={true}
/>
))}
{isSend.id && (
<CallingItem
id={isSend.id}
nickname={isSend.nickname}
isSend={true}
isSend={false}
setSend={setSend}
/>
)}
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/component/Game/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ export default class Game extends Phaser.Scene {
}

create() {
this.cameras.main.setBounds(0, 0, 2000, 2000);

const map = this.make.tilemap({ key: 'map' });
const tileset = map.addTilesetImage('town', 'tileset');
this.townLayer = map.createLayer('town', tileset, 0, 0).setScale(2.5);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/component/Sidebar/Friends/friendItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const FriendItem = ({ friend }: { friend: friendType }) => {

const newFriend = { ...friends };

delete newFriend[nickname];
delete newFriend[id];
setFriends(newFriend);

alert(`${nickname}๋‹˜์„ ์–ธํŒ”๋กœ์šฐ ํ•˜์˜€์Šต๋‹ˆ๋‹ค.`);
Expand All @@ -50,7 +50,7 @@ const FriendItem = ({ friend }: { friend: friendType }) => {
return (
<Content draggable={isOnline}>
<section id={id} css={friendItemWrapper(isOnline)}>
<div css={userName(isOnline)}>{nickname}</div>
<div css={userName(status)}>{nickname}</div>
<div>
<button onClick={sendChatting}>
<img src={message} alt="์ฑ„ํŒ…ํ•˜๊ธฐ ๋ฒ„ํŠผ"></img>
Expand Down
20 changes: 18 additions & 2 deletions frontend/src/component/Sidebar/Friends/friendList.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
import { MouseEvent } from 'react';
import { useRecoilValue } from 'recoil';
import { useRecoilState, useRecoilValue } from 'recoil';
import Content from '../Content';
import FriendItem from './friendItem';
import { friendType } from './friends';
import { friendListWrapper } from './friends.styled';
import { friendsState } from '../../../store/atom/friends';
import Search from './search';
import { socketState } from '../../../store/atom/socket';

const FriendList = () => {
const friends = useRecoilValue(friendsState);
const [friends, setFriends] = useRecoilState(friendsState);
const friendList = Object.values(friends).filter(value => !value.isCalling);
const socket = useRecoilValue(socketState);

socket.on('userDataChanged', data => {
const { id, nickname } = data;

if (!friends[id]) return;

const newFriends = { ...friends };
newFriends[id] = {
...newFriends[id],
nickname: nickname,
};

setFriends(newFriends);
});

const handleDrag = (e: MouseEvent) => {
const target = e.target as HTMLElement;
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/component/Sidebar/Friends/friends.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const friendItemWrapper = (isOnline: boolean) => css`
}
`;

export const userName = (state: boolean) => css`
export const userName = (state: string) => css`
font-weight: 700;

::before {
Expand All @@ -76,7 +76,11 @@ export const userName = (state: boolean) => css`
width: 10px;
height: 10px;
border-radius: 5px;
background-color: ${state ? theme.green : theme.red};
background-color: ${state === 'online'
? theme.green
: state === 'offline'
? theme.red
: theme.yellow};
}
`;

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/component/Sidebar/Friends/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Search = () => {

setFriends({
...friends,
id: {
[data.userId]: {
id: data.userId,
status: 'offline',
nickname: data.nickname,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const global = css`
*::after,
*::before {
box-sizing: border-box;
font-family: 'NanumSquareRound';
font-family: 'NanumSquareRound', 'nanum';
}

body {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/guard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const routerGuard = () => {

friendList.forEach(
({ userId, nickname }: { userId: string; nickname: string }) => {
initialList[nickname] = {
initialList[userId] = {
id: userId,
status: 'offline',
nickname: nickname,
Expand All @@ -37,6 +37,7 @@ export const routerGuard = () => {
);

setFriends(initialList);
console.log(initialList);
} catch (e) {
console.log(e);
}
Expand Down