Skip to content

Commit e20d658

Browse files
authored
Merge pull request #148 from Detaysoft/chat-list-tool
added mute and video call button to chatlist
2 parents b932c68 + aa77152 commit e20d658

6 files changed

Lines changed: 131 additions & 6 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ import { ChatItem } from 'react-chat-elements'
9595
| statusColor | none | color | ChatItem status color |
9696
| statusColorType | badge | string | ChatItem status color type (encircle, badge) |
9797
| statusText | none | color | ChatItem status text |
98-
| lazyLoadingImage | none | image path | lazy loading image |
98+
| muted | false | bool | chat mute info |
99+
| showMute | false | bool | chat mute button visibilty |
100+
| showVideoCall | false | bool | chat video call button visibilty |
101+
| onClickMute | none | function | mute button |
102+
| onClickVideoCall | none | function | video call button |
99103

100104

101105

example/App.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ export class App extends Component {
197197
date: new Date(),
198198
subtitle: loremIpsum({ count: 1, units: 'sentences' }),
199199
unread: parseInt(Math.random() * 10 % 3),
200+
muted: parseInt(Math.random() * 10 % 2) === 1,
201+
showMute: parseInt(Math.random() * 10 % 2) === 1,
202+
showVideoCall: parseInt(Math.random() * 10 % 2) === 1,
200203
dropdownMenu: (
201204
<Dropdown
202205
animationPosition="norteast"
@@ -317,7 +320,9 @@ export class App extends Component {
317320
center={
318321
this.state.list === 'chat' ?
319322
<ChatList
320-
dataSource={chatSource} />
323+
dataSource={chatSource}
324+
onClickMute={({...props}) => console.log(props)}
325+
onClickVideoCall={({...props}) => console.log(props)} />
321326
:
322327
<MeetingList
323328
onMeetingClick={console.log}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-chat-elements",
3-
"version": "10.15.0",
3+
"version": "10.16.0",
44
"description": "Reactjs chat components",
55
"author": "Avare Kodcu <abdurrahmaneker58@gmail.com>",
66
"main": "dist/main.js",

src/ChatItem/ChatItem.css

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,47 @@
130130
border-radius: 100%;
131131
background: red;
132132
}
133+
134+
.rce-citem-body--bottom-tools {
135+
align-items: center;
136+
justify-content: center;
137+
flex-direction: row;
138+
display: flex;
139+
height: 0;
140+
opacity: 0;
141+
position: absolute;
142+
left: -999px;
143+
transition: height .5s ease, opacity 1s ease;
144+
}
145+
146+
.rce-citem:hover .rce-citem-body--bottom-tools {
147+
height: 100%;
148+
opacity: 1;
149+
position: relative;
150+
left: 0;
151+
}
152+
153+
.rce-citem-body--bottom-tools-item-hidden-hover {
154+
height: 100%;
155+
opacity: 0.3;
156+
transition: .5s ease;
157+
}
158+
159+
.rce-citem:hover .rce-citem-body--bottom-tools-item-hidden-hover {
160+
height: 0;
161+
opacity: 0;
162+
position: absolute;
163+
left: -999px;
164+
transition: .5s ease;
165+
}
166+
167+
.rce-citem-body--bottom-tools-item {
168+
width: 18px;
169+
height: 18px;
170+
}
171+
172+
.rce-citem-body--bottom-tools-item svg {
173+
width: 18px;
174+
height: 18px;
175+
fill: #575757;
176+
}

src/ChatItem/ChatItem.js

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,50 @@ import {
88
} from'timeago.js';
99

1010
import classNames from 'classnames';
11-
import MdBlock from 'react-icons/lib/md/block';
11+
12+
import { MdVideoCall, MdVolumeOff, MdVolumeUp } from 'react-icons/lib/md';
1213

1314
export class ChatItem extends Component {
1415

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+
1548
render() {
1649
const statusColorType = this.props.statusColorType;
1750

1851
return (
1952
<div
2053
className={classNames('rce-container-citem', this.props.className)}
21-
onClick={this.props.onClick}
54+
onClick={this.handleOnClick}
2255
onContextMenu={this.props.onContextMenu}>
2356
<div className="rce-citem">
2457
<div className={classNames(
@@ -71,6 +104,38 @@ export class ChatItem extends Component {
71104
<div className="rce-citem-body--bottom-title">
72105
{this.props.subtitle}
73106
</div>
107+
<div className="rce-citem-body--bottom-tools" onMouseEnter={this.handleOnMouseEnter} onMouseLeave={this.handleOnMouseLeave}>
108+
{
109+
this.props.showMute &&
110+
<div className="rce-citem-body--bottom-tools-item"
111+
onClick={this.props.onClickMute}>
112+
{
113+
this.props.muted === true &&
114+
<MdVolumeOff />
115+
}
116+
{
117+
this.props.muted === false &&
118+
<MdVolumeUp />
119+
}
120+
</div>
121+
}
122+
{
123+
this.props.showVideoCall &&
124+
<div className="rce-citem-body--bottom-tools-item"
125+
onClick={this.props.onClickVideoCall}>
126+
<MdVideoCall />
127+
</div>
128+
}
129+
</div>
130+
<div className="rce-citem-body--bottom-tools-item-hidden-hover">
131+
{
132+
this.props.showMute &&
133+
this.props.muted &&
134+
<div className="rce-citem-body--bottom-tools-item">
135+
<MdVolumeOff />
136+
</div>
137+
}
138+
</div>
74139
<div className="rce-citem-body--bottom-status">
75140
{
76141
this.props.unread > 0 &&
@@ -101,6 +166,8 @@ ChatItem.defaultProps = {
101166
dateString: null,
102167
lazyLoadingImage: undefined,
103168
onAvatarError: () => void(0),
169+
showMute: null,
170+
showVideoCall: null,
104171
}
105172

106173
export default ChatItem;

src/ChatList/ChatList.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export class ChatList extends Component {
3737
{...x}
3838
onAvatarError={(e) => this.onAvatarError(x, i, e)}
3939
onContextMenu={(e) => this.onContextMenu(x, i, e)}
40-
onClick={(e) => this.onClick(x, i, e)}/>
40+
onClick={(e) => this.onClick(x, i, e)}
41+
onClickMute={(e) => this.props.onClickMute(x, i, e)}
42+
onClickVideoCall={(e) => this.props.onClickVideoCall(x, i, e)}/>
4143
))
4244
}
4345
</div>
@@ -49,6 +51,9 @@ ChatList.defaultProps = {
4951
dataSource: [],
5052
onClick: null,
5153
lazyLoadingImage: undefined,
54+
mute: null,
55+
onClickMute: null,
56+
onClickVideoCall: null,
5257
};
5358

5459
export default ChatList;

0 commit comments

Comments
 (0)