Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
156 changes: 95 additions & 61 deletions src/routes/Chat.css
Original file line number Diff line number Diff line change
@@ -1,71 +1,105 @@
.chat{
flex-direction: column;
display: flex;
padding:10px;
flex:0.35;

height:88vh;
.chat__window {
flex-direction: column;
display: flex;
padding: 10px;
flex: 0.35;
margin-top: 18px;
height: 80vh;
}
.chat__header{
padding:20px;
display: flex;
align-items: center;
border-bottom: 1px solid lightgray;
justify-content: space-between;
.chat__header {
padding: 20px;
display: flex;
align-items: center;
border-bottom: 1px solid lightgray;
justify-content: space-between;
background-color: #3f51b5;
color: #ececec;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.19);
font-size: 18px;
font-weight: 600;
}
.chat__body{
flex:1;
background-color:#d4fbff;
padding: 30px;
overflow: scroll !important;
.chat__body {
flex: 1;
background-color: #d4fbff;
padding: 30px;
overflow: scroll !important;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.19);
min-height: 60%;
}
.chat__message{
position: relative;
font-size: 16px;
padding:10px;
width: fit-content;
border-radius: 10px;
background-color: white;
margin-bottom: 30px;
.chat__message {
position: relative;
font-size: 16px;
padding: 10px;
width: fit-content;
border-radius: 10px;
background-color: white;
margin-bottom: 30px;
}
.chat__receiver{
position: relative;
font-size: 16px;
padding:10px;
margin-left: auto;
width: fit-content;
border-radius: 10px;
background-color: rgb(5, 51, 199);
margin-bottom: 30px;
color:white;
.chat__receiver {
position: relative;
font-size: 16px;
padding: 10px;
margin-left: auto;
width: fit-content;
border-radius: 10px;
background-color: rgb(5, 51, 199);
margin-bottom: 30px;
color: white;
}
.chat__timestamp{
margin-left: 10px;
font-size: xx-small;
.chat__timestamp {
margin-left: 10px;
font-size: xx-small;
}
.chat__name{
position:absolute;
top:-15px;
font-weight: 800;
font-size: xx-small;
color: black;

.chat__name {
position: absolute;
top: -15px;
font-weight: 800;
font-size: xx-small;
color: black;
}
.chat__footer{
display: flex;
align-items: center;
height: 60px;
border-top: 1px solid lightgray;
justify-content: space-between;
.chat__footer {
display: flex;
align-items: center;
height: 60px;
border-top: 1px solid lightgray;
justify-content: space-between;
background-color: #3f51b5;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.19);
}
.chat__footer>form>input{
flex:1 !important;
border-radius: 30px;
padding: 10px;
border: none;
width: 200px;
outline: none;
.chat__footer > form > input {
flex: 1 !important;
border-radius: 30px;
padding: 10px;
border: none;
width: 200px;
outline: none;
}
.chat__footer>form>button{
display: none;
.chat__footer > form > button {
display: none;
}
.chat__modal {
background-color: #3f51b5;
vertical-align: bottom;
text-align: center;
border-radius: 50%;
width: 70px;
height: 70px;
border: none;
margin-top: 10px;
bottom: 23px;
right: 28px;
cursor: pointer;
position: fixed;
}
.chat__modal > .MuiIconButton-root {
flex: 1;
padding: 33%;
}
.MuiSvgIcon-root {
color: #ececec;
}
.emoji__picker {
position: absolute;
bottom: 20px;
right: 20px;
}
47 changes: 36 additions & 11 deletions src/routes/Chat.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { useState ,useEffect,useRef} from 'react'
import './Chat.css'
import {Avatar,IconButton} from "@material-ui/core";
import {Avatar,IconButton, Button} from "@material-ui/core";
import EmojiEmotionsOutlinedIcon from '@material-ui/icons/EmojiEmotionsOutlined';
import AddIcCallOutlinedIcon from '@material-ui/icons/AddIcCallOutlined';
import ChatBubbleOutline from '@material-ui/icons/ChatBubbleOutline';
import AttachFile from '@material-ui/icons/AttachFile';
import { CookiesProvider, Cookies,useCookies } from 'react-cookie';
import io from "socket.io-client";
import axios from "axios";
Expand All @@ -17,14 +18,15 @@ function Chat(props) {
const [messages,setMessages]=useState([]);
console.log("Test");

const url = (process.env.NODE_ENV==="production" ? "https://thawing-dawn-49846.herokuapp.com/" : "http://localhost:5000/");
// const url = (process.env.NODE_ENV==="production" ? "https://thawing-dawn-49846.herokuapp.com/" : "http://localhost:5000/");
const url = "https://thawing-dawn-49846.herokuapp.com/"
console.log(process.env.NODE_ENV,url);

const userDetail={
room:props.roomID,
name:userCookie.name,
GID:userCookie.GID,
imgURI:"123"
imgURI:userCookie.url
}

window.onbeforeunload =()=>{
Expand Down Expand Up @@ -55,7 +57,15 @@ function Chat(props) {
},[]);



const toggleChat = ()=>{
var disp = document.querySelector('.chat__window').style.display;
if(disp === 'none')
{
document.querySelector('.chat__window').style.display = 'flex';
}
else
document.querySelector('.chat__window').style.display = 'none';
}
const sendMessage = (e)=>{
e.preventDefault();
const obj={
Expand All @@ -76,10 +86,12 @@ function Chat(props) {


return (

<div className = 'chat'>
<div className = 'chat__window'>
<div className="chat__header">
<Avatar src = ""/>
<p>Room Name</p>
<p>General Chat</p>
</div>

<div className="chat__body">
Expand All @@ -103,12 +115,25 @@ function Chat(props) {
</input>
<button onClick = {sendMessage} type = 'submit'>Send message</button>
</form>
<IconButton>
<AddIcCallOutlinedIcon></AddIcCallOutlinedIcon>
</IconButton>
<input type='file' multiple hidden id = 'file'></input>
<label htmlFor='file'>
<IconButton color = 'primary' component = "span">
<AttachFile>
</AttachFile>
</IconButton>
</label>


</div>


</div>
<div className='chat__modal' onClick={toggleChat}>
<IconButton>
<ChatBubbleOutline/>
</IconButton>
</div>

</div>
</div>
)
}

Expand Down