Here is an array of emojis for you to consider:
allEmojis = {
"Smileys-People": [
{
"index": 1,
"display": true,
"name": "grinning face",
"shortName": ":grinning:",
"alt": "😀",
"image": "_81",
"position": "0px -80px",
"keywords": [
"face",
"nice",
"smile",
"laugh",
"happy",
"smiling",
"grin",
"teeth",
"cheerful",
"cheery",
"grinning face"
]
},
{
"index": 2,
"display": true,
"name": "smiling face with open mouth",
"shortName": ":smiley:",
"alt": "😃",
"image": "_81",
"position": "-60px -80px",
"keywords": [
"face",
"open mouth",
"awesome",
"yay",
"smile",
"happy",
"smiling",
"grin",
"teeth",
"smiling face with open mouth"
]
}
],
"Animals-Nature": [
{
"index": 3,
"display": true,
"name": "grinning face",
"shortName": ":dog:",
"alt": "🐶",
"image": "_82",
"position": "-60px -20px",
"keywords": [
"animal",
"face",
"pet",
"adorbs",
"dog",
"puppies",
"puppy",
"dog face"
]
},
{
"index": 4,
"display": true,
"name": "smiling face with open mouth",
"shortName": ":cat:",
"alt": "🐱",
"image": "_82",
"position": "-60px -80px",
"keywords": [
"animal",
"face",
"cat",
"kitten",
"kitty",
"pet",
"cat face"
]
}
]
}
I have implemented a javascript code to search within the array and set each display
based on the keyword input. However, there are certain discrepancies in the behavior of the function depending on the keyword used.
emojiTitles = Object.keys(allEmojis).join(",").split(',')
const emojiSeacrh = (e) => {
let value = e.target.value.toUpperCase()
for (let emojiTitle of emojiTitles) {
for (let emoji of allEmojis[emojiTitle]) {
for (let keyword of emoji.keywords) {
if (keyword.toUpperCase().startsWith(value)) {
emoji.display = true
}
else {
emoji.display = false
}
}
}
}
allEmojis = allEmojis
}
While I acknowledge that my emojiSearch
function may not be optimal, I have struggled to find a better solution that fits my specific requirements after extensive research.