diff --git a/src/features/gifPicker/components/GifAutocompleteSuggestions.tsx b/src/features/gifPicker/components/GifAutocompleteSuggestions.tsx new file mode 100644 index 0000000000..5d5af6f115 --- /dev/null +++ b/src/features/gifPicker/components/GifAutocompleteSuggestions.tsx @@ -0,0 +1,66 @@ +import {Pressable, View} from 'react-native' +import {msg} from '@lingui/core/macro' +import {useLingui} from '@lingui/react' + +import {atoms as a, useTheme} from '#/alf' +import {MagnifyingGlass_Stroke2_Corner0_Rounded as SearchIcon} from '#/components/icons/MagnifyingGlass' +import {Text} from '#/components/Typography' + +const LISTBOX_ID = 'gif-autocomplete-listbox' + +export function suggestionItemId(index: number) { + return `gif-autocomplete-option-${index}` +} + +export {LISTBOX_ID as GIF_AUTOCOMPLETE_LISTBOX_ID} + +export function GifAutocompleteSuggestions({ + suggestions, + activeIndex, + onSelect, +}: { + suggestions: string[] + activeIndex: number + onSelect: (suggestion: string) => void +}) { + const {_} = useLingui() + const t = useTheme() + + if (suggestions.length === 0) return null + + return ( + + {suggestions.map((suggestion, index) => { + const isActive = index === activeIndex + return ( + onSelect(suggestion)} + style={state => [ + a.flex_row, + a.align_center, + a.gap_sm, + a.px_md, + a.py_sm, + (isActive || ('hovered' in state && state.hovered)) && + t.atoms.bg_contrast_25, + ]}> + + + {suggestion} + + + ) + })} + + ) +}