Spaces:
Runtime error
Runtime error
Commit
·
6d4dede
1
Parent(s):
791dd65
added messages
Browse files
src/components/Chat/Chat.css
CHANGED
|
@@ -7,5 +7,5 @@
|
|
| 7 |
|
| 8 |
.chat_main{
|
| 9 |
flex-grow:1;
|
| 10 |
-
background-color: white;
|
| 11 |
}
|
|
|
|
| 7 |
|
| 8 |
.chat_main{
|
| 9 |
flex-grow:1;
|
| 10 |
+
background-color: white;
|
| 11 |
}
|
src/components/ChatMain/ChatMain.css
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.chat_main{
|
| 2 |
+
padding:2em;
|
| 3 |
+
display:flex;
|
| 4 |
+
flex-direction: column;
|
| 5 |
+
gap:20px;
|
| 6 |
+
}
|
src/components/ChatMain/ChatMain.jsx
CHANGED
|
@@ -1,13 +1,25 @@
|
|
| 1 |
import React from 'react'
|
| 2 |
import Message from '../Message';
|
|
|
|
| 3 |
|
| 4 |
function ChatMain() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
return (
|
| 6 |
<div className='chat_main'>
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
</div>
|
| 12 |
)
|
| 13 |
}
|
|
|
|
| 1 |
import React from 'react'
|
| 2 |
import Message from '../Message';
|
| 3 |
+
import "./ChatMain.css";
|
| 4 |
|
| 5 |
function ChatMain() {
|
| 6 |
+
|
| 7 |
+
const getMessages = () => {
|
| 8 |
+
|
| 9 |
+
var messages = [];
|
| 10 |
+
for (var i = 0; i < 10; i++) {
|
| 11 |
+
messages.push(<Message message={"Hello"} time="10AM" isReceived={false} />);
|
| 12 |
+
}
|
| 13 |
+
return messages;
|
| 14 |
+
}
|
| 15 |
return (
|
| 16 |
<div className='chat_main'>
|
| 17 |
+
{/* {
|
| 18 |
+
getMessages()
|
| 19 |
+
} */}
|
| 20 |
+
<Message message={"Hi"} time="11AM" isReceived={true} />
|
| 21 |
+
<Message message={"How are you"} time="11:10AM" isReceived={false} />
|
| 22 |
+
<Message message={"I am good what about you..."} time="11AM" isReceived={true} />
|
| 23 |
</div>
|
| 24 |
)
|
| 25 |
}
|
src/components/Contacts/Contacts.jsx
CHANGED
|
@@ -15,7 +15,7 @@ function Contacts() {
|
|
| 15 |
lastmessage={"Well this is a long messageWell this is a long messageWell this is a long messageWell this is a long messageWell this is a long messageWell this is a long messageWell this is a long messageWell this is a long message"}
|
| 16 |
/>
|
| 17 |
<Contact profile_pic={"logo512.png"} name={"anuj"} lastmessage={"good morning"}/>
|
| 18 |
-
<Contact profile_pic={"logo512.png"} name={"anuj"} lastmessage={"good morning"} />
|
| 19 |
</div>
|
| 20 |
)
|
| 21 |
}
|
|
|
|
| 15 |
lastmessage={"Well this is a long messageWell this is a long messageWell this is a long messageWell this is a long messageWell this is a long messageWell this is a long messageWell this is a long messageWell this is a long message"}
|
| 16 |
/>
|
| 17 |
<Contact profile_pic={"logo512.png"} name={"anuj"} lastmessage={"good morning"}/>
|
| 18 |
+
<Contact profile_pic={"logo512.png"} name={"anuj"} lastmessage={"good morning"} isActive/>
|
| 19 |
</div>
|
| 20 |
)
|
| 21 |
}
|
src/components/Message/Message.css
CHANGED
|
@@ -2,12 +2,25 @@
|
|
| 2 |
width:100%;
|
| 3 |
display:flex;
|
| 4 |
flex-direction: column;
|
|
|
|
| 5 |
align-items: end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
}
|
| 7 |
|
| 8 |
.message__content{
|
| 9 |
-
width:
|
| 10 |
-
background-color:
|
|
|
|
|
|
|
|
|
|
| 11 |
}
|
| 12 |
|
| 13 |
.message__time{
|
|
|
|
| 2 |
width:100%;
|
| 3 |
display:flex;
|
| 4 |
flex-direction: column;
|
| 5 |
+
gap:5px;
|
| 6 |
align-items: end;
|
| 7 |
+
|
| 8 |
+
/* border: 2px dotted gray; */
|
| 9 |
+
}
|
| 10 |
+
.message.left{
|
| 11 |
+
align-items: start;
|
| 12 |
+
}
|
| 13 |
+
.message.left .message__content{
|
| 14 |
+
background-color: var(--RECEIVED-MSG-BG);
|
| 15 |
+
color:var(--RECEIVED-MSG-COLOR);
|
| 16 |
}
|
| 17 |
|
| 18 |
.message__content{
|
| 19 |
+
max-width:400px;
|
| 20 |
+
background-color:rgb(224, 224, 224);
|
| 21 |
+
color:rgb(113, 113, 113);
|
| 22 |
+
padding:1em 2em;
|
| 23 |
+
border-radius: 10px;
|
| 24 |
}
|
| 25 |
|
| 26 |
.message__time{
|
src/components/Message/Message.jsx
CHANGED
|
@@ -3,14 +3,14 @@ import "./Message.css";
|
|
| 3 |
function Message({
|
| 4 |
message,
|
| 5 |
time,
|
| 6 |
-
isReceived=false,
|
| 7 |
}) {
|
| 8 |
return (
|
| 9 |
|
| 10 |
-
<div className={"message "+
|
| 11 |
<div className='message__content'>{message}</div>
|
| 12 |
<span className='message__time'>{time}</span>
|
| 13 |
-
|
| 14 |
)
|
| 15 |
}
|
| 16 |
|
|
|
|
| 3 |
function Message({
|
| 4 |
message,
|
| 5 |
time,
|
| 6 |
+
isReceived = false,
|
| 7 |
}) {
|
| 8 |
return (
|
| 9 |
|
| 10 |
+
<div className={"message " +(isReceived ? "left" : "")}>
|
| 11 |
<div className='message__content'>{message}</div>
|
| 12 |
<span className='message__time'>{time}</span>
|
| 13 |
+
</div>
|
| 14 |
)
|
| 15 |
}
|
| 16 |
|
src/index.css
CHANGED
|
@@ -17,4 +17,7 @@ body {
|
|
| 17 |
--PRIMARY-COLOR: rgb(115, 40, 214);
|
| 18 |
--SECONDARY-COLOR:#FFF;
|
| 19 |
--BORDER-COLOR:rgb(227, 225, 225);
|
|
|
|
|
|
|
|
|
|
| 20 |
}
|
|
|
|
| 17 |
--PRIMARY-COLOR: rgb(115, 40, 214);
|
| 18 |
--SECONDARY-COLOR:#FFF;
|
| 19 |
--BORDER-COLOR:rgb(227, 225, 225);
|
| 20 |
+
|
| 21 |
+
--RECEIVED-MSG-BG:rgb(253, 213, 220);
|
| 22 |
+
--RECEIVED-MSG-COLOR:rgb(217, 118, 135);
|
| 23 |
}
|