-
Notifications
You must be signed in to change notification settings - Fork 3k
/
EmojiPickerButton.js
54 lines (48 loc) · 2.01 KB
/
EmojiPickerButton.js
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
import React from 'react';
import PropTypes from 'prop-types';
import styles from '../../styles/styles';
import * as StyleUtils from '../../styles/StyleUtils';
import getButtonState from '../../libs/getButtonState';
import * as Expensicons from '../Icon/Expensicons';
import Tooltip from '../Tooltip';
import Icon from '../Icon';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';
import * as EmojiPickerAction from '../../libs/actions/EmojiPickerAction';
import PressableWithoutFeedback from '../Pressable/PressableWithoutFeedback';
const propTypes = {
/** Flag to disable the emoji picker button */
isDisabled: PropTypes.bool,
/** Id to use for the emoji picker button */
nativeID: PropTypes.string,
...withLocalizePropTypes,
};
const defaultProps = {
isDisabled: false,
nativeID: '',
};
function EmojiPickerButton(props) {
let emojiPopoverAnchor = null;
return (
<Tooltip text={props.translate('reportActionCompose.emoji')}>
<PressableWithoutFeedback
ref={(el) => (emojiPopoverAnchor = el)}
style={({hovered, pressed}) => [styles.chatItemEmojiButton, StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed))]}
disabled={props.isDisabled}
onPress={() => EmojiPickerAction.showEmojiPicker(props.onModalHide, props.onEmojiSelected, emojiPopoverAnchor)}
nativeID={props.nativeID}
accessibilityLabel={props.translate('reportActionCompose.emoji')}
>
{({hovered, pressed}) => (
<Icon
src={Expensicons.Emoji}
fill={StyleUtils.getIconFillColor(getButtonState(hovered, pressed))}
/>
)}
</PressableWithoutFeedback>
</Tooltip>
);
}
EmojiPickerButton.propTypes = propTypes;
EmojiPickerButton.defaultProps = defaultProps;
EmojiPickerButton.displayName = 'EmojiPickerButton';
export default withLocalize(EmojiPickerButton);