From 247a4fe94b48ecfdf107279b7750c03ff73254f7 Mon Sep 17 00:00:00 2001 From: crazywoola Date: Fri, 19 May 2023 11:12:32 +0800 Subject: [PATCH] feat: add category called search --- .../components/base/emoji-picker/index.tsx | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/web/app/components/base/emoji-picker/index.tsx b/web/app/components/base/emoji-picker/index.tsx index 63ad3cc87c..e4b7d1a75c 100644 --- a/web/app/components/base/emoji-picker/index.tsx +++ b/web/app/components/base/emoji-picker/index.tsx @@ -33,8 +33,7 @@ async function search(value: string) { const results = emojis.map((emoji: any) => { return emoji.skins[0].native }) - - console.log(results) + return results } const backgroundColors = [ @@ -74,6 +73,9 @@ const EmojiPicker: FC = ({ const [selectedEmoji, setSelectedEmoji] = useState('') const [selectedBackground, setSelectedBackground] = useState(backgroundColors[0]) + const [searchedEmojis, setSearchedEmojis] = useState([]) + const [isSearching, setIsSearching] = useState(false) + return isModal ? { }} isShow @@ -90,14 +92,44 @@ const EmojiPicker: FC = ({ id="search" className='block w-full h-10 px-3 pl-10 text-sm font-normal bg-gray-100 rounded-lg' placeholder="Search emojis..." - onChange={(e: ChangeEvent) => { - search(e.target.value) + onChange={async (e: ChangeEvent) => { + if (e.target.value === '') { + setIsSearching(false) + return + } else { + setIsSearching(true) + const emojis = await search(e.target.value) + setSearchedEmojis(emojis) + } }} /> +
+ {isSearching && <> +
+

Search

+
+ {searchedEmojis.map((emoji: string, index: number) => { + return
{ + setSelectedEmoji(emoji) + }} + > +
+ +
+
+ })} +
+
+ } + + {categories.map((category: any, index: number) => { return

{category.id}