-
Notifications
You must be signed in to change notification settings - Fork 626
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
Amanda-Kaliane-Amethyst-C19-Chatlog #67
base: main
Are you sure you want to change the base?
Conversation
…yles to format Vladimir's messages on the left with light yellow background and Estragon's messages on the right with light blue background for Wave 1.
const changeLiked = (id) => { | ||
setEntries(prevEntries => { | ||
const updatedEntries = prevEntries.map(entry => { | ||
|
||
return entry.id === id ? { ...entry, liked: !entry.liked} : entry; | ||
}) | ||
return updatedEntries; | ||
}) | ||
} |
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.
Perfectly done! ⭐️
const totalLiked = () => { | ||
let total = 0; | ||
for (let entry of entries) { | ||
total += entry.liked ? 1 : 0; | ||
} | ||
return total; | ||
} |
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.
💫
// message = {message} | ||
id={entry.id} | ||
sender={entry.sender} | ||
body={entry.body} | ||
timeStamp={entry.timeStamp} | ||
changeLiked={changeLiked} | ||
liked={entry.liked} |
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.
Love how you kept the naming consistent as you passed down your props!
ChatLog.propTypes = { | ||
entries: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
id: PropTypes.number.isRequired, | ||
sender: PropTypes.string.isRequired, | ||
body: PropTypes.string.isRequired, | ||
liked: PropTypes.bool.isRequired, | ||
timeStamp: PropTypes.string.isRequired, | ||
}) | ||
) | ||
}; |
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.
Y'all ate on this! Great Job!
|
||
const ChatEntry = (props) => { | ||
const ChatEntry = ({ id, sender, body, timeStamp, changeLiked, liked }) => { | ||
const side = sender === 'Vladimir' ? 'local' : 'remote'; |
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.
The ternaries are great for situations like this right? They are the perfect tool to use when wanting conditionally apply styling!
No description provided.