-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
CategoryShortcutButton.js
53 lines (48 loc) · 1.79 KB
/
CategoryShortcutButton.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
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {Pressable, View} from 'react-native';
import Icon from '../Icon';
import variables from '../../styles/variables';
import styles from '../../styles/styles';
import * as StyleUtils from '../../styles/StyleUtils';
import getButtonState from '../../libs/getButtonState';
import themeColors from '../../styles/themes/default';
const propTypes = {
/** The icon representation of the category that this button links to */
icon: PropTypes.func.isRequired,
/** The function to call when an emoji is selected */
onPress: PropTypes.func.isRequired,
};
class CategoryShortcutButton extends PureComponent {
constructor(props) {
super(props);
this.state = {
isHighlighted: false,
};
}
render() {
return (
<Pressable
onPress={this.props.onPress}
onHoverIn={() => this.setState({isHighlighted: true})}
onHoverOut={() => this.setState({isHighlighted: false})}
style={({pressed}) => ([
StyleUtils.getButtonBackgroundColorStyle(getButtonState(false, pressed)),
styles.categoryShortcutButton,
this.state.isHighlighted && styles.emojiItemHighlighted,
])}
>
<View style={styles.alignSelfCenter}>
<Icon
fill={themeColors.icon}
src={this.props.icon}
height={variables.iconSizeNormal}
width={variables.iconSizeNormal}
/>
</View>
</Pressable>
);
}
}
CategoryShortcutButton.propTypes = propTypes;
export default CategoryShortcutButton;