diff --git a/src/App.css b/src/App.css
index d97beb4e6..ae0150c40 100644
--- a/src/App.css
+++ b/src/App.css
@@ -1,5 +1,5 @@
#App {
- background-color: #87cefa;
+ background: #87cefa;
}
#App header {
@@ -26,8 +26,10 @@
display: inline-block;
}
+
#App header section {
background-color: #e0ffff;
+ color: black;
}
#App .widget {
diff --git a/src/App.js b/src/App.js
index c10859093..cbde5278b 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,16 +1,40 @@
import React from 'react';
+import { useState } from 'react';
import './App.css';
import chatMessages from './data/messages.json';
+import ChatLog from './components/ChatLog';
const App = () => {
+ const [messages, setMessages] = useState(chatMessages);
+
+ const toggleLike = (id) => {
+ setMessages(
+ messages.map((message) =>
+ message.id === id ? { ...message, liked: !message.liked } : message
+ )
+ );
+ };
+
+ const countLikes = () => {
+ let heartCount = 0;
+ for (let message of messages) {
+ if (message.liked) {
+ heartCount += 1;
+ }
+ }return heartCount;
+ };
+
+
return (
- Application title
+ Waiting for Chat GDT
+
- {/* 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..744b38366 100644
--- a/src/components/ChatEntry.css
+++ b/src/components/ChatEntry.css
@@ -26,6 +26,7 @@ button {
width: fit-content;
}
+
.chat-entry .entry-bubble:hover {
background-color: #fefea2;
}
diff --git a/src/components/ChatEntry.js b/src/components/ChatEntry.js
index b92f0b7b2..d43f82058 100644
--- a/src/components/ChatEntry.js
+++ b/src/components/ChatEntry.js
@@ -1,22 +1,41 @@
import React from 'react';
import './ChatEntry.css';
import PropTypes from 'prop-types';
+import TimeStamp from './TimeStamp';
-const ChatEntry = (props) => {
+const ChatEntry = ({id, sender, body, timeStamp, liked, toggleLike}) => {
+ const handleLikeClick = () => {
+ toggleLike(id);
+ };
+
+const localOrRemote = (sender) => {
+if (sender === 'Vladimir') {
+ return 'chat-entry local';
+} else if (sender === 'Estragon') {
+ return 'chat-entry remote';
+};
+};
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.isRequired,
+ body: PropTypes.string.isRequired,
+ sender: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string.isRequired,
+ liked: PropTypes.bool,
+ toggleLike: PropTypes.func,
};
export default ChatEntry;
diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js
new file mode 100644
index 000000000..eeef27d1b
--- /dev/null
+++ b/src/components/ChatLog.js
@@ -0,0 +1,42 @@
+import './ChatEntry.css'
+import ChatEntry from './ChatEntry';
+import PropTypes from 'prop-types';
+
+
+const Chatlog = ({entries, toggleLike}) => {
+ const getEntries = () => {
+ return entries.map((entry, index) => {
+ return (
+
+ );
+ });
+}
+ return
+
+
+};
+
+Chatlog.propTypes = {
+ entries: PropTypes.arrayOf (
+ PropTypes.shape (
+ {
+ sender: PropTypes.string.isRequired,
+ body: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string.isRequired,
+ liked: PropTypes.bool,
+ })
+ ).isRequired,
+ toggleLike: PropTypes.func,
+};
+
+export default Chatlog;
\ No newline at end of file