From 01384e634ccc98eb2c48fd03eeb9c74182a9f148 Mon Sep 17 00:00:00 2001 From: crazywoola <427733928@qq.com> Date: Thu, 18 May 2023 08:38:25 +0800 Subject: [PATCH] feat: add emoji --- .../components/base/emoji-picker/index.tsx | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/web/app/components/base/emoji-picker/index.tsx b/web/app/components/base/emoji-picker/index.tsx index dba28d5ad0..b9f49ec339 100644 --- a/web/app/components/base/emoji-picker/index.tsx +++ b/web/app/components/base/emoji-picker/index.tsx @@ -1,16 +1,4 @@ 'use client' - -declare global { - namespace JSX { - interface IntrinsicElements { - 'em-emoji': React.DetailedHTMLProps< - React.HTMLAttributes, - HTMLElement - >; - } - } -} - import data from '@emoji-mart/data' import { init } from 'emoji-mart' // import AppIcon from '@/app/components/base/app-icon' @@ -25,6 +13,17 @@ import { } from '@heroicons/react/24/outline' import React from 'react' +declare global { + namespace JSX { + interface IntrinsicElements { + 'em-emoji': React.DetailedHTMLProps< + React.HTMLAttributes, + HTMLElement + >; + } + } +} + init({ data }) const backgroundColors = [ @@ -122,7 +121,12 @@ const EmojiSelect: FC = ({ } -const EmojiPicker: FC = () => { +interface IEmojiPickerProps { + onSelect?: (emoji: string, background: string) => void +} +const EmojiPicker: FC = ({ + onSelect +}) => { const [selectedEmoji, setSelectedEmoji] = useState('') const [selectBackground, setSelectBackground] = useState('') @@ -136,12 +140,15 @@ const EmojiPicker: FC = () => { - + { - setSelectedEmoji(itm) - }} /> - setSelectBackground(color)} /> - + setSelectedEmoji(itm) + }} /> + { + setSelectBackground(color) + onSelect && onSelect(selectedEmoji, color) + }} /> +