diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..406bf3d80 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.testing.pytestArgs": [ + "node_modules" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} \ No newline at end of file diff --git a/src/App.js b/src/App.js index c10859093..98d773b4e 100644 --- a/src/App.js +++ b/src/App.js @@ -1,16 +1,19 @@ -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 [chatLogList, setchatLogList] = useState([]); return (

Application title

+ {/* Wave 01: Render one ChatEntry component - Wave 02: Render ChatLog component */} + Wave 02: Render ChatLog component */}{' '}
); diff --git a/src/components/ChatEntry.js b/src/components/ChatEntry.js index b92f0b7b2..99349c557 100644 --- a/src/components/ChatEntry.js +++ b/src/components/ChatEntry.js @@ -1,22 +1,40 @@ import React from 'react'; import './ChatEntry.css'; import PropTypes from 'prop-types'; +import TimeStamp from './TimeStamp.js'; +import { useState } from 'react'; const ChatEntry = (props) => { + const sender = props.sender; + const senderBody = props.body; + const timeStamp = props.timeStamp; + const [isLiked, setIsLiked] = useState(false); + + const changeColorHeart = () => { + setIsLiked(!isLiked); + }; + return (
-

Replace with name of sender

+

{sender}

-

Replace with body of ChatEntry

-

Replace with TimeStamp component

- +

{senderBody}

+
+ +
+ +
); }; ChatEntry.propTypes = { - //Fill with correct proptypes + sender: PropTypes.string.isRequired, + body: PropTypes.string.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..3c2af7ad5 --- /dev/null +++ b/src/components/ChatLog.js @@ -0,0 +1,36 @@ +import React from 'react'; +import './ChatLog.css'; +import PropTypes from 'prop-types'; +import ChatEntry from './ChatEntry'; + +const ChatLog = (props) => { + const chatLogComponents = []; + const chatLogList = props.chatLogList; + + for (const chat of chatLogList) { + chatLogComponents.push( + + ); + } + + return
{chatLogComponents}
; +}; + +ChatLog.propTypes = { + chatLogList: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.number.isRequired, + sender: PropTypes.string.isRequired, + body: PropTypes.string.isRequired, + timeStamp: PropTypes.string.isRequired, + liked: PropTypes.bool.isRequired, + }) + ), +}; + +export default ChatLog; diff --git a/yarn.lock b/yarn.lock index b09a8b80b..80f5cc1d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3864,15 +3864,10 @@ caniuse-api@^3.0.0: lodash.memoize "^4.1.2" lodash.uniq "^4.5.0" -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001332: - version "1.0.30001344" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001344.tgz#8a1e7fdc4db9c2ec79a05e9fd68eb93a761888bb" - integrity sha512-0ZFjnlCaXNOAYcV7i+TtdKBp0L/3XEU2MF/x6Du1lrh+SRX4IfzIVL4HNJg5pB2PmFb8rszIGyOvsZnqqRoc2g== - -caniuse-lite@^1.0.30001400, caniuse-lite@^1.0.30001426: - version "1.0.30001439" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001439.tgz#ab7371faeb4adff4b74dad1718a6fd122e45d9cb" - integrity sha512-1MgUzEkoMO6gKfXflStpYgZDlFM7M/ck/bgfVCACO5vnAf0fXoNVHdWtqGU+MYca+4bL9Z5bpOVmR33cWW9G2A== +caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001332, caniuse-lite@^1.0.30001400, caniuse-lite@^1.0.30001426: + version "1.0.30001441" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001441.tgz" + integrity sha512-OyxRR4Vof59I3yGWXws6i908EtGbMzVUi3ganaZQHmydk1iwDhRnvaPG2WaR0KcqrDFKrxVZHULT396LEPhXfg== case-sensitive-paths-webpack-plugin@^2.4.0: version "2.4.0"