I think I just might go insane
Some checks failed
Actions / Build Plugins (push) Successful in 31s
Actions / Lint Plugins (push) Failing after 26s

This commit is contained in:
cswimr 2024-12-23 01:28:11 -05:00
parent f1f7d48532
commit f774f3b8bc
Signed by: cswimr
GPG key ID: 0EC431A8DA8F8087
3 changed files with 103 additions and 1 deletions

View file

@ -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"]

93
src/emojipicker-grid.tsx Normal file
View file

@ -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<string | undefined>("");
let emojiList: BaseEmoji[] | Record<GroupedBy, BaseEmoji[]>;
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 (
<Grid>
<Grid.SearchBar
placeholder={"Search for an emoji"}
value={searchText}
onChange={setSearchText}
/>
{isCategory
? Object.entries(emojiList).map(([category, emojis]) => (
<Grid.Section key={category} title={category}>
{emojis.map((emoji: BaseEmoji) => (
<Grid.Item
key={emoji.emoji}
title={emoji.emoji}
subtitle={emoji.keywords.join(", ")}
onClick={async () => {
console.log(emoji);
await Clipboard.writeText(emoji.emoji);
showHud(`${emoji.emoji} copied to clipboard`);
}}
/>
))}
</Grid.Section>
))
: (emojiList as BaseEmoji[]).map((emoji: BaseEmoji) => (
<Grid.Item
key={emoji.emoji}
title={emoji.emoji}
subtitle={emoji.keywords.join(", ")}
onClick={async () => {
console.log(emoji);
await Clipboard.writeText(emoji.emoji);
showHud(`${emoji.emoji} copied to clipboard`);
}}
/>
))}
</Grid>
);
// return (
// <Inline
// actions={
// <ActionPanel>
// <Action
// label={`Copy ${emoji.emoji} to clipboard`}
// onAction={async () => {
// console.log(emoji.emoji);
// await Clipboard.writeText(emoji.emoji);
// showHud(`${emoji.emoji} copied to clipboard`);
// }}
// />
// </ActionPanel>
// }
// >
// <Inline.Left>
// <Content.H3>{text}</Content.H3>
// </Inline.Left>
// <Inline.Separator icon={Icons.ArrowRight} />
// <Inline.Right>
// <Content.Paragraph>{emoji.emoji}</Content.Paragraph>
// </Inline.Right>
// </Inline>
// );
}

View file

@ -36,7 +36,7 @@ export default function EmojiPicker(props: {
<Action
label={`Copy ${emoji.emoji} to clipboard`}
onAction={async () => {
console.log(emoji.emoji);
console.log(emoji);
await Clipboard.writeText(emoji.emoji);
showHud(`${emoji.emoji} copied to clipboard`);
}}