diff --git a/src/App.css b/src/App.css
index d97beb4e6..a1c8fa4db 100644
--- a/src/App.css
+++ b/src/App.css
@@ -38,11 +38,13 @@
font-size:0.8em;
padding-left: 1em;
padding-right: 1em;
+ padding-top: 0.5em;
+ padding-bottom: 0.5em;
}
#App #heartWidget {
- font-size: 1.5em;
- margin: 1em
+ font-size: 1em;
+ margin: 1em;
}
#App span {
diff --git a/src/App.jsx b/src/App.jsx
index 14a7f684d..b972e3bdf 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,14 +1,30 @@
+import { useState } from 'react';
+import ChatLog from './components/ChatLog';
+import messages from './data/messages.json';
import './App.css';
const App = () => {
+ const [chatData, setChatData] = useState(messages);
+
+ const toggleLike = (id) => {
+ setChatData(chatData.map((message) => {
+ if (message.id === id) {
+ return { ...message, liked: !message.liked };
+ }
+ return message;
+ }));
+ };
+
return (
- Application title
+ Camille's Chatroom
+
- {/* Wave 01: Render one ChatEntry component
- Wave 02: Render ChatLog component */}
+
);
diff --git a/src/components/ChatEntry.jsx b/src/components/ChatEntry.jsx
index 15c56f96b..e76eedb4b 100644
--- a/src/components/ChatEntry.jsx
+++ b/src/components/ChatEntry.jsx
@@ -1,20 +1,33 @@
+import PropTypes from 'prop-types';
+import TimeStamp from './TimeStamp'
import './ChatEntry.css';
-const ChatEntry = () => {
+const ChatEntry = (props) => {
+ const heartColor = props.liked ? '❤️' : '🤍';
+
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.isRequired,
+ sender: PropTypes.string.isRequired,
+ body: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string.isRequired,
+ liked: PropTypes.bool.isRequired,
+ onLike: PropTypes.func.isRequired,
};
export default ChatEntry;
diff --git a/src/components/ChatLog.jsx b/src/components/ChatLog.jsx
new file mode 100644
index 000000000..15617630d
--- /dev/null
+++ b/src/components/ChatLog.jsx
@@ -0,0 +1,40 @@
+import PropTypes from "prop-types";
+import ChatEntry from "./ChatEntry";
+import "./ChatLog.css";
+
+const ChatLog = (props) => {
+ const chatEntries = props.entries.map((entry) => {
+ return (
+
+ );
+ });
+
+ return (
+
+ {chatEntries}
+
+ );
+};
+
+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,
+ })
+ ).isRequired,
+ onLike: PropTypes.func.isRequired,
+};
+
+export default ChatLog;
\ No newline at end of file