Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 29 additions & 41 deletions src/components/EmojiPicker/CategoryShortcutButton.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, {PureComponent} from 'react';
Comment thread
AGarciaNY marked this conversation as resolved.
import React, {useState} from 'react';
import PropTypes from 'prop-types';
import Icon from '../Icon';
import Tooltip from '../Tooltip';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';
import useLocalize from '../../hooks/useLocalize';
import variables from '../../styles/variables';
import styles from '../../styles/styles';
import * as StyleUtils from '../../styles/StyleUtils';
Expand All @@ -20,48 +20,36 @@ const propTypes = {

/** The function to call when an emoji is selected */
onPress: PropTypes.func.isRequired,

...withLocalizePropTypes,
};

class CategoryShortcutButton extends PureComponent {
constructor(props) {
super(props);
this.state = {
isHighlighted: false,
};
}
function CategoryShortcutButton(props) {
const {translate} = useLocalize();
const [isHighlighted, setIsHighlighted] = useState(false);

render() {
return (
<Tooltip
text={this.props.translate(`emojiPicker.headers.${this.props.code}`)}
shiftVertical={-4}
return (
<Tooltip
text={translate(`emojiPicker.headers.${props.code}`)}
shiftVertical={-4}
>
<PressableWithoutFeedback
shouldUseAutoHitSlop={false}
onPress={props.onPress}
onHoverIn={() => setIsHighlighted(true)}
onHoverOut={() => setIsHighlighted(false)}
style={({pressed}) => [StyleUtils.getButtonBackgroundColorStyle(getButtonState(false, pressed)), styles.categoryShortcutButton, isHighlighted && styles.emojiItemHighlighted]}
accessibilityLabel={`emojiPicker.headers.${props.code}`}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
>
<PressableWithoutFeedback
shouldUseAutoHitSlop={false}
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,
]}
accessibilityLabel={`emojiPicker.headers.${this.props.code}`}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
>
<Icon
fill={themeColors.icon}
src={this.props.icon}
height={variables.iconSizeNormal}
width={variables.iconSizeNormal}
/>
</PressableWithoutFeedback>
</Tooltip>
);
}
<Icon
fill={themeColors.icon}
src={props.icon}
height={variables.iconSizeNormal}
width={variables.iconSizeNormal}
/>
</PressableWithoutFeedback>
</Tooltip>
);
}
CategoryShortcutButton.propTypes = propTypes;
Comment thread
puneetlath marked this conversation as resolved.
Outdated

export default withLocalize(CategoryShortcutButton);
CategoryShortcutButton.displayName = 'CategoryShortcutButton';
export default React.memo(CategoryShortcutButton);