-
Notifications
You must be signed in to change notification settings - Fork 111
Otters | Tori Shade #92
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -1,22 +1,37 @@ | ||
| import React from 'react'; | ||
| import './ChatEntry.css'; | ||
| import PropTypes from 'prop-types'; | ||
| import TimeStamp from './TimeStamp'; | ||
|
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. Great job using the provided |
||
|
|
||
| const ChatEntry = (props) => { | ||
|
|
||
| const chatEntryClassType = props.sender === 'Vladimir' ? 'local' : 'remote'; | ||
|
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. Wonderful implementation of the ternary here! |
||
|
|
||
| const likeMessage = () => { | ||
| props.likeCallback(props.id); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="chat-entry local"> | ||
| <h2 className="entry-name">Replace with name of 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> | ||
| <div className = {`chat-entry ${chatEntryClassType}`}> | ||
| <p className = 'entry-name'>{props.sender}</p> | ||
| <section className = 'entry-bubble'> | ||
| <p>{props.body}</p> | ||
| <p className = 'entry-time'> | ||
| <TimeStamp | ||
| time={props.timeStamp} | ||
| /> | ||
| </p> | ||
| <button className = 'like' onClick={likeMessage}>{props.liked ? '❤️': '🤍'}</button> | ||
| </section> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| ChatEntry.propTypes = { | ||
| //Fill with correct proptypes | ||
| sender: PropTypes.string.isRequired, | ||
| body: PropTypes.string.isRequired, | ||
| timeStamp: PropTypes.string.isRequired, | ||
| liked: PropTypes.bool.isRequired, | ||
| }; | ||
|
|
||
| export default ChatEntry; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import './ChatLog.css'; | ||
| import ChatEntry from './ChatEntry' | ||
| import PropTypes from 'prop-types'; | ||
| import React from 'react'; | ||
|
|
||
| const ChatLog = (props) => { | ||
| const chatEntryComponents = props.entries.map((chatEntry) => { | ||
| return ( | ||
| <ChatEntry | ||
| key={chatEntry.id} | ||
| id={chatEntry.id} | ||
| sender={chatEntry.sender} | ||
| body={chatEntry.body} | ||
| timeStamp={chatEntry.timeStamp} | ||
| liked={chatEntry.liked} | ||
| likeCallback={props.likeCallback} | ||
| /> | ||
| ); | ||
| }); | ||
| return ( | ||
| <div> | ||
| {chatEntryComponents} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| ChatLog.propTypes = { | ||
| entries: PropTypes.array.isRequired, | ||
|
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. We should also add |
||
| }; | ||
|
|
||
| export default ChatLog; | ||
|
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. Nit: JS wants a new line at the end of the file! |
||
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.
We can combine L1 and L4 into one line because they're both imported from the react library: