diff --git a/src/components/message/EmojiPicker.tsx b/src/components/message/EmojiPicker.tsx new file mode 100644 index 0000000..14c9fde --- /dev/null +++ b/src/components/message/EmojiPicker.tsx @@ -0,0 +1,42 @@ +import React, { FC } from 'react' +import data from '@emoji-mart/data' +import Picker from '@emoji-mart/react' +import { Emoji } from './Emoji' +import { Box, IconButton, Popper } from '@mui/material' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { faSmile } from '@fortawesome/free-solid-svg-icons' +import palette from '../../theme/palette' + +interface Props { + onChange: (emoji: Emoji) => void +} + +const EmojiPicker: FC = ({ onChange }) => { + const [anchorEl, setAnchorEl] = React.useState(null) + + const handleChange = (emoji: Emoji) => { + onChange(emoji) + setAnchorEl(null) + } + + const handleClick = (event: React.MouseEvent) => { + setAnchorEl(anchorEl ? null : event.currentTarget) + event.stopPropagation() + } + + const open = Boolean(anchorEl) + const id = open ? 'simple-popper' : undefined + + return ( + + + + + + setAnchorEl(null)} onEmojiSelect={handleChange} theme="light" /> + + + ) +} + +export default EmojiPicker diff --git a/src/components/message/EmojiPickerModal.tsx b/src/components/message/EmojiPickerModal.tsx deleted file mode 100644 index 9de43b1..0000000 --- a/src/components/message/EmojiPickerModal.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import React, { FC } from 'react' -import Modal from '../common/Modal' -import data from '@emoji-mart/data' -import Picker from '@emoji-mart/react' -import { Emoji } from './Emoji' - -interface Props { - open: boolean - onClose: () => void - onChange: (emoji: Emoji) => void -} - -const EmojiPickerModal: FC = ({ open, onClose, onChange }) => { - const handleChange = (emoji: Emoji) => { - onChange(emoji) - onClose() - } - - return ( - - onClose} onEmojiSelect={handleChange} /> - - ) -} - -export default EmojiPickerModal diff --git a/src/components/message/MessageForm.tsx b/src/components/message/MessageForm.tsx index 1999693..31a05a1 100644 --- a/src/components/message/MessageForm.tsx +++ b/src/components/message/MessageForm.tsx @@ -8,12 +8,12 @@ import useAuth from '../useAuth' import { Upload } from '../../api/Upload' import UploadButton from './UploadButton' import AttachmentsPreview from './AttachmentsPreview' -import EmojiPickerModal from './EmojiPickerModal' +import EmojiPicker from './EmojiPicker' import MessageMapModal from './MessageMapModal' import { FeatureCollection, Geometry } from 'geojson' import { Box, Button, FormGroup, IconButton, Stack, TextField } from '@mui/material' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faMapLocationDot, faPaperPlane, faSmile } from '@fortawesome/free-solid-svg-icons' +import { faMapLocationDot, faPaperPlane } from '@fortawesome/free-solid-svg-icons' import palette from '../../theme/palette' import { Emoji } from './Emoji' @@ -40,7 +40,6 @@ const MessageForm: FC = ({ ticker }) => { const [isSubmitting, setIsSubmitting] = useState(false) const [attachments, setAttachments] = useState([]) const [mapDialogOpen, setMapDialogOpen] = useState(false) - const [emojiPickerOpen, setEmojiPickerOpen] = useState(false) const emptyMap: FeatureCollection = { type: 'FeatureCollection', features: [], @@ -130,19 +129,16 @@ const MessageForm: FC = ({ ticker }) => { /> - + - setEmojiPickerOpen(true)} style={{ marginRight: '8px' }}> - - + setMapDialogOpen(true)}> setMapDialogOpen(false)} open={mapDialogOpen} ticker={ticker} /> - setEmojiPickerOpen(false)} open={emojiPickerOpen} />