Compare commits

..

No commits in common. "1963fddb7f315c3358cab9748a7d69808bb857ce" and "0b30f5501764f87d88e48a368ce83d54b3c815e4" have entirely different histories.

7 changed files with 153 additions and 3730 deletions

View file

@ -1,9 +0,0 @@
# The MIT License (MIT)
Copyright © 2024 cswimr
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -7,18 +7,18 @@ Repository: https://www.coastalcommits.com/cswimr/gauntlet-emojipicker
""" """
[[entrypoint]] [[entrypoint]]
id = 'emojipicker-legacy' id = 'emojipicker'
name = 'Emoji Picker' name = 'Emoji Picker'
path = 'src/emojipicker-legacy.tsx' path = 'src/emojipicker.tsx'
type = 'inline-view' type = 'inline-view'
description = """ description = """
Copy emojis to your clipboard from Gauntlet! Copy emojis to your clipboard from Gauntlet!
""" """
[[entrypoint]] [[entrypoint]]
id = 'emojipicker' id = 'emojipicker-grid'
name = 'Emoji Picker' name = 'Emoji Picker (Grid)'
path = 'src/emojipicker.tsx' path = 'src/emojipicker-grid.tsx'
type = 'view' type = 'view'
description = """ description = """
Copy emojis to your clipboard from Gauntlet! Copy emojis to your clipboard from Gauntlet!

View file

@ -1,6 +1,5 @@
{ {
"name": "cswimr-gauntlet-plugins", "name": "cswimr-gauntlet-plugins",
"license": "MIT",
"scripts": { "scripts": {
"publish": "gauntlet publish", "publish": "gauntlet publish",
"build": "gauntlet build", "build": "gauntlet build",
@ -9,7 +8,6 @@
}, },
"dependencies": { "dependencies": {
"@project-gauntlet/api": "0.12.0", "@project-gauntlet/api": "0.12.0",
"fuse": "^0.12.1",
"unicode-emoji": "^2.6.0", "unicode-emoji": "^2.6.0",
"which": "^5.0.0" "which": "^5.0.0"
}, },

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

@ -0,0 +1,68 @@
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>
);
}

View file

@ -1,56 +0,0 @@
import {
Action,
ActionPanel,
Content,
Icons,
Inline,
} from "@project-gauntlet/api/components";
import React, { ReactNode } from "react";
import { Clipboard, showHud } from "@project-gauntlet/api/helpers";
import * as UnicodeEmoji 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(props: {
text: string;
}): ReactNode | undefined {
const text = props.text.trim();
if (text.length < 3) {
return undefined;
}
const emoji = UnicodeEmoji.getEmojis().find((emoji) =>
emoji.keywords.includes(text),
);
if (!emoji) {
return undefined;
}
return (
<Inline
actions={
<ActionPanel>
<Action
label={`Copy ${emoji.emoji} to clipboard`}
onAction={async () => {
console.log(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

@ -1,89 +1,56 @@
import { Grid } from "@project-gauntlet/api/components";
import React, { ReactNode, useState } from "react";
import { Clipboard, showHud } from "@project-gauntlet/api/helpers";
import { import {
GroupedBy, Action,
BaseEmoji, ActionPanel,
getEmojis, Content,
getEmojisGroupedBy, Icons,
} from "unicode-emoji"; Inline,
} from "@project-gauntlet/api/components";
import React, { ReactNode } from "react";
import { Clipboard, showHud } from "@project-gauntlet/api/helpers";
import * as UnicodeEmoji from "unicode-emoji";
// @ts-expect-error gauntlet uses deno and not node // @ts-expect-error gauntlet uses deno and not node
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
const denoCore: DenoCore = Deno[Deno.internal].core; const denoCore: DenoCore = Deno[Deno.internal].core;
export default function EmojiPicker(): ReactNode | undefined { export default function EmojiPicker(props: {
const [searchText, setSearchText] = useState<string | undefined>(""); text: string;
}): ReactNode | undefined {
const text = props.text.trim();
let emojiList: BaseEmoji[] | Record<GroupedBy, BaseEmoji[]>; if (text.length < 3) {
let isCategory = null; return undefined;
if (searchText) {
emojiList = getEmojis().filter((emoji) =>
emoji.keywords.some((keyword) => keyword.includes(searchText)),
);
isCategory = false;
} else {
emojiList = getEmojisGroupedBy("category");
isCategory = true;
} }
let emojiListLength = 0; const emoji = UnicodeEmoji.getEmojis().find((emoji) =>
if (isCategory) { emoji.keywords.includes(text),
const typedList = emojiList as Record<GroupedBy, BaseEmoji[]>; );
for (const category in typedList) { if (!emoji) {
emojiListLength += typedList[category as GroupedBy].length; return undefined;
}
} else {
emojiListLength = (emojiList as BaseEmoji[]).length;
} }
console.log(emojiListLength);
return ( return (
<Grid> <Inline
<Grid.SearchBar actions={
placeholder={"Search for an emoji"} <ActionPanel>
value={searchText} <Action
onChange={setSearchText} label={`Copy ${emoji.emoji} to clipboard`}
/> onAction={async () => {
{isCategory console.log(emoji);
? Object.entries(emojiList).map(([category, emojis]) => ( await Clipboard.writeText(emoji.emoji);
<Grid.Section key={category} title={category}> showHud(`${emoji.emoji} copied to clipboard`);
{emojis.map((emoji: BaseEmoji) => ( }}
<Grid.Item />
key={emoji.emoji} </ActionPanel>
title={emoji.description} }
onClick={async () => { >
console.log(emoji); <Inline.Left>
await Clipboard.writeText(emoji.emoji); <Content.H3>{text}</Content.H3>
showHud(`${emoji.emoji} copied to clipboard`); </Inline.Left>
}} <Inline.Separator icon={Icons.ArrowRight} />
> <Inline.Right>
<Grid.Item.Content> <Content.Paragraph>{emoji.emoji}</Content.Paragraph>
<Grid.Item.Content.Paragraph> </Inline.Right>
{emoji.emoji} </Inline>
</Grid.Item.Content.Paragraph>
</Grid.Item.Content>
</Grid.Item>
))}
</Grid.Section>
))
: (emojiList as BaseEmoji[]).map((emoji: BaseEmoji) => (
<Grid.Item
key={emoji.emoji}
title={emoji.description}
onClick={async () => {
console.log(emoji);
await Clipboard.writeText(emoji.emoji);
showHud(`${emoji.emoji} copied to clipboard`);
}}
>
<Grid.Item.Content>
<Grid.Item.Content.Paragraph>
{emoji.emoji}
</Grid.Item.Content.Paragraph>
</Grid.Item.Content>
</Grid.Item>
))}
</Grid>
); );
} }

3621
yarn.lock

File diff suppressed because it is too large Load diff