sdy

create ChatPresenter.js

1 +import React from "react";
2 +import styled from "styled-components";
3 +import Header from "../../Components/Header";
4 +import Input from "../../Components/Input";
5 +import Button from "../../Components/Button";
6 +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
7 +import {
8 + faAddressBook,
9 + faArrowDown,
10 + faPlus,
11 +} from "@fortawesome/free-solid-svg-icons";
12 +import { Link } from "react-router-dom";
13 +
14 +const Wrapper = styled.div`
15 + display: grid;
16 + width: 100%;
17 + height: 100%;
18 + grid-template-rows: 80px auto min-content;
19 + grid-template-areas:
20 + "Header"
21 + "Workspace";
22 + .Header {
23 + box-shadow: none;
24 + }
25 +`;
26 +
27 +const ChatWrapper = styled.div`
28 + display: flex;
29 + flex-direction: row;
30 + width: 100%;
31 + height: 100%;
32 + grid-template-columns: 200px auto;
33 + grid-area: "Workspace";
34 +`;
35 +
36 +const ChatMenuContainer = styled.div`
37 + display: grid;
38 + width: 200px;
39 + height: 100%;
40 + background-color: #667aff;
41 + color: white;
42 + grid-template-rows: 80px 80px 1fr;
43 +`;
44 +
45 +const TitleContainer = styled.div`
46 + display: flex;
47 + justify-content: center;
48 + align-items: center;
49 + font-size: 20px;
50 + border-top: 1px solid rgba(255, 255, 255, 0.5);
51 +`;
52 +
53 +const Title = styled.span`
54 + font-family: "Chelsea Market", cursive;
55 +`;
56 +
57 +const ItemText = styled.span`
58 + font-family: "Ubuntu", sans-serif;
59 +`;
60 +
61 +const PeopleContainer = styled.div`
62 + display: flex;
63 + justify-content: center;
64 + align-items: center;
65 + svg {
66 + font-size: 20px;
67 + }
68 + span {
69 + margin-left: 10px;
70 + font-size: 20px;
71 + }
72 + border-top: 1px solid rgba(255, 255, 255, 0.5);
73 +`;
74 +
75 +const CategoryContainer = styled.div`
76 + display: flex;
77 + svg {
78 + font-size: 20px;
79 + }
80 + span {
81 + margin-left: 10px;
82 + font-size: 20px;
83 + }
84 + border-top: 1px solid rgba(255, 255, 255, 0.5);
85 +`;
86 +
87 +const ItemListContainer = styled.div`
88 + display: flex;
89 + flex-direction: row;
90 + width: 100%;
91 + padding: 15px;
92 +`;
93 +
94 +const ItemList = styled.ul`
95 + align-items: center;
96 + svg {
97 + margin: 0px 10px;
98 + }
99 +`;
100 +
101 +const Item = styled.li``;
102 +
103 +const ChatScreenContainer = styled.div`
104 + display: grid;
105 + width: 100%;
106 + height: 100%;
107 + grid-template-rows: 70px 1fr;
108 +`;
109 +
110 +const ChatScreenHeader = styled.div`
111 + display: flex;
112 + flex-direction: row;
113 + align-items: center;
114 + padding: 10px;
115 + border-bottom: 1px solid rgba(0, 0, 0, 0.1);
116 +`;
117 +
118 +const ChatScreenBox = styled.div`
119 + display: flex;
120 + flex-direction: column;
121 + width: 100%;
122 + height: 100%;
123 +`;
124 +
125 +const InputWrapper = styled.div`
126 + display: flex;
127 + flex-direction: row;
128 + justify-content: center;
129 + align-items: center;
130 + padding: 10px;
131 + margin-bottom: 10px;
132 + width: 100%;
133 +`;
134 +
135 +const InputContainer = styled.div`
136 + position: fixed;
137 + bottom: 0;
138 + padding: 10px;
139 + margin-bottom: 20px;
140 + display: flex;
141 + flex-direction: row;
142 + width: 70%;
143 + form {
144 + width: 100%;
145 + button {
146 + background-color: #27ae60;
147 + width: 10%;
148 + color: white;
149 + border-radius: 10px;
150 + }
151 + input {
152 + width: 70%;
153 + }
154 + }
155 + border: 1px solid rgba(0, 0, 0, 0.7);
156 + border-radius: 10px;
157 +`;
158 +
159 +const StyledLink = styled(Link)`
160 + width: 100%;
161 + display: flex;
162 + flex-direction: row;
163 + justify-content: center;
164 + align-items: center;
165 + text-decoration: none;
166 + color: white;
167 + cursor: pointer;
168 + &:hover {
169 + background-color: white;
170 + color: #667aff;
171 + }
172 +`;
173 +
174 +export default ({ data, location, message, onSubmit }) => {
175 + const { pathname } = location;
176 + const roomName = pathname.slice(1, pathname.length);
177 + return (
178 + <Wrapper>
179 + <Header text={"KhuChat"} />
180 + <ChatWrapper className="ChatWrapper">
181 + <ChatMenuContainer>
182 + <TitleContainer>
183 + <Title>{roomName} Room</Title>
184 + </TitleContainer>
185 + <PeopleContainer>
186 + <StyledLink to="People">
187 + <FontAwesomeIcon icon={faAddressBook} />
188 + <ItemText>People</ItemText>
189 + </StyledLink>
190 + </PeopleContainer>
191 + <CategoryContainer>
192 + <ItemListContainer>
193 + <ItemList>
194 + <FontAwesomeIcon icon={faArrowDown} /> Category
195 + <FontAwesomeIcon icon={faPlus} />
196 + <Item>
197 + <ItemText># Music</ItemText>
198 + </Item>
199 + </ItemList>
200 + </ItemListContainer>
201 + </CategoryContainer>
202 + </ChatMenuContainer>
203 + <ChatScreenContainer>
204 + <ChatScreenHeader>
205 + <Title>Selected Menu Title</Title>
206 + </ChatScreenHeader>
207 + <ChatScreenBox>
208 + <InputWrapper>
209 + <InputContainer>
210 + <form onSubmit={onSubmit}>
211 + <Input
212 + placeholder={"Enter any words"}
213 + type="text"
214 + {...message}
215 + />
216 + <Button text={"Submit"} />
217 + </form>
218 + </InputContainer>
219 + </InputWrapper>
220 + </ChatScreenBox>
221 + </ChatScreenContainer>
222 + </ChatWrapper>
223 + </Wrapper>
224 + );
225 +};