forked from AdaGold/react-chatlog
-
Notifications
You must be signed in to change notification settings - Fork 17
Ocelots-Diana A #9
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
Open
diarreola
wants to merge
17
commits into
ada-ac2:main
Choose a base branch
from
diarreola:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
71918ce
wave1: pass props to ChatEntry component
diarreola 2aed422
wave2: render ChatLog componeny
diarreola 2e702d0
wave2: create ChatLog component
diarreola c07cd17
wave2: update ChatEntry to include id prop
diarreola 3e189b2
Add correct title
diarreola e532e70
Add Estragon chatbox to the right side via ternary operator
diarreola 02959fc
Add liked prop
diarreola e4ead75
Add new attribute likedCount in entryData
diarreola fea50b0
Set and update state for a liked message
diarreola 5436216
Add onUpdateLikedMessage as a prop in Chatlog and require it
diarreola fd86aa9
Add onUpdateLikedMessage in ChatEntry and require it
diarreola 69d1438
Like heart and total likes
diarreola 64ff625
Add total likes to header
diarreola 6f19d43
Fix hearting a message
diarreola 3cc9d74
Pass entryData as a prop
diarreola 7403741
Update README.md
diarreola c0dfc74
Update README.md
diarreola File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,43 @@ | ||
| import React from 'react'; | ||
| import './ChatEntry.css'; | ||
| import PropTypes from 'prop-types'; | ||
| import TimeStamp from './TimeStamp'; | ||
|
|
||
| const ChatEntry = (props) => { | ||
| const id = props.id; | ||
| const sender = props.sender; | ||
| const body = props.body; | ||
| const timeStamp = props.timeStamp; | ||
| const liked = props.liked; | ||
|
|
||
| const senderSide = | ||
| sender === 'Vladimir' ? 'chat-entry local' : 'chat-entry remote'; | ||
|
|
||
| const heart = liked ? '❤️' : '🤍'; | ||
|
|
||
| return ( | ||
| <div className="chat-entry local"> | ||
| <h2 className="entry-name">Replace with name of sender</h2> | ||
| <div className={senderSide}> | ||
| <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>{body}</p> | ||
| <p className="entry-time"> | ||
| <TimeStamp time={timeStamp} /> | ||
| </p> | ||
| <button className="like" onClick={() => props.onUpdateLikedMessage(id)}> | ||
| {heart} | ||
| </button> | ||
| </section> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| ChatEntry.propTypes = { | ||
| //Fill with correct proptypes | ||
| id: PropTypes.number.isRequired, | ||
| sender: PropTypes.string.isRequired, | ||
| body: PropTypes.string.isRequired, | ||
| timeStamp: PropTypes.string.isRequired, | ||
| liked: PropTypes.bool.isRequired, | ||
| onUpdateLikedMessage: PropTypes.func.isRequired, | ||
| }; | ||
|
|
||
| export default ChatEntry; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import React from 'react'; | ||
| import './ChatLog.css'; | ||
| import './ChatEntry.css'; | ||
| import PropTypes from 'prop-types'; | ||
| import ChatEntry from './ChatEntry'; | ||
|
|
||
| const ChatLog = (props) => { | ||
| const messages = props.entries.map((message) => { | ||
| return ( | ||
| <div key={message.id}> | ||
| <ChatEntry | ||
| id={message.id} | ||
| sender={message.sender} | ||
| body={message.body} | ||
| timeStamp={message.timeStamp} | ||
| liked={message.liked} | ||
| onUpdateLikedMessage={props.onUpdateLikedMessage} | ||
| /> | ||
| </div> | ||
|
|
||
| ); | ||
| }); | ||
|
|
||
| return <section className="chat-log">{messages}</section>; | ||
| }; | ||
|
|
||
| ChatLog.propTypes = { | ||
| entries: PropTypes.arrayOf( | ||
|
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. nice use of PropTypes to control data requirements |
||
| PropTypes.shape({ | ||
| id: PropTypes.number.isRequired, | ||
| sender: PropTypes.string.isRequired, | ||
| body: PropTypes.string, | ||
| timeStamp: PropTypes.string.isRequired, | ||
| liked: PropTypes.bool.isRequired | ||
| }) | ||
| ), | ||
| onUpdateLikedMessage: PropTypes.func.isRequired | ||
| }; | ||
|
|
||
| export default ChatLog; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nice method of calculating total likes!