diff --git a/src/App.css b/src/App.css
index d97beb4e6..99675b3fb 100644
--- a/src/App.css
+++ b/src/App.css
@@ -24,17 +24,18 @@
font-size: 1.5em;
text-align: center;
display: inline-block;
+
}
#App header section {
- background-color: #e0ffff;
+ background-color: #222;
}
#App .widget {
display: inline-block;
line-height: 0.5em;
border-radius: 10px;
- color: black;
+ color:rgb(rgb(21, 138, 233), green, blue);
font-size:0.8em;
padding-left: 1em;
padding-right: 1em;
@@ -43,6 +44,7 @@
#App #heartWidget {
font-size: 1.5em;
margin: 1em
+
}
#App span {
diff --git a/src/App.js b/src/App.js
index c10859093..74815a26a 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,16 +1,51 @@
import React from 'react';
import './App.css';
+import ChatLog from './components/ChatLog';
import chatMessages from './data/messages.json';
+import { useState } from 'react';
+let numberOfLikes = 0;
const App = () => {
+ const [MessageData, setMessageData] = useState(chatMessages)
+
+ const updateMessageData = updatedChatEntry =>{
+ const entries = MessageData.map((chat) => {
+ if(chat.id === updatedChatEntry.id){
+ numberOfLikes = updatedChatEntry.liked ? numberOfLikes+1 : numberOfLikes-1;
+ return updatedChatEntry;
+ } else {
+ return chat;
+ }
+ });
+ setMessageData(entries);
+ };
+
return (
- Application title
+ Chat between VLadimir and Estragon
+
+
+ {numberOfLikes} ❤️s
+
+
+
- {/* Wave 01: Render one ChatEntry component
- Wave 02: Render ChatLog component */}
+
+ {/* Wave 01 */}
+ {/*
+ */}
+
+
+
+
);
diff --git a/src/components/ChatEntry.css b/src/components/ChatEntry.css
index 05c3baa44..bd15892e9 100644
--- a/src/components/ChatEntry.css
+++ b/src/components/ChatEntry.css
@@ -56,15 +56,19 @@ button {
/* "local" messages are shown on the left side */
.chat-entry.local {
text-align: left;
+ color:green;
}
+
.chat-entry.local .entry-time {
text-align: right;
+ color:green
}
.chat-entry.local .entry-bubble::before {
background-color: #ffffe0;
left: -18px;
+
}
.chat-entry.local .entry-bubble:hover::before {
@@ -74,20 +78,24 @@ button {
/* "remote" messages are shown on the right side, in blue */
.chat-entry.remote {
text-align: right;
+ color: blue
}
.chat-entry.remote .entry-bubble {
background-color: #e0ffff;
margin-left: auto;
margin-right: 0;
+ color: blue;
}
.chat-entry.remote .entry-bubble:hover {
background-color: #a9f6f6;
+ color: blue;
}
.chat-entry.remote .entry-time {
text-align: left;
+ color: blue;
}
.chat-entry.remote .entry-bubble::before {
diff --git a/src/components/ChatEntry.js b/src/components/ChatEntry.js
index b92f0b7b2..fae9b6a96 100644
--- a/src/components/ChatEntry.js
+++ b/src/components/ChatEntry.js
@@ -1,22 +1,44 @@
import React from 'react';
import './ChatEntry.css';
import PropTypes from 'prop-types';
+import TimeStamp from './TimeStamp';
const ChatEntry = (props) => {
+ const onFlipHeartClick = () => {
+
+ const updatedChatEntry = {
+ id : props.id,
+ sender : props.sender,
+ body : props.body,
+ timeStamp : props.timeStamp,
+ liked : !props.liked
+ };
+ props.onUpdate(updatedChatEntry);
+ };
+ const HeartColor = props.liked ? '❤️':'🤍';
return (
-
-
Replace with name of sender
+
+
{props.sender}
- Replace with body of ChatEntry
- Replace with TimeStamp component
-
+ {props.body}
+
+
+
);
};
ChatEntry.propTypes = {
- //Fill with correct proptypes
+ id: PropTypes.number,
+ sender: PropTypes.string,
+ body: PropTypes.string,
+ timeStamp: PropTypes.string,
+ liked: PropTypes.bool,
+ onUpdate: PropTypes.func,
};
export default ChatEntry;
diff --git a/src/components/ChatEntry.test.js b/src/components/ChatEntry.test.js
index b69270c03..664e422e0 100644
--- a/src/components/ChatEntry.test.js
+++ b/src/components/ChatEntry.test.js
@@ -21,7 +21,7 @@ describe("Wave 01: ChatEntry", () => {
test("that it will display the body", () => {
expect(screen.getByText(/Get out by 8am/)).toBeInTheDocument();
});
-
+
test("that it will display the time", () => {
expect(screen.getByText(/\d+ years ago/)).toBeInTheDocument();
});
diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js
new file mode 100644
index 000000000..9e6e950b7
--- /dev/null
+++ b/src/components/ChatLog.js
@@ -0,0 +1,44 @@
+import React from 'react';
+import './ChatLog.css';
+import PropTypes from 'prop-types';
+import ChatEntry from './ChatEntry';
+
+const ChatLog = (props) => {
+ const chatentryComponents =props.entries.map((chat,index)=>{
+ return (
+
+
+
+ );
+ });
+ return (
+
+ Chat
+
+ {chatentryComponents};
+
+
+ );
+};
+
+ChatLog.propTypes = {
+ entries: PropTypes.arrayOf(PropTypes.shape({
+ id:PropTypes.number,
+ sender: PropTypes.string,
+ body: PropTypes.string,
+ timeStamp: PropTypes.string,
+ liked: PropTypes.bool,
+ })
+ ).isRequired,
+
+ onUpdatechat: PropTypes.func
+};
+
+export default ChatLog;
\ No newline at end of file