sdy

update chat presenter

1 -import React, { useEffect } from "react"; 1 +import React from "react";
2 import styled from "styled-components"; 2 import styled from "styled-components";
3 -import Header from "../../Components/Header";
4 import Input from "../../Components/Input"; 3 import Input from "../../Components/Input";
5 -import Button from "../../Components/Button";
6 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; 4 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
7 -import { faAddressBook } from "@fortawesome/free-solid-svg-icons"; 5 +import { faPlusSquare } from "@fortawesome/free-solid-svg-icons";
8 -import { Link } from "react-router-dom";
9 -import Category from "../Category/CategoryContainer";
10 -import Message from "../../Components/Message";
11 6
12 const Wrapper = styled.div` 7 const Wrapper = styled.div`
13 - display: grid; 8 + display: block;
14 width: 100%; 9 width: 100%;
15 - height: 100%; 10 + height: 100vh;
16 - grid-template-rows: 80px auto min-content; 11 + background-color: #2f3136;
17 - grid-template-areas: 12 +`;
18 - "Header" 13 +
19 - "Workspace"; 14 +const ServerListBox = styled.div`
20 - .Header { 15 + position: absolute;
21 - box-shadow: none; 16 + top: 0;
22 - } 17 + left: 0;
18 + bottom: 0;
19 + width: 72px;
20 + background-color: #202225;
21 + color: white;
23 `; 22 `;
24 23
25 -const ChatWrapper = styled.div` 24 +const ServerNav = styled.nav`
26 display: flex; 25 display: flex;
27 - flex-direction: row; 26 + flex-direction: column;
28 - width: 100%;
29 - height: 100%;
30 - grid-template-columns: 200px auto;
31 - grid-area: "Workspace";
32 `; 27 `;
33 28
34 -const ChatMenuContainer = styled.div` 29 +const ServerBox = styled.div``;
35 - display: grid; 30 +
36 - width: 200px; 31 +const MainContainer = styled.div`
37 - height: 100%; 32 + position: absolute;
38 - background-color: #667aff; 33 + top: 0;
39 - color: white; 34 + left: 72px;
40 - grid-template-rows: 80px 80px 1fr; 35 + right: 0;
36 + bottom: 0;
41 `; 37 `;
42 38
43 -const TitleContainer = styled.div` 39 +const MainContentBox = styled.div`
40 + width: 100%;
41 + height: 100%;
44 display: flex; 42 display: flex;
45 - justify-content: center; 43 + flex: 1 1 auto;
46 - align-items: center;
47 - font-size: 20px;
48 - border-top: 1px solid rgba(255, 255, 255, 0.5);
49 `; 44 `;
50 45
51 -const Title = styled.span` 46 +const MainSideBar = styled.div`
52 - font-family: "Chelsea Market", cursive; 47 + background-color: #2f3136;
48 + color: white;
53 `; 49 `;
54 50
55 -const ItemText = styled.span` 51 +const MainBox = styled.div`
56 - font-family: "Ubuntu", sans-serif; 52 + width: 100%;
57 `; 53 `;
58 54
59 -const PeopleContainer = styled.div` 55 +const HeaderSection = styled.section`
56 + background-color: #36393f;
57 + color: white;
58 + padding: 15px;
59 +`;
60 +
61 +const SectionContainer = styled.div`
60 display: flex; 62 display: flex;
61 - justify-content: center; 63 + flex-direction: row;
62 - align-items: center; 64 + height: auto;
63 - svg {
64 - font-size: 20px;
65 - }
66 - span {
67 - margin-left: 10px;
68 - font-size: 20px;
69 - }
70 - border-top: 1px solid rgba(255, 255, 255, 0.5);
71 `; 65 `;
72 66
73 -const ChatScreenContainer = styled.div` 67 +const ChatSection = styled.section`
74 - display: grid; 68 + background-color: #36393f;
75 - width: 100%; 69 + color: white;
76 - height: 100%; 70 + flex: 1 1 auto;
77 - grid-template-rows: 70px 1fr;
78 `; 71 `;
79 72
80 -const ChatScreenHeader = styled.div` 73 +const MessageWrapper = styled.div`
74 + position: relative;
81 display: flex; 75 display: flex;
82 - flex-direction: row; 76 + flex: 1 1 auto;
83 - align-items: center;
84 - padding: 10px;
85 - border-bottom: 1px solid rgba(0, 0, 0, 0.1);
86 `; 77 `;
87 78
88 -const ChatScreenBox = styled.div` 79 +const ScrollWrapper = styled.div`
80 + overflow-y: scroll;
89 display: flex; 81 display: flex;
82 + flex: 1 1 auto;
90 flex-direction: column; 83 flex-direction: column;
91 - width: 100%;
92 - height: 100%;
93 - overflow-y: scroll;
94 &::-webkit-scrollbar { 84 &::-webkit-scrollbar {
95 - width: 10px; 85 + width: 16px;
96 - } 86 + height: 16px;
97 - &::-webkit-scrollbar-track {
98 - background-color: transparent;
99 } 87 }
100 &::-webkit-scrollbar-thumb { 88 &::-webkit-scrollbar-thumb {
101 - border-radius: 3px; 89 + background-color: #202225;
102 - background-color: gray; 90 + border-color: #36393f;
103 } 91 }
104 - &::-webkit-scrollbar-button { 92 + &::-webkit-scrollbar-thumb,
105 - width: 0; 93 + &::-webkit-scrollbar-track {
106 - height: 0; 94 + border-width: 4px;
95 + border-radius: 8px;
107 } 96 }
108 `; 97 `;
109 98
110 -const InputWrapper = styled.div` 99 +const ScrollInner = styled.div``;
111 - width: 100%;
112 - display: flex;
113 - flex-direction: row;
114 - justify-content: center;
115 - align-items: center;
116 -`;
117 100
118 -const InputContainer = styled.div` 101 +const ScrollInnerTitle = styled.div`
119 - position: fixed; 102 + padding: 10px;
120 - bottom: 0; 103 + p {
121 - justify-content: center; 104 + text-align: center;
122 - align-items: center;
123 - width: 50%;
124 - margin-bottom: 20px;
125 - display: flex;
126 - flex-direction: row;
127 - background-color: #b2bec3;
128 - border: none;
129 - form {
130 - width: 100%;
131 - button {
132 - background-color: #27ae60;
133 - width: 20%;
134 - color: white;
135 - border-radius: 10px;
136 - }
137 - input {
138 - background-color: #b2bec3;
139 - width: 70%;
140 } 105 }
106 +`;
107 +
108 +const CardWrapper = styled.div`
109 + padding: 5px;
110 + text-align: center;
111 + &:last-child {
112 + margin-bottom: 10px;
141 } 113 }
142 - border-radius: 10px;
143 `; 114 `;
144 115
145 -const StyledLink = styled(Link)` 116 +const StyleForm = styled.form``;
146 - width: 100%; 117 +
118 +const InputArea = styled.div`
147 display: flex; 119 display: flex;
148 flex-direction: row; 120 flex-direction: row;
149 - justify-content: center;
150 - align-items: center;
151 - text-decoration: none;
152 - color: white;
153 - cursor: pointer;
154 - &:hover {
155 - background-color: white;
156 - color: #667aff;
157 - }
158 `; 121 `;
159 122
160 -export default ({ 123 +const AttachArea = styled.div``;
161 - location, 124 +
162 - message, 125 +const TextArea = styled.div``;
163 - onSubmit, 126 +
164 - messageArray, 127 +const ButtonArea = styled.div``;
165 - subscribeToNewMessage, 128 +
166 -}) => { 129 +const PeopleSection = styled.section`
167 - const { pathname } = location; 130 + background-color: #2f3136;
168 - const roomName = pathname.slice(1, pathname.length); 131 + color: white;
169 - useEffect(() => subscribeToNewMessage(), []); 132 + flex: 0 1 30%;
133 + min-width: 360px;
134 + max-width: 420px;
135 +`;
170 136
137 +export default () => {
171 return ( 138 return (
172 <Wrapper> 139 <Wrapper>
173 - <Header text={"KhuChat"} /> 140 + <ServerListBox>
174 - <ChatWrapper className="ChatWrapper"> 141 + <ServerNav>
175 - <ChatMenuContainer> 142 + <ServerBox>Test</ServerBox>
176 - <TitleContainer> 143 + </ServerNav>
177 - <Title>{roomName} Room</Title> 144 + </ServerListBox>
178 - </TitleContainer> 145 + <MainContainer>
179 - <PeopleContainer> 146 + <MainContentBox>
180 - <StyledLink to={`/${roomName}/People`}> 147 + <MainSideBar>채널 DM 목록</MainSideBar>
181 - <FontAwesomeIcon icon={faAddressBook} /> 148 + <MainBox>
182 - <ItemText>People</ItemText> 149 + <HeaderSection>상태 표시바</HeaderSection>
183 - </StyledLink> 150 + <SectionContainer>
184 - </PeopleContainer> 151 + <ChatSection>
185 - <Category /> 152 + <MessageWrapper>
186 - </ChatMenuContainer> 153 + <ScrollWrapper>
187 - <ChatScreenContainer> 154 + <ScrollInner>
188 - <ChatScreenHeader> 155 + <ScrollInnerTitle>
189 - <Title>{roomName}</Title> 156 + <p>.. Server 오신 것을 환영합니다.</p>
190 - </ChatScreenHeader> 157 + <p>We Introduce some guides below.</p>
191 - <ChatScreenBox> 158 + </ScrollInnerTitle>
192 - {messageArray && 159 + <CardWrapper>초대하기</CardWrapper>
193 - messageArray.seeAllMessage.map((e) => ( 160 + <CardWrapper>데스크톱 다운로드</CardWrapper>
194 - <Message 161 + <CardWrapper>아이콘</CardWrapper>
195 - text={e.text} 162 + </ScrollInner>
196 - time={e.createdAt} 163 + </ScrollWrapper>
197 - key={e.id} 164 + </MessageWrapper>
198 - avatar={e.sender.avatarUrl} 165 + <StyleForm>
199 - /> 166 + <InputArea>
200 - ))} 167 + <AttachArea>
201 - <InputWrapper> 168 + <FontAwesomeIcon icon={faPlusSquare} />
202 - <InputContainer className="InputContainer"> 169 + </AttachArea>
203 - <form onSubmit={onSubmit}> 170 + <TextArea>
204 - <Input 171 + <Input placeholder="# 보낼 메시지 입력" />
205 - placeholder={"Enter any words"} 172 + </TextArea>
206 - type="text" 173 + <ButtonArea></ButtonArea>
207 - {...message} 174 + </InputArea>
208 - /> 175 + </StyleForm>
209 - <Button text={"Submit"} /> 176 + </ChatSection>
210 - </form> 177 + <PeopleSection>활동중인 친구 리스트</PeopleSection>
211 - </InputContainer> 178 + </SectionContainer>
212 - </InputWrapper> 179 + </MainBox>
213 - </ChatScreenBox> 180 + </MainContentBox>
214 - </ChatScreenContainer> 181 + </MainContainer>
215 - </ChatWrapper>
216 </Wrapper> 182 </Wrapper>
217 ); 183 );
218 }; 184 };
......