Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat[issue #16143]: Changed CategoryShortcutButton class component #22431

Merged
merged 5 commits into from
Jul 14, 2023
Merged
Changes from 3 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
61 changes: 25 additions & 36 deletions src/components/EmojiPicker/CategoryShortcutButton.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {PureComponent} from 'react';
AGarciaNY marked this conversation as resolved.
Show resolved Hide resolved
import React, {useState} from 'react';
import PropTypes from 'prop-types';
import Icon from '../Icon';
import Tooltip from '../Tooltip';
Expand All @@ -24,43 +24,32 @@ const propTypes = {
...withLocalizePropTypes,
};

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

render() {
return (
<Tooltip
text={this.props.translate(`emojiPicker.headers.${this.props.code}`)}
shiftVertical={-4}
return (
<Tooltip
text={props.translate(`emojiPicker.headers.${props.code}`)}
shiftVertical={-4}
>
<PressableWithoutFeedback
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
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;
puneetlath marked this conversation as resolved.
Show resolved Hide resolved

CategoryShortcutButton.displayName = 'CategoryShortcutButton';
export default withLocalize(CategoryShortcutButton);
AGarciaNY marked this conversation as resolved.
Show resolved Hide resolved