From 7a222665b5a0afc2fb8627879414092ffe0c0dd0 Mon Sep 17 00:00:00 2001 From: Yvett Jimenez Date: Mon, 24 Jul 2023 23:09:05 -0500 Subject: [PATCH 1/6] added test comment --- src/App.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/App.js b/src/App.js index c10859093..05bd2e325 100644 --- a/src/App.js +++ b/src/App.js @@ -11,6 +11,7 @@ const App = () => {
{/* Wave 01: Render one ChatEntry component Wave 02: Render ChatLog component */} + {/* comment */}
); From fe96ac5a128af0da3b1abb92ec45a3c7f3fa88e5 Mon Sep 17 00:00:00 2001 From: Yvett Jimenez Date: Mon, 24 Jul 2023 23:31:28 -0500 Subject: [PATCH 2/6] wave 1 --- src/App.js | 12 ++++++++++-- src/components/ChatEntry.js | 11 +++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/App.js b/src/App.js index 05bd2e325..678018db1 100644 --- a/src/App.js +++ b/src/App.js @@ -1,17 +1,25 @@ import React from 'react'; import './App.css'; import chatMessages from './data/messages.json'; +import ChatEntry from './components/ChatEntry'; const App = () => { + + const exampleMessage = chatMessages[0]; + return (
-

Application title

+

Chat Messages

{/* Wave 01: Render one ChatEntry component Wave 02: Render ChatLog component */} - {/* comment */} +
); diff --git a/src/components/ChatEntry.js b/src/components/ChatEntry.js index b92f0b7b2..af36b5873 100644 --- a/src/components/ChatEntry.js +++ b/src/components/ChatEntry.js @@ -1,14 +1,17 @@ import React from 'react'; import './ChatEntry.css'; +import TimeStamp from './TimeStamp'; import PropTypes from 'prop-types'; -const ChatEntry = (props) => { +const ChatEntry = ( { sender, body, timestamp } ) => { return (
-

Replace with name of sender

+

{sender}

-

Replace with body of ChatEntry

-

Replace with TimeStamp component

+

{body}

+

+ +

From ef01468e942a06bdac3ef6765eb79334fc265aea Mon Sep 17 00:00:00 2001 From: Yvett Jimenez Date: Mon, 24 Jul 2023 23:32:30 -0500 Subject: [PATCH 3/6] prop spelling correction --- src/App.js | 2 +- src/components/ChatEntry.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/App.js b/src/App.js index 678018db1..09aa63946 100644 --- a/src/App.js +++ b/src/App.js @@ -18,7 +18,7 @@ const App = () => { diff --git a/src/components/ChatEntry.js b/src/components/ChatEntry.js index af36b5873..14a877e2a 100644 --- a/src/components/ChatEntry.js +++ b/src/components/ChatEntry.js @@ -3,14 +3,14 @@ import './ChatEntry.css'; import TimeStamp from './TimeStamp'; import PropTypes from 'prop-types'; -const ChatEntry = ( { sender, body, timestamp } ) => { +const ChatEntry = ( { sender, body, timeStamp } ) => { return (

{sender}

{body}

- +

From bfb93fa434b2659807b76a26e88792750ae7112e Mon Sep 17 00:00:00 2001 From: Yvett Jimenez Date: Mon, 24 Jul 2023 23:37:36 -0500 Subject: [PATCH 4/6] added proptypes --- src/App.js | 2 ++ src/components/ChatEntry.js | 3 +++ src/components/ChatLog.js | 0 3 files changed, 5 insertions(+) create mode 100644 src/components/ChatLog.js diff --git a/src/App.js b/src/App.js index 09aa63946..4a8242614 100644 --- a/src/App.js +++ b/src/App.js @@ -2,6 +2,7 @@ import React from 'react'; import './App.css'; import chatMessages from './data/messages.json'; import ChatEntry from './components/ChatEntry'; +import ChatLog from './components/ChatLog'; const App = () => { @@ -20,6 +21,7 @@ const App = () => { body={exampleMessage.body} timeStamp={exampleMessage.timeStamp} /> +
); diff --git a/src/components/ChatEntry.js b/src/components/ChatEntry.js index 14a877e2a..cb091176f 100644 --- a/src/components/ChatEntry.js +++ b/src/components/ChatEntry.js @@ -20,6 +20,9 @@ const ChatEntry = ( { sender, body, timeStamp } ) => { ChatEntry.propTypes = { //Fill with correct proptypes + sender: PropTypes.string.isRequired, + body: PropTypes.number.isRequired, + timeStamp: PropTypes.string.isRequired }; export default ChatEntry; diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js new file mode 100644 index 000000000..e69de29bb From 7ad7a2f01c6c46fa91290b7ce9e9aafc3606300e Mon Sep 17 00:00:00 2001 From: Yvett Jimenez Date: Mon, 24 Jul 2023 23:58:04 -0500 Subject: [PATCH 5/6] wave 2, adjusted props in chat entry component, made chatlog component, adjusted app jsx --- src/App.js | 14 +++----------- src/components/ChatEntry.js | 5 +++-- src/components/ChatLog.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/App.js b/src/App.js index 4a8242614..bf9586c25 100644 --- a/src/App.js +++ b/src/App.js @@ -1,27 +1,19 @@ import React from 'react'; import './App.css'; import chatMessages from './data/messages.json'; -import ChatEntry from './components/ChatEntry'; import ChatLog from './components/ChatLog'; const App = () => { - - const exampleMessage = chatMessages[0]; - + return (

Chat Messages

- {/* Wave 01: Render one ChatEntry component - Wave 02: Render ChatLog component */} - -
); diff --git a/src/components/ChatEntry.js b/src/components/ChatEntry.js index cb091176f..19e681e0f 100644 --- a/src/components/ChatEntry.js +++ b/src/components/ChatEntry.js @@ -19,10 +19,11 @@ const ChatEntry = ( { sender, body, timeStamp } ) => { }; ChatEntry.propTypes = { - //Fill with correct proptypes + id: PropTypes.number.isRequired, sender: PropTypes.string.isRequired, body: PropTypes.number.isRequired, - timeStamp: PropTypes.string.isRequired + timeStamp: PropTypes.string.isRequired, + liked: PropTypes.bool.isRequired }; export default ChatEntry; diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js index e69de29bb..87ce95c99 100644 --- a/src/components/ChatLog.js +++ b/src/components/ChatLog.js @@ -0,0 +1,30 @@ +import React from 'react'; +import './ChatLog.css'; +import PropTypes from 'prop-types'; +import ChatEntry from './ChatEntry'; + +const ChatLog = ( { entries } ) => { + const chatEntries = entries.map(entry => { + return ( + + ) + }) + + return ( + <> + {chatEntries} + + ) +}; + +ChatLog.propTypes = { + entries: PropTypes.array.isRequired + }; + +export default ChatLog; \ No newline at end of file From 9fd39ca3608e33de6b22b0465bd383d518044ad5 Mon Sep 17 00:00:00 2001 From: Yvett Jimenez Date: Tue, 25 Jul 2023 00:52:04 -0500 Subject: [PATCH 6/6] done i think --- src/App.js | 14 +++++++++++++- src/components/ChatEntry.js | 17 ++++++++++++++--- src/components/ChatLog.js | 4 +++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/App.js b/src/App.js index bf9586c25..8482be6fd 100644 --- a/src/App.js +++ b/src/App.js @@ -1,18 +1,30 @@ -import React from 'react'; +import React, { useState } from 'react'; import './App.css'; import chatMessages from './data/messages.json'; import ChatLog from './components/ChatLog'; const App = () => { + const [likedMessages, setLikedMessages] = useState(0); + + const likeMessage = () => { + setLikedMessages(likedMessages => likedMessages + 1); + }; + + const unlikeMessage = () => { + setLikedMessages(likedMessages => likedMessages - 1); + }; return (

Chat Messages

+

{likedMessages} ❤️s

diff --git a/src/components/ChatEntry.js b/src/components/ChatEntry.js index 19e681e0f..a7736b49c 100644 --- a/src/components/ChatEntry.js +++ b/src/components/ChatEntry.js @@ -1,9 +1,18 @@ -import React from 'react'; +import React, { useState } from 'react'; import './ChatEntry.css'; import TimeStamp from './TimeStamp'; import PropTypes from 'prop-types'; -const ChatEntry = ( { sender, body, timeStamp } ) => { +const ChatEntry = ( { sender, body, timeStamp, likeMessage, unlikeMessage } ) => { + const [hearted, setHearted] = useState(false); + + const toggleHeart = () => { + setHearted(hearted => !hearted); + hearted ? unlikeMessage(): likeMessage(); + }; + + const heartedIcon = hearted ? '❤️' : '🤍'; + return (

{sender}

@@ -12,7 +21,9 @@ const ChatEntry = ( { sender, body, timeStamp } ) => {

- +
); diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js index 87ce95c99..6329f1431 100644 --- a/src/components/ChatLog.js +++ b/src/components/ChatLog.js @@ -3,7 +3,7 @@ import './ChatLog.css'; import PropTypes from 'prop-types'; import ChatEntry from './ChatEntry'; -const ChatLog = ( { entries } ) => { +const ChatLog = ( { entries, likeMessage, unlikeMessage } ) => { const chatEntries = entries.map(entry => { return ( { body={entry.body} timeStamp={entry.timeStamp} liked={entry.liked} + likeMessage={likeMessage} + unlikeMessage={unlikeMessage} /> ) })