From 5a835a337cee85e8e42faaf8055922a8a3bf98eb Mon Sep 17 00:00:00 2001 From: crazywoola <427733928@qq.com> Date: Thu, 18 May 2023 10:00:27 +0800 Subject: [PATCH] fix: emoji not show --- web/app/(commonLayout)/apps/NewAppDialog.tsx | 16 +- .../components/base/emoji-picker/index.tsx | 206 ++++++++---------- 2 files changed, 99 insertions(+), 123 deletions(-) diff --git a/web/app/(commonLayout)/apps/NewAppDialog.tsx b/web/app/(commonLayout)/apps/NewAppDialog.tsx index 419c91c3c0..ab8df96e80 100644 --- a/web/app/(commonLayout)/apps/NewAppDialog.tsx +++ b/web/app/(commonLayout)/apps/NewAppDialog.tsx @@ -85,7 +85,14 @@ const NewAppDialog = ({ show, onClose }: NewAppDialogProps) => { isCreatingRef.current = false }, [isWithTemplate, newAppMode, notify, router, templates, selectedTemplateIndex]) - return ( + return <> + {showEmojiPicker && { + console.log(emoji, background) + setShowEmojiPicker(false) + }} + onClose={() => setShowEmojiPicker(false)} + />} { } > - {showEmojiPicker && { - console.log(emoji, background) - setShowEmojiPicker(false) - }} />} +

{t('app.newApp.captionName')}

@@ -195,7 +199,7 @@ const NewAppDialog = ({ show, onClose }: NewAppDialogProps) => { )}
- ) + } export default NewAppDialog diff --git a/web/app/components/base/emoji-picker/index.tsx b/web/app/components/base/emoji-picker/index.tsx index 833bd9a530..ad22ba32b9 100644 --- a/web/app/components/base/emoji-picker/index.tsx +++ b/web/app/components/base/emoji-picker/index.tsx @@ -14,17 +14,6 @@ import { import React from 'react' import Modal from '@/app/components/base/modal' -declare global { - namespace JSX { - interface IntrinsicElements { - 'em-emoji': React.DetailedHTMLProps< - React.HTMLAttributes, - HTMLElement - >; - } - } -} - init({ data }) const backgroundColors = [ @@ -48,120 +37,103 @@ const backgroundColors = [ '#ECE9FE', '#FFE4E8', ] - -interface IColorSelectProps { - selectedEmoji: string - onSelect: (color: string) => void +interface IEmojiPickerProps { + isModal?: boolean + onSelect?: (emoji: string, background: string) => void + onClose?: () => void } -const ColorSelect: FC = ( - { selectedEmoji, onSelect } -) => { - const [selectBackground, setSelectBackground] = useState(backgroundColors[0]); - return
-

Choose Style

-
- {backgroundColors.map((color) => { - return
{ - setSelectBackground(color) - onSelect(color) - }} - > -
- +const EmojiPicker: FC = ({ + isModal = true, + onSelect, + onClose + +}) => { + const { categories } = data as any + const [selectedEmoji, setSelectedEmoji] = useState('') + const [selectedBackground, setSelectedBackground] = useState(backgroundColors[0]) + + return isModal ? { }} + isShow + closable={false} + className={cn(s.container, '!w-[362px] !p-0')} + > +
+
+
+
+ +
+
+ +
+ {categories.map((category: any, index: number) => { + return
+

{category.id}

+
+ {category.emojis.map((emoji: string, index: number) => { + return
{ + setSelectedEmoji(emoji) + }} + > +
+ +
+
+ })} +
})}
-
-} -interface IEmojiSelectProps { - onSelect?: (emoji: any) => void -} -const EmojiSelect: FC = ({ - onSelect -}) => { - - const { categories, emojis } = data as any - return
- {categories.map((category: any) => { - return
-

{category.id}

-
- {category.emojis.map((emoji: any) => { - return
{ - onSelect && onSelect(emoji) - }} - > -
- -
+ {/* Color Select */} +
+

Choose Style

+
+ {backgroundColors.map((color) => { + return
{ + setSelectedBackground(color) + }} + > +
+ {selectedEmoji !== '' && }
- })} - -
-
- })} -
-} - -interface IEmojiPickerProps { - isModal?: boolean - onSelect?: (emoji: string, background: string) => void -} -const EmojiPicker: FC = ({ - isModal = true, - onSelect -}) => { - const [selectedEmoji, setSelectedEmoji] = useState('') - - const Elem = () => { - return isModal ? { }} - isShow - className={cn(s.container, '!w-[362px] !p-0')} - > -
-
-
-
- -
+ })}
- - { - setSelectedEmoji(itm) - }} /> - { - onSelect && onSelect(selectedEmoji, color) - }} /> - -
- -
-
: <> - - } - - return +
+ +
+ + +
+ : <> + } -export default EmojiPicker +export default EmojiPicker \ No newline at end of file