-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicon-picker.tsx
46 lines (40 loc) · 1.04 KB
/
icon-picker.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"use client";
import EmojiPicker, { Theme } from "emoji-picker-react";
import { useTheme } from "next-themes";
import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
interface IconPickerProps {
onChange: (icon: string) => void;
children: React.ReactNode;
asChild?: boolean;
}
/**
* @description icon picker component
*/
export const IconPicker = ({
onChange,
children,
asChild,
}: IconPickerProps) => {
const themeMap = {
dark: Theme.DARK,
light: Theme.LIGHT,
};
const { resolvedTheme } = useTheme();
const currentTheme = (resolvedTheme || "light") as keyof typeof themeMap;
const theme = themeMap[currentTheme];
return (
<>
<Popover>
<PopoverTrigger asChild={asChild}>{children}</PopoverTrigger>
<PopoverContent className="p-0 w-full border-none">
<EmojiPicker
height={400}
width={400}
theme={theme}
onEmojiClick={(data) => onChange(data.emoji)}
/>
</PopoverContent>
</Popover>
</>
);
};