@@ -7,6 +7,7 @@ import Emoji from "@/components/commons/emoji";
77import useYDocStore from "@/store/useYDocStore" ;
88import { useYText } from "@/hooks/useYText" ;
99import { useOptimisticUpdatePage } from "@/hooks/usePages" ;
10+ import { cn } from "@/lib/utils" ;
1011
1112interface EditorTitleProps {
1213 currentPage : number ;
@@ -44,11 +45,11 @@ export default function EditorTitle({
4445 } ) ;
4546 } ;
4647
47- const handleEmojiClick = ( emoji : Emoji ) => {
48- setYEmoji ( emoji . native ) ;
48+ const handleEmojiClick = ( { native } : Emoji ) => {
49+ setYEmoji ( native ) ;
4950
5051 optimisticUpdatePageMutation . mutate ( {
51- pageData : { title, content : pageContent , emoji : emoji . native } ,
52+ pageData : { title, content : pageContent , emoji : native } ,
5253 } ) ;
5354
5455 setIsEmojiPickerOpen ( false ) ;
@@ -64,21 +65,46 @@ export default function EditorTitle({
6465 setIsEmojiPickerOpen ( false ) ;
6566 } ;
6667
68+ const handleRemoveIconClick = ( e : React . MouseEvent ) => {
69+ e . stopPropagation ( ) ;
70+
71+ setYEmoji ( "" ) ;
72+
73+ optimisticUpdatePageMutation . mutate ( {
74+ pageData : { title, content : pageContent , emoji : "" } ,
75+ } ) ;
76+
77+ setIsEmojiPickerOpen ( false ) ;
78+ } ;
79+
6780 return (
6881 < div className = "flex flex-col gap-3" >
69- < div className = "relative" >
70- < button onClick = { handleTitleEmojiClick } >
71- < Emoji emoji = { emoji } width = "w-10" height = "h-10" fontSize = "text-6xl" />
72- </ button >
73- < div
74- className = { `top-18 absolute z-50 ${ isEmojiPickerOpen ? "block" : "hidden" } ` }
75- >
76- < Picker
77- theme = "light"
78- previewPosition = "none"
79- onEmojiSelect = { handleEmojiClick }
80- onClickOutside = { handleEmojiOutsideClick }
81- />
82+ < div className = "group" >
83+ < div className = { cn ( "relative duration-200" ) } >
84+ < button onClick = { handleTitleEmojiClick } >
85+ < Emoji
86+ emoji = { emoji }
87+ width = "w-16"
88+ height = "h-16"
89+ fontSize = "text-6xl"
90+ />
91+ </ button >
92+ < div
93+ className = { `top-18 absolute z-50 ${ isEmojiPickerOpen ? "block" : "hidden" } ` }
94+ >
95+ < button
96+ onClick = { handleRemoveIconClick }
97+ className = "absolute -top-8 right-0 z-10 rounded-md bg-neutral-50 p-1 px-2 text-sm hover:bg-neutral-200"
98+ >
99+ Remove
100+ </ button >
101+ < Picker
102+ theme = "light"
103+ previewPosition = "none"
104+ onEmojiSelect = { handleEmojiClick }
105+ onClickOutside = { handleEmojiOutsideClick }
106+ />
107+ </ div >
82108 </ div >
83109 </ div >
84110 < input
0 commit comments