Skip to content

Commit 1a6f521

Browse files
committed
Build v1.1.0
1 parent 5d0e72e commit 1a6f521

File tree

9 files changed

+93
-31
lines changed

9 files changed

+93
-31
lines changed

components/Chat.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ const Container = styled.div`
4545
cursor: pointer;
4646
padding: 1.5rem;
4747
word-break: break-word;
48+
font-size: 1.35rem;
49+
color: #495057;
4850
4951
:hover {
5052
background-color: #e9eaeb;

components/ChatScreen.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ function ChatScreen({ chat, messages }) {
114114
</HeaderInfo>
115115
<HeaderIcons>
116116
<IconButton>
117-
<AttachFileIcon />
117+
<AttachFileIcon style={{ fontSize: 25 }} />
118118
</IconButton>
119119
<IconButton>
120-
<MoreVertIcon />
120+
<MoreVertIcon style={{ fontSize: 25 }} />
121121
</IconButton>
122122
</HeaderIcons>
123123
</Header>
@@ -128,22 +128,29 @@ function ChatScreen({ chat, messages }) {
128128
</MessageContainer>
129129

130130
<InputContainer>
131-
<InsertEmoticonIcon />
132-
<Input value={input} onChange={(e) => setInput(e.target.value)} />
131+
<IconButton>
132+
<InsertEmoticonIcon style={{ fontSize: 25 }} />
133+
</IconButton>
134+
<Input
135+
value={input}
136+
onChange={(e) => setInput(e.target.value)}
137+
placeholder="Type a message..."
138+
autoFocus
139+
/>
133140
<button hidden disabled={!input} type="submit" onClick={sendMessage}>
134141
Send Message
135142
</button>
136-
<MicIcon />
143+
<IconButton>
144+
<MicIcon style={{ fontSize: 25 }} />
145+
</IconButton>
137146
</InputContainer>
138147
</Container>
139148
);
140149
}
141150

142151
export default ChatScreen;
143152

144-
const Container = styled.div`
145-
/* overflow: none; */
146-
`;
153+
const Container = styled.div``;
147154

148155
const Header = styled.div`
149156
position: sticky;
@@ -152,7 +159,7 @@ const Header = styled.div`
152159
top: 0;
153160
display: flex;
154161
padding: 1.1rem;
155-
height: 8rem;
162+
height: 7rem;
156163
align-items: center;
157164
border-bottom: 1px solid whitesmoke;
158165
`;
@@ -163,10 +170,12 @@ const HeaderInfo = styled.div`
163170
164171
> h3 {
165172
margin-bottom: 0.3rem;
173+
color: #495057;
174+
font-size: 1.35rem;
166175
}
167176
168177
> p {
169-
font-size: 1.4rem;
178+
font-size: 1.2rem;
170179
color: gray;
171180
}
172181
`;
@@ -197,9 +206,10 @@ const Input = styled.input`
197206
flex: 1;
198207
border: none;
199208
outline: none;
200-
border-radius: 1rem;
209+
border-radius: 3rem;
201210
align-items: center;
202-
padding: 2rem;
211+
padding: 1.3rem;
212+
font-size: 1.55rem;
203213
margin-left: 1.5rem;
204214
margin-right: 1.5rem;
205215
background-color: whitesmoke;

components/Message.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function Message({ user, message }) {
1515
<TimeStamp>
1616
{message.timestamp ? moment(message.timestamp).format('LT') : '...'}
1717
</TimeStamp>
18-
</TypeOfMessage>
18+
</TypeOfMessage>
1919
</Container>
2020
);
2121
}
@@ -33,6 +33,8 @@ const MessageElement = styled.p`
3333
padding-bottom: 2.6rem;
3434
position: relative;
3535
text-align: right;
36+
font-size: 1.3rem;
37+
word-break: break-all;
3638
`;
3739

3840
const Sender = styled(MessageElement)`

components/Sidebar.js

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Avatar, Button, IconButton } from '@material-ui/core';
1+
import { Avatar, IconButton } from '@material-ui/core';
22
import styled from 'styled-components';
33
import ChatIcon from '@material-ui/icons/Chat';
44
import MoreVertIcon from '@material-ui/icons/MoreVert';
@@ -8,6 +8,7 @@ import { useAuthState } from 'react-firebase-hooks/auth';
88
import { useCollection } from 'react-firebase-hooks/firestore';
99
import { auth, db } from '../firebase';
1010
import Chat from './Chat';
11+
import AddCircleRoundedIcon from '@material-ui/icons/AddCircleRounded';
1112

1213
function Sidebar() {
1314
const [user] = useAuthState(auth);
@@ -46,20 +47,28 @@ function Sidebar() {
4647

4748
<IconsContainer>
4849
<IconButton>
49-
<ChatIcon />
50+
<ChatIcon style={{ fontSize: 22 }} />
5051
</IconButton>
5152
<IconButton>
52-
<MoreVertIcon />
53+
<MoreVertIcon style={{ fontSize: 22 }} />
5354
</IconButton>
5455
</IconsContainer>
5556
</Header>
5657

5758
<Search>
58-
<SearchIcon />
59-
<SearchInput placeholder="Search in chats" />
59+
<SearchIcon style={{ fontSize: 22, marginRight: '1rem' }} />
60+
<SearchInput placeholder="Search for chats..." />
61+
{/* or Add Chat (s) by Gmail */}
6062
</Search>
6163

62-
<SidebarButton onClick={createChat}>Start a new chat</SidebarButton>
64+
<SidebarButton>
65+
{/* <IconButton> */}
66+
<AddCircleRoundedIcon
67+
style={{ fontSize: 58, color: '#25D366' }}
68+
onClick={createChat}
69+
/>
70+
{/* </IconButton> */}
71+
</SidebarButton>
6372

6473
{/* List of Chats */}
6574
{chatsSnapshot?.docs.map((chat) => (
@@ -78,6 +87,7 @@ const Container = styled.div`
7887
min-width: 30rem;
7988
max-width: 35rem;
8089
overflow-y: scroll;
90+
position: relative;
8191
8292
::-webkit-scrollbar {
8393
display: none;
@@ -94,18 +104,28 @@ const Search = styled.div`
94104
border-radius: 0.2rem;
95105
`;
96106

97-
const SidebarButton = styled(Button)`
98-
width: 100%;
99-
&&& {
100-
border-top: 1px solid whitesmoke;
101-
border-bottom: 1px solid whitesmoke;
102-
}
107+
const SidebarButton = styled.button`
108+
position: absolute;
109+
bottom: 1.85rem;
110+
right: 2rem;
111+
border-radius: 50%;
112+
width: 3rem;
113+
height: 3rem;
114+
border: none;
115+
outline: none;
116+
padding: 2.5rem;
117+
display: flex;
118+
align-items: center;
119+
justify-content: center;
120+
cursor: pointer;
121+
z-index: 100;
103122
`;
104123

105124
const SearchInput = styled.input`
106125
outline: none;
107126
border: none;
108127
flex: 1;
128+
font-size: 1.5rem;
109129
`;
110130

111131
const Header = styled.div`
@@ -117,7 +137,7 @@ const Header = styled.div`
117137
justify-content: space-between;
118138
align-items: center;
119139
padding: 1.5rem;
120-
height: 8rem;
140+
height: 7rem;
121141
border-bottom: 1px solid whitesmoke;
122142
`;
123143

pages/Loading.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// import Image from 'next/image';
2-
// import React from 'react';
31
import Image from 'next/image';
42
import { Circle } from 'better-react-spinkit';
53
import profilePic from '../public/580b57fcd9996e24bc43c543.png';

pages/Login.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { Button } from '@material-ui/core';
22
import Head from 'next/head';
3+
import Image from 'next/image';
34
import styled from 'styled-components';
45
import { auth, provider } from '../firebase';
6+
import googleIcon from '../public/icons8-google.svg';
57

68
function Login() {
79
const signIn = () => {
@@ -17,7 +19,8 @@ function Login() {
1719
<LoginContainer>
1820
<Logo src="https://assets.stickpng.com/images/580b57fcd9996e24bc43c543.png" />
1921
<Button onClick={signIn} variant="outlined">
20-
SignIn with Google
22+
<Image src={googleIcon} alt="Google Icon" width={25} height={25} />
23+
<ButtonText>SignIn with Google</ButtonText>
2124
</Button>
2225
</LoginContainer>
2326
</Container>
@@ -43,6 +46,12 @@ const LoginContainer = styled.div`
4346
box-shadow: 0px 4px 14px -3px rgba(0, 0, 0, 0.7);
4447
`;
4548

49+
const ButtonText = styled.span`
50+
margin-left: 1rem;
51+
font-size: 1.2rem;
52+
font-family: 'Inter', sans-serif;
53+
`;
54+
4655
const Logo = styled.img`
4756
height: 20rem;
4857
width: 20rem;

pages/chat/[id].js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@ import Sidebar from '../../components/Sidebar';
55
import { useAuthState } from 'react-firebase-hooks/auth';
66
import { auth, db } from '../../firebase';
77
import getRecipientEmail from '../../utils/getRecipientEmail';
8+
import { useRef } from 'react';
89

910
function Chat({ chat, messages }) {
1011
const [user] = useAuthState(auth);
1112

13+
const endOfMessagesRef = useRef(null);
14+
15+
const scrollToBottom = () => {
16+
endOfMessagesRef.current.scrollIntoView({
17+
behaviour: 'smooth',
18+
block: 'start',
19+
});
20+
};
21+
1222
return (
1323
<Container>
1424
<Head>
@@ -20,8 +30,9 @@ function Chat({ chat, messages }) {
2030
</title>
2131
</Head>
2232
<Sidebar />
23-
<ChatContainer>
33+
<ChatContainer onLoad={scrollToBottom}>
2434
<ChatScreen chat={chat} messages={messages} />
35+
<EndOfMessage ref={endOfMessagesRef} />
2536
</ChatContainer>
2637
</Container>
2738
);
@@ -68,7 +79,8 @@ const Container = styled.div`
6879

6980
const ChatContainer = styled.div`
7081
flex: 1;
71-
overflow: scroll;
82+
overflow-y: scroll;
83+
overflow-x: hidden;
7284
height: 100vh;
7385
7486
::-webkit-srollbar {
@@ -78,3 +90,5 @@ const ChatContainer = styled.div`
7890
-ms-overflow-style: none;
7991
scrollbar-width: none;
8092
`;
93+
94+
const EndOfMessage = styled.div``;

public/icons8-google.svg

Lines changed: 1 addition & 0 deletions
Loading

styles/globals.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');
2+
13
* {
24
margin: 0;
35
padding: 0;
@@ -15,6 +17,10 @@ html {
1517
font-size: 62.5%;
1618
}
1719

20+
body {
21+
font-family: 'Inter', sans-serif;
22+
}
23+
1824
a {
1925
color: inherit;
2026
text-decoration: none;

0 commit comments

Comments
 (0)