diff --git a/src/App.css b/src/App.css
index d97beb4e6..b579c014e 100644
--- a/src/App.css
+++ b/src/App.css
@@ -11,6 +11,7 @@
z-index: 100;
text-align: center;
align-items: center;
+ height: 80px;
}
#App main {
@@ -18,6 +19,7 @@
padding-right: 2em;
padding-bottom: 5rem;
padding-top: 10rem;
+ margin: auto;
}
#App h1 {
@@ -28,14 +30,20 @@
#App header section {
background-color: #e0ffff;
+ color: black;
+ height: 100%;
+ display: flex;
+ flex-direction: row;
+ justify-content: space-around;
+ align-items: center
}
#App .widget {
display: inline-block;
- line-height: 0.5em;
+ /* line-height: 0.5em; */
border-radius: 10px;
color: black;
- font-size:0.8em;
+ font-size: 0.8em;
padding-left: 1em;
padding-right: 1em;
}
@@ -71,4 +79,8 @@
.purple {
color: purple
+}
+
+.black {
+ color: black
}
\ No newline at end of file
diff --git a/src/App.js b/src/App.js
index c10859093..101e7f494 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,16 +1,66 @@
import React from 'react';
import './App.css';
import chatMessages from './data/messages.json';
+import ChatLog from './components/ChatLog';
+import ColorChoice from './components/ColorChoice';
const App = () => {
+ const [messages, setMessages] = React.useState(chatMessages);
+
+ const likeMessage = (id) => {
+ setMessages(
+ messages.map((message) => (message.id === id ? {
+ ...message,
+ liked: !message.liked
+ } : message))
+ );
+ };
+
+ const [colorChoice, setColor] = React.useState({
+ [messages[0].sender]: 'red',
+ [messages[1].sender]: 'green'
+ })
+
+ const setColorChoice = (sender, chosenColor) => {
+ console.log(sender, chosenColor)
+ setColor(prevColor => {
+ return {
+ ...prevColor,
+ [sender]: chosenColor
+ }
+ })
+ }
+
+
+ console.log(colorChoice)
+
+ let totalHearts = 0;
+
+ for (let message of messages) {
+ if (message.liked) {
+ totalHearts++
+ }
+ }
+
return (
- Application title
+ Chat between
+ {messages[0].sender} and {messages[1].sender}
+
+
+
+
+
+ {totalHearts} ❤️s
+
+
+
+
+
- {/* 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..1dce399c8 100644
--- a/src/components/ChatEntry.js
+++ b/src/components/ChatEntry.js
@@ -1,22 +1,44 @@
import React from 'react';
import './ChatEntry.css';
import PropTypes from 'prop-types';
+import TimeStamp from './TimeStamp';
-const ChatEntry = (props) => {
- return (
-
-
Replace with name of sender
-
- Replace with body of ChatEntry
- Replace with TimeStamp component
-
-
-
- );
+const ChatEntry = ({ id, sender, body, timeStamp, liked, likeMessage, colorChoice = 'black' }) => {
+ const likedHeart = '❤️';
+ const notLikedHeart = '🤍';
+ const likedClass = liked ? likedHeart : notLikedHeart;
+
+ const bubbleClass = colorChoice[sender] ?? 'black'
+
+ // console.log(bubbleClass)
+
+ const stateMessage = (sender) => {
+ return sender === 'Vladimir' ? 'local' : 'remote';
+ };
+
+ return (
+
+
{sender}
+
+ {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,
+ colorChoice: PropTypes.func
};
export default ChatEntry;
diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js
new file mode 100644
index 000000000..404e64981
--- /dev/null
+++ b/src/components/ChatLog.js
@@ -0,0 +1,27 @@
+import React from 'react'
+import './ChatLog.css'
+import ChatEntry from './ChatEntry'
+
+const ChatLog = ({ entries, likeMessage, colorChoice }) => {
+ const entryComponents = entries.map(entry => {
+ return (
+
+ )
+ })
+
+ return (
+
+
+
+ )
+}
+
+export default ChatLog
\ No newline at end of file
diff --git a/src/components/ColorChoice.css b/src/components/ColorChoice.css
new file mode 100644
index 000000000..4cb27aa6c
--- /dev/null
+++ b/src/components/ColorChoice.css
@@ -0,0 +1,19 @@
+ul {
+ list-style: none;
+ display: flex;
+ flex-direction: row;
+ gap: 10px;
+ overflow: hidden;
+ padding: 0
+}
+
+#color-picker {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+li {
+ float: left;
+}
\ No newline at end of file
diff --git a/src/components/ColorChoice.js b/src/components/ColorChoice.js
new file mode 100644
index 000000000..702a96592
--- /dev/null
+++ b/src/components/ColorChoice.js
@@ -0,0 +1,21 @@
+import React from 'react';
+import './ColorChoice.css'
+
+const ColorChoice = ({ setColorCallback, sender }) => {
+ return (
+
+
{`${sender}'s Color:`}
+
+ - setColorCallback(sender, 'red')}>🔴
+ - setColorCallback(sender, 'orange')}>🟠
+ - setColorCallback(sender, 'yellow')}>🟡
+ - setColorCallback(sender, 'green')}>🟢
+ - setColorCallback(sender, 'blue')}>🔵
+ - setColorCallback(sender,'purple')}>🟣
+
+
+
+ )
+}
+
+export default ColorChoice
\ No newline at end of file