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

[5주차] 유세은 미션 제출합니다. #14

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
b60720a
초기세팅 완료
YoommY2 May 6, 2022
147a78b
feat : Menu 컴포넌트 만들기
YoommY2 May 6, 2022
4bd3d12
feat: UserProfile 컴포넌트 만들기
YoommY2 May 6, 2022
3351e51
feat : user data, image 추가
YoommY2 May 6, 2022
71de2ca
feat : ChatRoom 컴포넌트 만들기
YoommY2 May 6, 2022
61334d3
feat : InputForm 추가, 여러자잘한 수정,,,
YoommY2 May 6, 2022
ee6551a
feat : useInput hook 생성
YoommY2 May 6, 2022
59d9871
feat : Inputform design & ChatRoom에 반영
YoommY2 May 6, 2022
81d1133
feat: Message 컴포넌트에서 스크롤 생성
YoommY2 May 6, 2022
ee9cbe1
feat : MessageDesign 컴포넌트 작성, data 불러오기
YoommY2 May 6, 2022
ceb2e4f
chore : 파일 import
YoommY2 May 6, 2022
ef196a8
chore : GlobalStyle 만들기
YoommY2 May 6, 2022
cdde61e
docs : 파일별로 정리
YoommY2 May 6, 2022
85c4860
chore : html 제목 수정
YoommY2 May 6, 2022
f45cc54
chore : 다음 과제를 위한 채팅방 컴포넌트
YoommY2 May 6, 2022
e102582
f
YoommY2 May 6, 2022
adcb063
vercel
YoommY2 May 6, 2022
63facf4
test
YoommY2 May 6, 2022
ba7c673
chore : React.memo 사용
YoommY2 May 6, 2022
5d2c5fd
test for vercel
YoommY2 May 6, 2022
a299536
feat : 페이지 라우팅 설정 , friendList 예시로 테스트
YoommY2 May 9, 2022
3527a06
feat : basic design globalStyle에 추가
YoommY2 May 11, 2022
bcfb45a
feat : friendList에서 input 창 만들기, friendList 보여주기
YoommY2 May 11, 2022
58901e1
feat : friendList에 검색 기능 추가, user.json에 프로필 data 추가
YoommY2 May 11, 2022
de3b6ee
style : design for friendList
YoommY2 May 11, 2022
5c052aa
style : friendList에 말꼬리표 만들기
YoommY2 May 11, 2022
5d9ada8
feat : ChatRoomList로 링크 가기, 유저,채팅 데이터 추가 , 말꼬리표 prop 추가
YoommY2 May 11, 2022
18c71fb
feat : 사용자 선택에 따라 다른 채팅방 구현 , userdata수정, UserProfile 수정
YoommY2 May 11, 2022
604b36f
refactor : data에 roomId 설정 후 props 적용해서 유저마다 다른 채팅방이 나올 수 있도록 구현
YoommY2 May 11, 2022
b8b756c
style : 페이지마다 제목달기
YoommY2 May 11, 2022
059b643
feat : 유저 추가, 토글 기능 수정
YoommY2 May 12, 2022
4a12b35
chore : 유저 이미지 변경, 마지막 채팅 나타내기 오류 고치는 중..
YoommY2 May 12, 2022
3ba4cdf
chore : 자잘한 디자인 수정..
YoommY2 May 12, 2022
24e3104
chore : 이모지 전송 오류 수정..
YoommY2 May 12, 2022
ce0fb9c
chore : 자잘한 디자인 수정..
YoommY2 May 12, 2022
6146dce
chore : 파일명 바꾸기, 콘솔로그 지우기
YoommY2 May 12, 2022
c85821d
refactor : useNavigator hook 만들기
YoommY2 May 12, 2022
f2864d0
chore : import 하지 않은 파일 정리, 사용하지 않는 state 정리
YoommY2 May 12, 2022
cfdb30c
chore : props 정리, 자잘한 수정..
YoommY2 May 12, 2022
0a7f070
chore : 자잘한 px 수정
YoommY2 May 12, 2022
22b7a9f
feat : Home,setting 페이지 임의로 생성
YoommY2 May 12, 2022
bc50314
refactor : recoil 적용해보기
YoommY2 May 12, 2022
64ca89c
chore : 설정 페이지 디자인, recoil 시도중.
YoommY2 May 12, 2022
fab4be2
chore : rem으로 단위 바꾸기
YoommY2 May 12, 2022
bfef9b1
chore : useFilter 훅으로 나를 제외한 사용자만 가져오기
YoommY2 May 13, 2022
2bd669e
style : 끝나지 않는 css 수정..
YoommY2 May 13, 2022
99ccfed
refactor : recoil 적용중..
YoommY2 May 13, 2022
930a6ac
chore : file 디렉토리 정리
YoommY2 May 13, 2022
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
47,778 changes: 32,674 additions & 15,104 deletions package-lock.json

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.1.1",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.0",
"@types/node": "^17.0.31",
"@types/react": "^18.0.8",
"@types/react-dom": "^18.0.3",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1",
"recoil": "^0.7.3-alpha.2",
"styled-component": "^2.8.0",
"styled-components": "^5.3.5",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand All @@ -34,5 +42,20 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@types/styled-components": "^5.1.25",
"@typescript-eslint/eslint-plugin": "^5.22.0",
"@typescript-eslint/parser": "^5.22.0",
"eslint": "^8.14.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.5.0",
"prettier": "^2.6.2",
"typescript": "^4.6.4"
}
}
Binary file added public/img/profile0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/profile1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/profile2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/profile3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/profile4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/profile5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/profile6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>React App</title>
<title>💌 Messenger</title>
</head>
<body>
<div id="root"></div>
Expand Down
23 changes: 23 additions & 0 deletions src/.eslinterc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'react-hooks'],
extends: [
'airbnb', // or airbnb-base
'plugin:react/recommended',
'plugin:jsx-a11y/recommended', // 설치 한경우
'plugin:import/errors', // 설치한 경우
'plugin:import/warnings', // 설치한 경우
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
rules: {
'prettier/prettier': 0,
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
};
6 changes: 6 additions & 0 deletions src/.prettierc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
5 changes: 0 additions & 5 deletions src/App.js

This file was deleted.

58 changes: 58 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Route, Routes } from 'react-router-dom';
import styled from "styled-components";
import ChatRoom from "./Pages/ChatRoom";
import Menu from "./Menu";
import FriendList from './Pages/FriendList';
import ChatRoomList from './Pages/ChatRoomList';
import Home from './Pages/Home';
import Setting from './Pages/Setting';

function App() {


const Container = styled.div`

text-align: center;
width: 400px;
height: 600px;
background-color: white;
display: flex;

border-left :0px;
border-radius: 9px;

margin:0 auto; //중앙에 박스
margin-top: 50px;
box-shadow:3px 3px 3px 3px lightgrey;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

box-shadow: 0 1rem 4rem hsl(0 0% 0% / 15%);

제가 자주 사용하는 자연스러운 Shadowing 방식입니다.. 참고해 보세요!!
근데 이번에 세은 님께서 꾸미신 UI 컨셉에는 세은 님께서 기존에 사용하신 방식이 분위기상 더 어울리네요!!


`;


return (

/*

App
/ \
Menu CHatRoom
/ \ \
InputForm UserProfile Message

*/
Comment on lines +33 to +41

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주석으로 이렇게 구조를 표시해주신 점 너무 좋네요..!

<div>
<Container>
<Menu/>
<Routes>
<Route path ="/Home" element ={<Home/>}/>
<Route index element={<FriendList />} />
<Route path ="/Chatroom/:friendId" element ={<ChatRoom/>}/>
<Route path ="/ChatRoomList" element ={<ChatRoomList/>}/>
<Route path ="/Setting" element ={<Setting/>}/>
</Routes>
</Container>
</div>
);
}

export default App;

74 changes: 74 additions & 0 deletions src/ChatRoom/Input/InputForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import {MessageItem} from "../../type"
import React from "react";
import {useCallback} from "react";
import { Dispatch, SetStateAction} from "react";
import useInput from "../../hook/useInput";
import {Input,MessageButton,Form,InputWrapper,Emojimerong} from "./InputformDesign";
import { useRecoilValue, useSetRecoilState } from "recoil";
import { messageListState, userState } from "../../recoil";

type InputProps = {
messageList : MessageItem[];
setMessageList : Dispatch<SetStateAction<MessageItem[]>>
};

function Inputform ({messageList, setMessageList} : InputProps){

const{message, onChange ,setMessage} = useInput();
const currentUser = useRecoilValue(userState); //currentUser 불러오기

//const messageList =useRecoilValue(messageListState);
//const setMessageList = useSetRecoilState(messageListState);

const submitEmoji = useCallback((event : React.SyntheticEvent) => {
event.preventDefault();
setMessageList(messageList => [...messageList,
{
roomId : currentUser,
text: "😛",
userId: currentUser,
}]);
//입력받은 걸 배열에 넣음

},[currentUser]);

const submitInput = useCallback((event : React.SyntheticEvent) => {
event.preventDefault();

if (message) {
setMessageList(messageList => [...messageList,
{
roomId : currentUser,
text: message,
userId: currentUser,
}]);
//입력받은 걸 배열에 넣음

}

else{
alert("메시지를 입력하세요!");
}

setMessage("");
},[message]);

return(
<Form onSubmit={submitInput} >
<Emojimerong onClick={submitEmoji}>😛</Emojimerong>
<Input
onChange={onChange}
value={message}
type="text"
placeholder="메시지를 입력하세요"
autoFocus = {true}
spellCheck="false"

/>
<MessageButton onClick={submitInput}>보내기</MessageButton>
</Form>
);
}


export default React.memo(Inputform);
35 changes: 35 additions & 0 deletions src/ChatRoom/Input/InputformDesign.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import styled from "styled-components";

export const Input = styled.input
`
font-family: 'SuncheonB';
width: 200px;
height: 50px;
border-radius: 9px;
margin:1rem;

`

export const MessageButton = styled.span
`
cursor: pointer;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

커서 모양까지 정해 주신 디테일..!

margin-left : 0.1rem;
font-size: 15px;
`

export const Form = styled.form
`
margin-bottom: 10px;

`
;

export const InputWrapper = styled.div
`
flex:0.3;
`;
export const Emojimerong = styled.span
`
cursor:pointer;
font-size:20px;
`;
47 changes: 47 additions & 0 deletions src/ChatRoom/Message/Message.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { MessageItem, MessageList} from "../../type";
import {useRef,useEffect} from "react";
import {Wrapper,ChatMessage,ChatProfile,Chatcontainer,MessageBox,ChatName} from "./MessageDesign";
import user from "../../data/user.json";
import React from "react";
import { useRecoilValue, useSetRecoilState } from "recoil";
import { messageListState } from "../../recoil";
import chatting from "../../data/chat.json";

type IMessage = {
roomId : number;
}

function Message({messageList} : MessageList){

const messageRef = useRef<HTMLDivElement>(null);

const ScrollEvent = useEffect(()=>{
if(messageRef.current)
messageRef.current.scrollTo({
top: messageRef.current.scrollHeight,
behavior: "smooth",
})
},[messageList]); //메세지리스트가 변할때만 스크롤에 대한 렌더링


return(

<Wrapper ref={messageRef}>
{messageList.map((message) => (
<Chatcontainer key ={message.roomId}>
<ChatProfile src = {user[message.roomId].profile} loading ="lazy"/>
<MessageBox>
<ChatName>{user[message.roomId].name} 님의 말: </ChatName>
<ChatMessage>{message.text}</ChatMessage>
</MessageBox>
</Chatcontainer>
))
}

</Wrapper>

);

}

export default React.memo(Message);
53 changes: 53 additions & 0 deletions src/ChatRoom/Message/MessageDesign.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import styled from "styled-components";
export const Wrapper = styled.div
`
flex:1;
overflow: auto;
::-webkit-scrollbar{
width:8px;
heigth:8px;
background-color: white;
/* 스크롤바 둥글게 설정 */
border-radius: 10px;
}
::-webkit-scrollbar-track{
background-color: white;

`;

export const ChatName = styled.div
`
text-align:left;
font-size:13px;
margin: 0.5rem;
`;

export const Chatcontainer = styled.div
` border-radius: 9px
border: 1px solid grey;
display:flex;
margin: 0.5rem;
`;

export const ChatProfile =styled.img
`
flex:0.1;
width: 30px;
height: 30px;
border-radius: 30px;
margin:0.7rem;
`;

export const ChatMessage = styled.div
`
text-align:left;
margin-left: 1.3rem;
font-size:13px;
`;

export const MessageBox = styled.div
`
display:flex;
flex-direction: column;

`;
Loading