Skip to content

Commit

Permalink
custom Emojis
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Nov 4, 2023
1 parent aab1f07 commit fb53fbb
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 8 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"emoji-picker-react": "^4.5.8",
"emoji-picker-react": "^4.5.9",
"next": "13.5.6",
"react": "^18",
"react-dom": "^18"
Expand Down
35 changes: 35 additions & 0 deletions src/components/PickerControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
SuggestionMode,
Theme,
} from "emoji-picker-react";
import * as React from "react";
import { customEmojis } from "./customEmojis";

export function PickerControls({
pickerProps,
Expand Down Expand Up @@ -67,6 +69,11 @@ export function PickerControls({
updateState("skinTonePickerLocation", skinTonePickerLocation)
}
/>
<ChkCustomEmojis
setCustomEmojis={(customEmojis) =>
updateState("customEmojis", customEmojis)
}
/>
<button onClick={reset} className={styles.ButtonReset}>
Reset
</button>
Expand Down Expand Up @@ -125,6 +132,34 @@ function ChkSearchDisabled({
);
}

function ChkCustomEmojis({
setCustomEmojis,
}: {
setCustomEmojis: (
toggleCustomEmojis: {
names: string[];
imgUrl: string;
id: string;
}[]
) => void;
}) {
const [toggleCustomEmojis, setToggleCustomEmojis] = React.useState(false);

React.useEffect(() => {
setCustomEmojis(toggleCustomEmojis ? customEmojis : []);
}, [toggleCustomEmojis]);

return (
<Label text="Custom Emojis">
<input
type="checkbox"
checked={toggleCustomEmojis}
onChange={(e) => setToggleCustomEmojis(e.target.checked)}
/>
</Label>
);
}

function InputSearchPlaceholder({
searchPlaceholder,
setSearchPlaceholder,
Expand Down
68 changes: 68 additions & 0 deletions src/components/customEmojis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
export const customEmojis = [
{
names: ["Alice", "alice in wonderland"],
imgUrl:
"https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/alice.png",
id: "alice",
},
{
names: ["Dog"],
imgUrl:
"https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/dog.png",
id: "dog",
},
{
names: ["Hat"],
imgUrl:
"https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/hat.png",
id: "hat",
},
{
names: ["Kid"],
imgUrl:
"https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/kid.png",
id: "kid",
},
{
names: ["Mic"],
imgUrl:
"https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/mic.png",
id: "mic",
},
{
names: ["Moab", "desert"],
imgUrl:
"https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/moab.png",
id: "moab",
},
{
names: ["Potter", "harry", "harry potter"],
imgUrl:
"https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/potter.png",
id: "potter",
},
{
names: ["Shroom", "mushroom"],
imgUrl:
"https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/shroom.png",
id: "shroom",
},
{
names: ["Smily"],
imgUrl:
"https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/smily.png",
id: "smily",
},
{
names: ["Tabby", "cat"],
imgUrl:
"https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/tabby.png",
id: "tabby",
},
{
names: ["Vest"],
imgUrl:
"https://cdn.jsdelivr.net/gh/ealush/emoji-picker-react@custom_emojis_assets/vest.png",
id: "vest",
},
];

0 comments on commit fb53fbb

Please sign in to comment.