diff --git a/src/App.css b/src/App.css
index d97beb4e6..25013a9ab 100644
--- a/src/App.css
+++ b/src/App.css
@@ -46,7 +46,7 @@
}
#App span {
- display: inline-block
+ display: inline-block;
}
.red {
@@ -71,4 +71,20 @@
.purple {
color: purple
+}
+
+.numberOfLikes {
+ background-color: aliceblue;
+}
+
+.numberLikes {
+ color: black;
+}
+
+.vladimir_sub_header {
+
+}
+
+.estragon_sub_header {
+
}
\ No newline at end of file
diff --git a/src/App.js b/src/App.js
index c10859093..f278828b6 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,16 +1,37 @@
-import React from 'react';
+import React, {useState} from 'react';
import './App.css';
+import ChatLog from './components/ChatLog';
import chatMessages from './data/messages.json';
const App = () => {
+ const [chatEntries, setChatEntries] = useState(chatMessages);
+ const [numberLikes, setNumberLikes] = useState(0);
+
+ const updateChatEntry = (chatToUpdate) => {
+ const chats = chatEntries.map((entry) => {
+ if(entry.id === chatToUpdate.id){
+ setNumberLikes(chatToUpdate.liked ? numberLikes+1 : numberLikes-1)
+ return chatToUpdate;
+ }
+ return entry;
+ });
+ setChatEntries(chats);
+ };
+
return (
- {/* Wave 01: Render one ChatEntry component
- Wave 02: Render ChatLog component */}
+
);
diff --git a/src/components/ChatEntry.css b/src/components/ChatEntry.css
index 05c3baa44..54116a818 100644
--- a/src/components/ChatEntry.css
+++ b/src/components/ChatEntry.css
@@ -17,6 +17,7 @@ button {
}
.chat-entry .entry-bubble {
+ color: green;
background-color: #ffffe0;
border-radius: 30px;
max-width: 50rem;
@@ -80,6 +81,7 @@ button {
background-color: #e0ffff;
margin-left: auto;
margin-right: 0;
+ color: blue;
}
.chat-entry.remote .entry-bubble:hover {
diff --git a/src/components/ChatEntry.js b/src/components/ChatEntry.js
index b92f0b7b2..c23bf766b 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 = ({id, sender, body, timeStamp, onUpdateChat, liked}) => {
+ const updateClickState = () => {
+ onUpdateChat({
+ id,
+ sender,
+ body,
+ timeStamp,
+ liked : !liked
+ })
+ }
+ const heartStyle = liked ? '❤️' : '🤍';
+ let entryClass = ''
+
+ if(sender === 'Vladimir'){
+ entryClass = 'local';
+ }else{
+ entryClass = 'remote';
+ }
-const ChatEntry = (props) => {
return (
-
-
Replace with name of sender
+
+
{sender}
- Replace with body of ChatEntry
- Replace with TimeStamp component
-
+ {body}
+
+
- );
-};
+ )};
ChatEntry.propTypes = {
- //Fill with correct proptypes
+ id: PropTypes.number,
+ sender: PropTypes.string,
+ body: PropTypes.string,
+ timeStamp: PropTypes.string,
+ liked: PropTypes.bool,
+ onUpdateChat:PropTypes.func
};
export default ChatEntry;
diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js
new file mode 100644
index 000000000..f55b5528e
--- /dev/null
+++ b/src/components/ChatLog.js
@@ -0,0 +1,35 @@
+import PropTypes from 'prop-types';
+import ChatEntry from './ChatEntry';
+import './ChatLog.css';
+
+const ChatLog = ({entries, onUpdateChat}) => {
+ const messages = entries.map((message, index) => {
+ return(
+
+ );
+ });
+ return(messages);
+};
+
+ChatLog.propTypes = {
+ entries: PropTypes.arrayOf(
+ PropTypes.shape({
+ id: PropTypes.number,
+ sender: PropTypes.string,
+ body: PropTypes.string,
+ timeStamp: PropTypes.string,
+ liked: PropTypes.bool,
+ onUpdateChat:PropTypes.func
+ })).isRequired
+}
+
+export default ChatLog
\ No newline at end of file