Skip to content

Commit 5e0862b

Browse files
author
Emre Güdür
committed
video call, mute button attrs
1 parent 1b289f1 commit 5e0862b

5 files changed

Lines changed: 51 additions & 19 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ import { ChatItem } from 'react-chat-elements'
9696
| statusColorType | badge | string | ChatItem status color type (encircle, badge) |
9797
| statusText | none | color | ChatItem status text |
9898
| muted | false | bool | chat mute info |
99+
| showMute | false | bool | chat mute button visibilty |
100+
| showVideoCall | false | bool | chat video call button visibilty |
99101
| onClickMute | none | function | mute button |
100102
| onClickVideoCall | none | function | video call button |
101103

example/App.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ export class App extends Component {
198198
subtitle: loremIpsum({ count: 1, units: 'sentences' }),
199199
unread: parseInt(Math.random() * 10 % 3),
200200
muted: parseInt(Math.random() * 10 % 2) === 1,
201+
showMute: parseInt(Math.random() * 10 % 2) === 1,
202+
showVideoCall: parseInt(Math.random() * 10 % 2) === 1,
201203
dropdownMenu: (
202204
<Dropdown
203205
animationPosition="norteast"
@@ -319,8 +321,8 @@ export class App extends Component {
319321
this.state.list === 'chat' ?
320322
<ChatList
321323
dataSource={chatSource}
322-
onClickMute={console.log}
323-
onClickVideoCall={console.log} />
324+
onClickMute={({...props}) => console.log(props)}
325+
onClickVideoCall={({...props}) => console.log(props)} />
324326
:
325327
<MeetingList
326328
onMeetingClick={console.log}

src/ChatItem/ChatItem.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,5 @@
172172
.rce-citem-body--bottom-tools-item svg {
173173
width: 18px;
174174
height: 18px;
175+
fill: #575757;
175176
}

src/ChatItem/ChatItem.js

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,45 @@ import { MdVideoCall, MdVolumeOff, MdVolumeUp } from 'react-icons/lib/md';
1313

1414
export class ChatItem extends Component {
1515

16+
constructor(p) {
17+
super(p);
18+
this.state = {
19+
onHoverTool: false,
20+
};
21+
22+
this.handleOnMouseEnter = this.handleOnMouseEnter.bind(this);
23+
this.handleOnMouseLeave = this.handleOnMouseLeave.bind(this);
24+
this.handleOnClick = this.handleOnClick.bind(this);
25+
}
26+
27+
handleOnMouseEnter() {
28+
this.setState({
29+
onHoverTool: true,
30+
});
31+
}
32+
33+
handleOnMouseLeave() {
34+
this.setState({
35+
onHoverTool: false,
36+
});
37+
}
38+
39+
handleOnClick(e) {
40+
e.preventDefault();
41+
42+
if (this.state.onHoverTool === true)
43+
return;
44+
45+
this.props.onClick();
46+
}
47+
1648
render() {
1749
const statusColorType = this.props.statusColorType;
1850

1951
return (
2052
<div
2153
className={classNames('rce-container-citem', this.props.className)}
22-
onClick={this.props.onClick}
54+
onClick={this.handleOnClick}
2355
onContextMenu={this.props.onContextMenu}>
2456
<div className="rce-citem">
2557
<div className={classNames(
@@ -72,9 +104,9 @@ export class ChatItem extends Component {
72104
<div className="rce-citem-body--bottom-title">
73105
{this.props.subtitle}
74106
</div>
75-
<div className="rce-citem-body--bottom-tools">
107+
<div className="rce-citem-body--bottom-tools" onMouseEnter={this.handleOnMouseEnter} onMouseLeave={this.handleOnMouseLeave}>
76108
{
77-
this.props.onClickMute instanceof Function &&
109+
this.props.showMute &&
78110
<div className="rce-citem-body--bottom-tools-item"
79111
onClick={this.props.onClickMute}>
80112
{
@@ -88,7 +120,7 @@ export class ChatItem extends Component {
88120
</div>
89121
}
90122
{
91-
this.props.onClickVideoCall instanceof Function &&
123+
this.props.showVideoCall &&
92124
<div className="rce-citem-body--bottom-tools-item"
93125
onClick={this.props.onClickVideoCall}>
94126
<MdVideoCall />
@@ -97,7 +129,7 @@ export class ChatItem extends Component {
97129
</div>
98130
<div className="rce-citem-body--bottom-tools-item-hidden-hover">
99131
{
100-
this.props.onClickMute instanceof Function &&
132+
this.props.showMute &&
101133
this.props.muted &&
102134
<div className="rce-citem-body--bottom-tools-item">
103135
<MdVolumeOff />
@@ -134,6 +166,8 @@ ChatItem.defaultProps = {
134166
dateString: null,
135167
lazyLoadingImage: undefined,
136168
onAvatarError: () => void(0),
169+
showMute: null,
170+
showVideoCall: null,
137171
}
138172

139173
export default ChatItem;

src/ChatList/ChatList.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,6 @@ export class ChatList extends Component {
1212
this.props.onClick(item, i, e);
1313
}
1414

15-
onClickMute(item, i, e) {
16-
if (this.props.onClickMute instanceof Function)
17-
this.props.onClickMute(item, i, e);
18-
}
19-
20-
onClickVideoCall(item, i, e) {
21-
if (this.props.onClickVideoCall instanceof Function)
22-
this.props.onClickVideoCall(item, i, e);
23-
}
24-
2515
onContextMenu(item, i, e) {
2616
e.preventDefault();
2717
if (this.props.onContextMenu instanceof Function)
@@ -48,8 +38,8 @@ export class ChatList extends Component {
4838
onAvatarError={(e) => this.onAvatarError(x, i, e)}
4939
onContextMenu={(e) => this.onContextMenu(x, i, e)}
5040
onClick={(e) => this.onClick(x, i, e)}
51-
onClickMute={(e) => this.onClickMute(x, i, e)}
52-
onClickVideoCall={(e) => this.onClickVideoCall(x, i, e)}/>
41+
onClickMute={(e) => this.props.onClickMute(x, i, e)}
42+
onClickVideoCall={(e) => this.props.onClickVideoCall(x, i, e)}/>
5343
))
5444
}
5545
</div>
@@ -61,6 +51,9 @@ ChatList.defaultProps = {
6151
dataSource: [],
6252
onClick: null,
6353
lazyLoadingImage: undefined,
54+
mute: null,
55+
onClickMute: null,
56+
onClickVideoCall: null,
6457
};
6558

6659
export default ChatList;

0 commit comments

Comments
 (0)