blob: cbafd31c5cbf03b79b40739f52440e6582e1a98e (
plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
import PropTypes from 'prop-types';
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
import EmojiStore from 'stores/emoji_store.jsx';
export default class EmojiPickerItem extends React.PureComponent {
static propTypes = {
emoji: PropTypes.object.isRequired,
onItemOver: PropTypes.func.isRequired,
onItemOut: PropTypes.func.isRequired,
onItemClick: PropTypes.func.isRequired,
onItemUnmount: PropTypes.func.isRequired,
category: PropTypes.string.isRequired,
isLoaded: PropTypes.bool.isRequired
}
constructor(props) {
super(props);
this.handleMouseOver = this.handleMouseOver.bind(this);
this.handleMouseOut = this.handleMouseOut.bind(this);
this.handleClick = this.handleClick.bind(this);
}
componentWillUnmount() {
this.props.onItemUnmount(this.props.emoji);
}
handleMouseOver() {
this.props.onItemOver(this.props.emoji);
}
handleMouseOut() {
this.props.onItemOut(this.props.emoji);
}
handleClick() {
this.props.onItemClick(this.props.emoji);
}
render() {
let item = null;
if (this.props.category === 'recent' || this.props.category === 'custom') {
item = (
<span
onMouseOver={this.handleMouseOver}
onMouseOut={this.handleMouseOut}
onClick={this.handleClick}
className='emoji-picker__item-wrapper'
>
<img
className='emoji-picker__item emoticon'
src={EmojiStore.getEmojiImageUrl(this.props.emoji)}
/>
</span>
);
} else {
let className;
if (this.props.isLoaded) {
className = 'emojisprite';
} else {
className = 'emojisprite-loading';
}
className += ' emoji-category-' + this.props.category;
className += ' emoji-' + this.props.emoji.filename;
item = (
<div>
<img
src='/static/images/img_trans.gif'
className={className}
onMouseOver={this.handleMouseOver}
onMouseOut={this.handleMouseOut}
onClick={this.handleClick}
/>
</div>
);
}
return item;
}
}
|