diff --git a/gauntlet.toml b/gauntlet.toml index 7c95cd3..1f143dc 100644 --- a/gauntlet.toml +++ b/gauntlet.toml @@ -15,6 +15,15 @@ description = """ Copy emojis to your clipboard from Gauntlet! """ +[[entrypoint]] +id = 'emojipicker-grid' +name = 'Emoji Picker (Grid)' +path = 'src/emojipicker-grid.tsx' +type = 'view' +description = """ +Copy emojis to your clipboard from Gauntlet! +""" + [permissions] main_search_bar = ["read"] clipboard = ["write"] diff --git a/src/emojipicker-grid.tsx b/src/emojipicker-grid.tsx new file mode 100644 index 0000000..4753bad --- /dev/null +++ b/src/emojipicker-grid.tsx @@ -0,0 +1,93 @@ +import { Grid } from "@project-gauntlet/api/components"; +import React, { ReactNode, useState } from "react"; +import { Clipboard, showHud } from "@project-gauntlet/api/helpers"; +import { + GroupedBy, + BaseEmoji, + getEmojis, + getEmojisGroupedBy, +} from "unicode-emoji"; + +// @ts-expect-error gauntlet uses deno and not node +// eslint-disable-next-line @typescript-eslint/no-unused-vars +const denoCore: DenoCore = Deno[Deno.internal].core; + +export default function EmojiPicker(): ReactNode | undefined { + const [searchText, setSearchText] = useState(""); + + let emojiList: BaseEmoji[] | Record; + let isCategory = null; + if (searchText) { + emojiList = getEmojis().filter((emoji) => + emoji.keywords.some((keyword) => keyword.includes(searchText)), + ); + isCategory = false; + } else { + emojiList = getEmojisGroupedBy("category"); + isCategory = true; + } + + return ( + + + {isCategory + ? Object.entries(emojiList).map(([category, emojis]) => ( + + {emojis.map((emoji: BaseEmoji) => ( + { + console.log(emoji); + await Clipboard.writeText(emoji.emoji); + showHud(`${emoji.emoji} copied to clipboard`); + }} + /> + ))} + + )) + : (emojiList as BaseEmoji[]).map((emoji: BaseEmoji) => ( + { + console.log(emoji); + await Clipboard.writeText(emoji.emoji); + showHud(`${emoji.emoji} copied to clipboard`); + }} + /> + ))} + + ); + + // return ( + // + // { + // console.log(emoji.emoji); + // await Clipboard.writeText(emoji.emoji); + // showHud(`${emoji.emoji} copied to clipboard`); + // }} + // /> + // + // } + // > + // + // {text} + // + // + // + // {emoji.emoji} + // + // + // ); +} diff --git a/src/emojipicker.tsx b/src/emojipicker.tsx index 2e06969..2b34597 100644 --- a/src/emojipicker.tsx +++ b/src/emojipicker.tsx @@ -36,7 +36,7 @@ export default function EmojiPicker(props: { { - console.log(emoji.emoji); + console.log(emoji); await Clipboard.writeText(emoji.emoji); showHud(`${emoji.emoji} copied to clipboard`); }}