diff --git a/src/App.css b/src/App.css
index d97beb4e6..b5f2a5503 100644
--- a/src/App.css
+++ b/src/App.css
@@ -28,6 +28,7 @@
#App header section {
background-color: #e0ffff;
+ color: black;
}
#App .widget {
@@ -71,4 +72,10 @@
.purple {
color: purple
+}
+
+.colorSection {
+ display: flex;
+ flex-flow: row;
+ justify-content: center;
}
\ No newline at end of file
diff --git a/src/App.js b/src/App.js
index c10859093..44d9eb32e 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,16 +1,65 @@
import React from 'react';
import './App.css';
import chatMessages from './data/messages.json';
+import ChatLog from './components/ChatLog';
+import { useState } from 'react';
+import ColorChoice from './components/ColorChoice';
const App = () => {
+ const [chatData, setChatData] = useState(chatMessages);
+ const [localColor, setLocalColor] = useState('green');
+ const [remoteColor, setRemoteColor] = useState('blue');
+
+ const onUpdateLikes = (entryToUpdate) => {
+ const entries = chatData.map((entry) => {
+ if (entry.id === entryToUpdate.id) {
+ return entryToUpdate;
+ }
+ return entry;
+ });
+ setChatData(entries);
+ };
+
+ const calcTotalLikes = (Data) => {
+ let totalLikes = 0;
+ for (const chat of Data) {
+ if (chat.liked) {
+ totalLikes += 1;
+ }
+ }
+ return totalLikes;
+ };
+
+const totalLikeCount = calcTotalLikes(chatData);
+
+const updateLocalColor = (color) => {
+ setLocalColor(color);
+}
+
+const updateRemoteColor = (color) => {
+ setRemoteColor(color);
+}
+
+
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,
+ liked: PropTypes.bool.isRequired,
+ onUpdateLikes: PropTypes.func
};
+
export default ChatEntry;
diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js
new file mode 100644
index 000000000..d5d77d03c
--- /dev/null
+++ b/src/components/ChatLog.js
@@ -0,0 +1,41 @@
+import React from 'react';
+import './ChatLog.css';
+import PropTypes from 'prop-types';
+import ChatEntry from './ChatEntry';
+
+const ChatLog = ({ entries, onUpdateLikes, localColor, remoteColor}) => {
+ const chatEntryComponents = entries.map((entry) => {
+ return (
+
+ );
+});
+return (
+
+ {chatEntryComponents}
+
+);
+};
+
+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,
+ onUpdateLikes: PropTypes.func
+};
+
+export default ChatLog;
\ No newline at end of file
diff --git a/src/components/ColorChoice.js b/src/components/ColorChoice.js
new file mode 100644
index 000000000..af96babe0
--- /dev/null
+++ b/src/components/ColorChoice.js
@@ -0,0 +1,20 @@
+import React from 'react';
+
+const ColorChoice = ({setColorCallback}) => {
+ const onColorClick = (event) => {
+ setColorCallback(event.target.value);
+ }
+
+ return (
+
+
+
+
+
+
+
+
+ );
+};
+
+export default ColorChoice;