forked from AdaGold/react-chatlog
-
Notifications
You must be signed in to change notification settings - Fork 153
Expand file tree
/
Copy pathChatEntry.js
More file actions
44 lines (39 loc) · 1.03 KB
/
ChatEntry.js
File metadata and controls
44 lines (39 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import React from 'react';
import './ChatEntry.css';
import PropTypes from 'prop-types';
import TimeStamp from './TimeStamp';
const ChatEntry = (props) => {
const flipHeart = () => {
props.toggleHeartCallback(props.id);
};
return (
<div
className={`chat-entry ${
props.sender === 'Estragon' ? 'remote' : 'local'
} `}
>
<h2 className="entry-name">{props.sender}</h2>
<section className="entry-bubble">
<p>{props.body}</p>
<p className="entry-time">
<TimeStamp time={props.timeStamp} />
</p>
<button className="like" onClick={flipHeart}>
{props.liked ? '❤️' : '🤍'}
</button>
</section>
</div>
);
};
ChatEntry.propTypes = {
id: PropTypes.number,
sender: PropTypes.string.isRequired,
body: PropTypes.string.isRequired,
timeStamp: PropTypes.string.isRequired,
liked: PropTypes.bool,
toggleHeartCallback: PropTypes.func,
};
ChatEntry.defaultProps = {
toggleHeartCallback: () => {},
};
export default ChatEntry;