-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lions - Jessica A. #115
base: main
Are you sure you want to change the base?
Lions - Jessica A. #115
Changes from all commits
b551d8b
1b714f5
935ba8c
35ddeeb
75cdee9
c9c28c5
36a61d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"python.testing.pytestArgs": [ | ||
"node_modules" | ||
], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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([]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The state should start from the |
||
return ( | ||
<div id="App"> | ||
<header> | ||
<h1>Application title</h1> | ||
</header> | ||
<main> | ||
<ChatLog chatLogList={chatMessages} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be using the state instead of the messages directly |
||
{/* Wave 01: Render one ChatEntry component | ||
Wave 02: Render ChatLog component */} | ||
Wave 02: Render ChatLog component */}{' '} | ||
</main> | ||
</div> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
Comment on lines
7
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the future consider destructuring props in the constructor. |
||
const [isLiked, setIsLiked] = useState(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This type of state should be lifted up |
||
|
||
const changeColorHeart = () => { | ||
setIsLiked(!isLiked); | ||
}; | ||
|
||
return ( | ||
<div className="chat-entry local"> | ||
<h2 className="entry-name">Replace with name of sender</h2> | ||
<h2 className="entry-name">{sender}</h2> | ||
<section className="entry-bubble"> | ||
<p>Replace with body of ChatEntry</p> | ||
<p className="entry-time">Replace with TimeStamp component</p> | ||
<button className="like">🤍</button> | ||
<p>{senderBody}</p> | ||
<div className="entry-time"> | ||
<TimeStamp time={timeStamp} /> | ||
</div> | ||
|
||
<button className="like" onClick={changeColorHeart}> | ||
{isLiked ? <div>❤️</div> : <div>🤍</div>} | ||
</button> | ||
</section> | ||
</div> | ||
); | ||
}; | ||
|
||
ChatEntry.propTypes = { | ||
//Fill with correct proptypes | ||
sender: PropTypes.string.isRequired, | ||
body: PropTypes.string.isRequired, | ||
timeStamp: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default ChatEntry; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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( | ||
<ChatEntry | ||
key={chat.id} | ||
sender={chat.sender} | ||
body={chat.body} | ||
timeStamp={chat.timeStamp} | ||
/> | ||
); | ||
} | ||
|
||
return <div>{chatLogComponents}</div>; | ||
}; | ||
|
||
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, | ||
}) | ||
), | ||
}; | ||
Comment on lines
+24
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure to make the overall array prop as required. |
||
|
||
export default ChatLog; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these are correct settings - we're not using Python. Also, your individual VS Code settings should not be committed. They should be added to the
.gitignore
if needed.