forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#37641 from HezekielT/migrate/25155
[TS migration] Migrate 'EmojiPicker' component to TypeScript
- Loading branch information
Showing
29 changed files
with
455 additions
and
599 deletions.
There are no files selected for viewing
25 changes: 8 additions & 17 deletions
25
...onents/EmojiPicker/CategoryShortcutBar.js → ...nents/EmojiPicker/CategoryShortcutBar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,33 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import _ from 'underscore'; | ||
import sourcePropTypes from '@components/Image/sourcePropTypes'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import type {HeaderIndice} from '@libs/EmojiUtils'; | ||
import CategoryShortcutButton from './CategoryShortcutButton'; | ||
|
||
const propTypes = { | ||
type CategoryShortcutBarProps = { | ||
/** The function to call when an emoji is selected */ | ||
onPress: PropTypes.func.isRequired, | ||
onPress: (index: number) => void; | ||
|
||
/** The emojis consisting emoji code and indices that the icons should link to */ | ||
headerEmojis: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
code: PropTypes.string.isRequired, | ||
index: PropTypes.number.isRequired, | ||
icon: sourcePropTypes.isRequired, | ||
}), | ||
).isRequired, | ||
headerEmojis: HeaderIndice[]; | ||
}; | ||
|
||
function CategoryShortcutBar(props) { | ||
function CategoryShortcutBar({onPress, headerEmojis}: CategoryShortcutBarProps) { | ||
const styles = useThemeStyles(); | ||
return ( | ||
<View style={[styles.ph4, styles.flexRow]}> | ||
{_.map(props.headerEmojis, (headerEmoji, i) => ( | ||
{headerEmojis.map((headerEmoji) => ( | ||
<CategoryShortcutButton | ||
icon={headerEmoji.icon} | ||
onPress={() => props.onPress(headerEmoji.index)} | ||
key={`categoryShortcut${i}`} | ||
onPress={() => onPress(headerEmoji.index)} | ||
key={`categoryShortcut${headerEmoji.index}`} | ||
code={headerEmoji.code} | ||
/> | ||
))} | ||
</View> | ||
); | ||
} | ||
|
||
CategoryShortcutBar.propTypes = propTypes; | ||
CategoryShortcutBar.displayName = 'CategoryShortcutBar'; | ||
|
||
export default CategoryShortcutBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.