sdy

move Form, RoomList component to RoomPresenter

1 import React from "react"; 1 import React from "react";
2 import styled from "styled-components"; 2 import styled from "styled-components";
3 +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
4 +import { faArrowRight } from "@fortawesome/free-solid-svg-icons";
5 +import { Link } from "react-router-dom";
3 import Header from "../../Components/Header"; 6 import Header from "../../Components/Header";
4 -import RoomList from "../../Components/RoomList"; 7 +import Input from "../../Components/Input";
8 +import Button from "../../Components/Button";
5 9
6 const Wrapper = styled.div` 10 const Wrapper = styled.div`
7 display: flex; 11 display: flex;
...@@ -15,11 +19,159 @@ const Wrapper = styled.div` ...@@ -15,11 +19,159 @@ const Wrapper = styled.div`
15 } 19 }
16 `; 20 `;
17 21
18 -export default ({ roomArray }) => { 22 +const FormContainer = styled.div`
23 + visibility: hidden;
24 + display: flex;
25 + position: fixed;
26 + background-color: #f5f6fa;
27 + min-height: 10rem;
28 + min-width: 20rem;
29 + border-radius: 10px;
30 +`;
31 +
32 +const Form = styled.form`
33 + display: flex;
34 + flex-direction: column;
35 + align-items: center;
36 + justify-content: center;
37 + width: 100%;
38 + padding: 15px;
39 + span {
40 + margin-bottom: 15px;
41 + }
42 + input {
43 + margin-bottom: 15px;
44 + }
45 + button {
46 + background-color: #1e3799;
47 + width: 30%;
48 + color: white;
49 + border-radius: 10px;
50 + font-family: "Ubuntu", sans-serif;
51 + }
52 +`;
53 +
54 +const FormText = styled.span`
55 + font-size: 15px;
56 + font-family: "Ubuntu", sans-serif;
57 +`;
58 +
59 +const RoomWrapper = styled.div`
60 + display: flex;
61 + flex-direction: column;
62 + justify-content: center;
63 + align-items: center;
64 + background-color: #a5b1c2;
65 + border-radius: 10px;
66 + box-shadow: 1px 1px 10px #8395a7;
67 + min-width: 23.75rem;
68 + width: auto;
69 + max-height: none;
70 + padding: 0.5rem 0.7rem 0 1rem;
71 +`;
72 +
73 +const RoomContainer = styled.div`
74 + display: flex;
75 + flex-direction: column;
76 + width: 100%;
77 + overflow-y: scroll;
78 + min-height: 70px;
79 + justify-content: center;
80 + align-items: center;
81 + &::-webkit-scrollbar {
82 + width: 10px;
83 + }
84 + &::-webkit-scrollbar-track {
85 + background-color: transparent;
86 + }
87 + &::-webkit-scrollbar-thumb {
88 + border-radius: 3px;
89 + background-color: gray;
90 + }
91 + &::-webkit-scrollbar-button {
92 + width: 0;
93 + height: 0;
94 + }
95 +`;
96 +
97 +const RoomUL = styled.ul`
98 + width: 100%;
99 + display: flex;
100 + flex-direction: row;
101 + justify-content: space-between;
102 + svg {
103 + color: white;
104 + opacity: 0.7;
105 + }
106 +`;
107 +
108 +const RoomItem = styled.li`
109 + font-family: "Ubuntu", sans-serif;
110 +`;
111 +
112 +const CreateContainer = styled.div`
113 + padding-top: 1.9rem;
114 + padding-bottom: 1.7rem;
115 + box-shadow: 0 -4px 4px rgba(0, 0, 0, 0.04);
116 +`;
117 +
118 +const StyledLink = styled(Link)`
119 + width: 100%;
120 + display: flex;
121 + flex-direction: row;
122 + justify-content: space-between;
123 + align-items: center;
124 + text-decoration: none;
125 + cursor: pointer;
126 + color: #079992;
127 + svg {
128 + color: #079992;
129 + &:hover {
130 + border-bottom: 1px solid #079992;
131 + }
132 + }
133 + li {
134 + color: black;
135 + &:hover {
136 + color: #079992;
137 + }
138 + }
139 + span {
140 + &:hover {
141 + border-bottom: 1px solid #079992;
142 + }
143 + }
144 +`;
145 +
146 +export default ({ roomArray, action }) => {
19 return ( 147 return (
20 <Wrapper> 148 <Wrapper>
21 <Header text={"KhuChat"}></Header> 149 <Header text={"KhuChat"}></Header>
22 - <RoomList roomArray={roomArray}></RoomList> 150 + <RoomWrapper>
151 + <RoomContainer>
152 + <RoomUL>
153 + {roomArray &&
154 + roomArray.map((e) => (
155 + <StyledLink to={e.name} key={e.id}>
156 + <RoomItem>{e.name}</RoomItem>
157 + <FontAwesomeIcon icon={faArrowRight} />
158 + </StyledLink>
159 + ))}
160 + </RoomUL>
161 + </RoomContainer>
162 + <CreateContainer>
163 + <StyledLink to="/">
164 + <span>Create New Room</span>
165 + </StyledLink>
166 + </CreateContainer>
167 + </RoomWrapper>
168 + <FormContainer>
169 + <Form>
170 + <FormText>Room Name</FormText>
171 + <Input placeholder="Enter new Room name" />
172 + <Button text="Submit" />
173 + </Form>
174 + </FormContainer>
23 </Wrapper> 175 </Wrapper>
24 ); 176 );
25 }; 177 };
......