-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chat): added emoji picker (#449)
Co-authored-by: Dunsin <78784850+Dun-sin@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import {default as ReactEmojiPicker} from 'emoji-picker-react'; | ||
import { useState } from 'react'; | ||
import { MdOutlineEmojiEmotions } from "react-icons/md"; | ||
import { useDarkMode } from 'src/context/DarkModeContext'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export default function EmojiPicker({onEmojiPick, focusInput}){ | ||
const { darkMode } = useDarkMode(); | ||
const [showEmojiPicker, setShowEmojiPicker] = useState(false); | ||
|
||
const onClosePicker = () => { | ||
setShowEmojiPicker(false); | ||
focusInput(); | ||
}; | ||
|
||
const hndleEmojiClick = (emojiData) => { | ||
onEmojiPick(prev => prev + emojiData.emoji); | ||
onClosePicker(); | ||
}; | ||
|
||
return ( | ||
<> | ||
<MdOutlineEmojiEmotions | ||
onClick={() => setShowEmojiPicker(true)} | ||
className="fill-white mr-5 scale-[1.3] cursor-pointer" | ||
/> | ||
{showEmojiPicker && <> | ||
<div | ||
aria-hidden | ||
className='fixed inset-0 z-10' | ||
onClick={onClosePicker} | ||
/> | ||
<div | ||
className='absolute bottom-[calc(100%+16px)] right-0 z-20 w-[min(100%,350px)]' | ||
> | ||
<ReactEmojiPicker | ||
width='100%' | ||
theme={darkMode ? 'dark' : 'light'} | ||
onEmojiClick={hndleEmojiClick} | ||
lazyLoadEmojis | ||
skinTonesDisabled | ||
searchDisabled | ||
/> | ||
</div> | ||
</>} | ||
</> | ||
) | ||
} | ||
|
||
EmojiPicker.propTypes = { | ||
onEmojiPick: PropTypes.func, | ||
focusInput: PropTypes.func, | ||
}; |
131c3b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
whisper – ./
whisper-git-main-dun-sin.vercel.app
anon-chat-app.vercel.app
whischat.vercel.app
whisper-dun-sin.vercel.app