diff --git a/src/App.css b/src/App.css
index d97beb4e6..439a81e37 100644
--- a/src/App.css
+++ b/src/App.css
@@ -1,5 +1,5 @@
#App {
- background-color: #87cefa;
+ background-color: #E6E6FA;
}
#App header {
diff --git a/src/App.js b/src/App.js
index c10859093..8b1032496 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,16 +1,51 @@
import React from 'react';
import './App.css';
+// import ChatEntry from './components/ChatEntry';
+import ChatLog from './components/ChatLog';
import chatMessages from './data/messages.json';
+import { useState } from 'react';
const App = () => {
+ const [entries, setEntries] = useState(chatMessages)
+
+ const updateMessages = (updatedMessage) => {
+ const messages = entries.map(message => {
+ if (message.id === updatedMessage.id) {
+ return updatedMessage;
+ }
+ else {
+ return message
+ }
+ });
+ setEntries(messages);
+ };
+
+ const totalLikes = (entries) => {
+ let likes = 0
+ for (let message of entries){
+ if (message.liked === true){
+ likes +=1;
+ }
+ }
+ return `${likes} ❤️s`;
+ };
+
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.isRequired,
+ body: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string.isRequired,
+ liked: PropTypes.bool,
+ onToggleLike : PropTypes.func,
};
export default ChatEntry;
diff --git a/src/components/ChatLog.css b/src/components/ChatLog.css
index 378848d1f..dfba563dd 100644
--- a/src/components/ChatLog.css
+++ b/src/components/ChatLog.css
@@ -2,3 +2,7 @@
margin: auto;
max-width: 50rem;
}
+
+.chat-log ul{
+ list-style: none;
+}
\ No newline at end of file
diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js
new file mode 100644
index 000000000..bd951684d
--- /dev/null
+++ b/src/components/ChatLog.js
@@ -0,0 +1,37 @@
+import React from 'react';
+import './ChatLog.css';
+import ChatEntry from './ChatEntry';
+import PropTypes from 'prop-types';
+
+const ChatLog = (props) => {
+ const entryComponants = props.entries.map((message, index) => {
+ return(
+
+
+
+ );
+ });
+
+ return (
+
+
+ );
+};
+
+ChatLog.propTypes = {
+ entries: PropTypes.array.isRequired,
+ onToggleLike: PropTypes.func,
+};
+
+export default ChatLog;
\ No newline at end of file