diff --git a/src/App.css b/src/App.css
index d97beb4e6..5b474f32a 100644
--- a/src/App.css
+++ b/src/App.css
@@ -42,7 +42,8 @@
#App #heartWidget {
font-size: 1.5em;
- margin: 1em
+ margin: 1em;
+ color: black
}
#App span {
diff --git a/src/App.js b/src/App.js
index c10859093..28b6a67da 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,16 +1,30 @@
-import React from 'react';
+import React, { useState } from 'react';
import './App.css';
+import ChatEntry from './components/ChatEntry';
+import ChatLog from './components/ChatLog';
import chatMessages from './data/messages.json';
const App = () => {
+ // console.log(chatMessages);
+
+ // const [likedMap, setLikedMap] = useState({})
+ const [likedCount, setLikedCount] = useState(0);
+
+ const addLike = () => setLikedCount(likedCount + 1);
+ const removeLike = () => setLikedCount(likedCount - 1);
+
return (
- Application title
+ Chat between Vladimir and Estragon
+
- {/* Wave 01: Render one ChatEntry component
- Wave 02: Render ChatLog component */}
+
);
diff --git a/src/components/ChatEntry.js b/src/components/ChatEntry.js
index b92f0b7b2..473fc6035 100644
--- a/src/components/ChatEntry.js
+++ b/src/components/ChatEntry.js
@@ -1,22 +1,44 @@
-import React from 'react';
+import { React, useState } from 'react';
import './ChatEntry.css';
import PropTypes from 'prop-types';
+import TimeStamp from './TimeStamp';
+
+const ChatEntry = ({ sender, body, timeStamp, liked, addLike, removeLike }) => {
+ const [like, setLike] = useState(liked);
+
+ const handleOnClick = () => {
+ if (like) {
+ removeLike();
+ } else {
+ addLike();
+ }
+
+ setLike(!like);
+ };
-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
+ sender: PropTypes.string.isRequired,
+ body: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string.isRequired,
+ liked: PropTypes.bool,
+ addLike: PropTypes.func,
+ removeLike: PropTypes.func,
};
export default ChatEntry;
diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js
new file mode 100644
index 000000000..e8dfdc52f
--- /dev/null
+++ b/src/components/ChatLog.js
@@ -0,0 +1,39 @@
+import React from 'react';
+import './ChatLog.css';
+import PropTypes from 'prop-types';
+import ChatEntry from './ChatEntry';
+
+const ChatLog = ({ entries, addLike, removeLike }) => {
+ return (
+
+ {entries.map((message) => {
+ return (
+
+ );
+ })}
+
+ );
+};
+
+ChatLog.propTypes = {
+ entries: PropTypes.arrayOf(
+ PropTypes.shape({
+ sender: PropTypes.string.isRequired,
+ body: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string.isRequired,
+ liked: PropTypes.bool,
+ })
+ ).isRequired,
+ addLike: PropTypes.func,
+ removeLike: PropTypes.func,
+};
+
+export default ChatLog;