diff --git a/src/App.css b/src/App.css
index d97beb4e6..bdb584363 100644
--- a/src/App.css
+++ b/src/App.css
@@ -71,4 +71,8 @@
.purple {
color: purple
-}
\ No newline at end of file
+}
+
+/* button like {
+
+} */
\ No newline at end of file
diff --git a/src/App.js b/src/App.js
index c10859093..9696aec88 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,16 +1,35 @@
-import React from 'react';
+import React, {useState} from 'react';
import './App.css';
-import chatMessages from './data/messages.json';
+import ChatLog from './components/ChatLog';
+import HeartCounter from './components/HeartCounter'
+import messagesJSON from './data/messages.json'
const App = () => {
+ const [messageData, setMessageData] = useState(messagesJSON);
+
+ const toggleLiked = (id) => {
+ const messages = messageData.map((message) => {
+ if (message.id === id) {
+ message.liked = !message.liked;
+ }
+ return message;
+ });
+
+ setMessageData(messages);
+ }
+
+ const totalLikes = messagesJSON.filter(message => message.liked).length;
+
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,
+ sender: PropTypes.string.isRequired,
+ body: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string.isRequired,
+ isLiked: PropTypes.bool.isRequired,
+ onLikeMessage: PropTypes.func.isRequired,
};
export default ChatEntry;
+
diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js
new file mode 100644
index 000000000..1a58af409
--- /dev/null
+++ b/src/components/ChatLog.js
@@ -0,0 +1,38 @@
+import React from 'react';
+import ChatEntry from './ChatEntry';
+import PropTypes from 'prop-types';
+import './ChatLog.css';
+
+const ChatLog = ({entries, onLikeMessage}) => {
+ const chatComponents = entries.map((message) => {
+ return (
+
+
+
+ );
+ });
+
+ return (
)
+};
+
+ChatLog.propTypes = {
+ entries: PropTypes.arrayOf(PropTypes.shape({
+ id: PropTypes.number.isRequired,
+ sender: PropTypes.string.isRequired,
+ body: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string.isRequired,
+ liked: PropTypes.bool.isRequired
+ })),
+ onLikeMessage: PropTypes.func.isRequired,
+};
+
+export default ChatLog;
\ No newline at end of file
diff --git a/src/components/HeartCounter.js b/src/components/HeartCounter.js
new file mode 100644
index 000000000..bcc7635fe
--- /dev/null
+++ b/src/components/HeartCounter.js
@@ -0,0 +1,19 @@
+import '../App.css';
+import PropTypes from 'prop-types';
+
+const HeartCounter = (props) => {
+
+ return (
+
+
+ {props.likeTotal} ❤️s
+
+
+ );
+};
+
+HeartCounter.propTypes = {
+ likeTotal: PropTypes.number.isRequired,
+};
+
+export default HeartCounter;
\ No newline at end of file
diff --git a/src/components/LikeButton.js b/src/components/LikeButton.js
new file mode 100644
index 000000000..e0e789240
--- /dev/null
+++ b/src/components/LikeButton.js
@@ -0,0 +1,17 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+
+const LikeButton = (props) => {
+ if (props.heartCondition) {
+ return
+ } else {
+ return
+ };
+};
+
+LikeButton.propTypes = {
+ heartCondition: PropTypes.bool.isRequired,
+ updateLike: PropTypes.func.isRequired
+}
+
+export default LikeButton;
\ No newline at end of file