@@ -11,6 +11,7 @@ import {handleReaction} from "web/lib/util/message-reactions"
1111import { useClickOutside } from "web/hooks/use-click-outside"
1212import { PrivateChatMessage } from "common/chat-message" ;
1313import { updateReactionUI } from "web/lib/supabase/chat-messages" ;
14+ import { useIsMobile } from "web/hooks/use-is-mobile" ;
1415
1516const REACTIONS = [ '👍' , '❤️' , '😂' , '😮' , '😢' , '👎' ]
1617
@@ -35,6 +36,7 @@ export function MessageActions(props: {
3536 const emojiPickerRef = useRef < HTMLDivElement > ( null )
3637 const user = useUser ( )
3738 const isOwner = user ?. id === message . userId
39+ const isMobile = useIsMobile ( )
3840
3941 useClickOutside ( emojiPickerRef , ( ) => {
4042 setShowEmojiPicker ( false )
@@ -65,34 +67,32 @@ export function MessageActions(props: {
6567
6668 return (
6769 < div className = { clsx ( 'flex items-center gap-1' , className ) } >
68- < div className = "relative" >
69- { showEmojiPicker && (
70- < div
71- ref = { emojiPickerRef }
72- className = { clsx (
73- "absolute top-full mb-2 rounded-lg bg-canvas-200 p-2 shadow-lg pr-10 z-10" ,
74- isOwner && 'right-0' ,
75- ! isOwner && 'left-0' ,
76- ) }
77- >
78- < div className = "grid grid-cols-6 gap-8" >
79- { REACTIONS . map ( ( reaction ) => (
80- < button
81- key = { reaction }
82- className = "text-2xl hover:scale-125"
83- onClick = { async ( ) => {
84- setShowEmojiPicker ( false )
85- updateReactionUI ( message , user , reaction , setMessages )
86- await handleReaction ( reaction , message . id )
87- } }
88- >
89- { reaction }
90- </ button >
91- ) ) }
92- </ div >
70+ { showEmojiPicker && (
71+ < div
72+ ref = { emojiPickerRef }
73+ className = { clsx (
74+ 'absolute mb-2 rounded-lg bg-canvas-200 p-2 shadow-lg pr-10 z-10 max-w-[250px]' ,
75+ isMobile ? 'left-1/2 transform -translate-x-1/2'
76+ : isOwner ? 'right-20' : 'left-20'
77+ ) }
78+ >
79+ < div className = "grid grid-cols-6 gap-8" >
80+ { REACTIONS . map ( ( reaction ) => (
81+ < button
82+ key = { reaction }
83+ className = "text-2xl hover:scale-125"
84+ onClick = { async ( ) => {
85+ setShowEmojiPicker ( false )
86+ updateReactionUI ( message , user , reaction , setMessages )
87+ await handleReaction ( reaction , message . id )
88+ } }
89+ >
90+ { reaction }
91+ </ button >
92+ ) ) }
9393 </ div >
94- ) }
95- </ div >
94+ </ div >
95+ ) }
9696 { ! hideTrigger && (
9797 < DropdownMenu
9898 items = { [
@@ -117,7 +117,7 @@ export function MessageActions(props: {
117117 closeOnClick = { true }
118118 icon = { < DotsHorizontalIcon className = "h-5 w-5 text-gray-500" /> }
119119 menuWidth = "w-40"
120- className = "text-ink-500 hover:text-ink-700 rounded-full p-1 hover:bg-gray-100 "
120+ className = "text-ink-500 hover:text-ink-700 rounded-full p-1 hover:bg-canvas-50 "
121121 />
122122 ) }
123123 { /*{message.isEdited && (*/ }
0 commit comments