simon | 26e79f7 | 2022-10-05 22:16:08 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 Savoir-faire Linux Inc. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU Affero General Public License as |
| 6 | * published by the Free Software Foundation; either version 3 of the |
| 7 | * License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU Affero General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Affero General Public |
| 15 | * License along with this program. If not, see |
| 16 | * <https://www.gnu.org/licenses/>. |
| 17 | */ |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 18 | import { QuestionMark } from '@mui/icons-material'; |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 19 | import { Box, ClickAwayListener, IconButton, IconButtonProps, Popper, SvgIconProps } from '@mui/material'; |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 20 | import { styled } from '@mui/material/styles'; |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 21 | import EmojiPicker, { IEmojiData } from 'emoji-picker-react'; |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 22 | import { ComponentType, MouseEvent, useCallback, useState } from 'react'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 23 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 24 | import { |
| 25 | Arrow2Icon, |
| 26 | Arrow3Icon, |
| 27 | ArrowIcon, |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 28 | AudioCallIcon, |
Gabriel Rochon | e3ec0d2 | 2022-10-08 14:27:03 -0400 | [diff] [blame] | 29 | CallEndIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 30 | CameraIcon, |
| 31 | CameraInBubbleIcon, |
| 32 | CancelIcon, |
Gabriel Rochon | e3ec0d2 | 2022-10-08 14:27:03 -0400 | [diff] [blame] | 33 | ChatBubbleIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 34 | CrossedEyeIcon, |
| 35 | CrossIcon, |
| 36 | EmojiIcon, |
Gabriel Rochon | e3ec0d2 | 2022-10-08 14:27:03 -0400 | [diff] [blame] | 37 | ExtensionIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 38 | EyeIcon, |
| 39 | FolderIcon, |
Gabriel Rochon | e3ec0d2 | 2022-10-08 14:27:03 -0400 | [diff] [blame] | 40 | FullscreenIcon, |
| 41 | GroupAddIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 42 | InfoIcon, |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 43 | ListIcon, |
Gabriel Rochon | e3ec0d2 | 2022-10-08 14:27:03 -0400 | [diff] [blame] | 44 | MicroIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 45 | MicroInBubbleIcon, |
| 46 | PaperClipIcon, |
| 47 | PenIcon, |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 48 | PeopleWithPlusSignIcon, |
Gabriel Rochon | e3ec0d2 | 2022-10-08 14:27:03 -0400 | [diff] [blame] | 49 | RecordingIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 50 | SaltireIcon, |
Gabriel Rochon | e3ec0d2 | 2022-10-08 14:27:03 -0400 | [diff] [blame] | 51 | ScreenShareIcon, |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 52 | VideoCallIcon, |
Gabriel Rochon | e3ec0d2 | 2022-10-08 14:27:03 -0400 | [diff] [blame] | 53 | VideoCameraIcon, |
| 54 | VolumeIcon, |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 55 | } from './SvgIcon'; |
Michelle Sepkap Sime | f5ebc2e | 2022-10-27 18:30:53 -0400 | [diff] [blame] | 56 | import CustomTooltip from './Tooltip'; |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 57 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 58 | type ShapedButtonProps = IconButtonProps & { |
| 59 | Icon: ComponentType<SvgIconProps>; |
| 60 | }; |
| 61 | |
| 62 | const RoundButton = styled(({ Icon, ...props }: ShapedButtonProps) => ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 63 | <IconButton {...props} disableRipple={true}> |
| 64 | <Icon fontSize="inherit" /> |
| 65 | </IconButton> |
| 66 | ))(({ theme }) => ({ |
| 67 | border: `1px solid ${theme.palette.primary.dark}`, |
| 68 | color: theme.palette.primary.dark, |
| 69 | fontSize: '15px', |
| 70 | '&:hover': { |
| 71 | background: theme.palette.primary.light, |
| 72 | }, |
| 73 | '&:active': { |
| 74 | color: '#FFF', |
| 75 | background: theme.palette.primary.dark, |
| 76 | }, |
| 77 | '&.MuiIconButton-sizeSmall': { |
| 78 | height: '15px', |
| 79 | width: '15px', |
| 80 | }, |
| 81 | '&.MuiIconButton-sizeMedium': { |
| 82 | height: '30px', |
| 83 | width: '30px', |
| 84 | }, |
| 85 | '&.MuiIconButton-sizeLarge': { |
| 86 | height: '53px', |
| 87 | width: '53px', |
| 88 | }, |
idillon-sfl | d5cc786 | 2022-08-25 11:11:34 -0400 | [diff] [blame] | 89 | })); |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 90 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 91 | export const CancelPictureButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 92 | return <RoundButton {...props} aria-label="remove picture" Icon={CancelIcon} size="large" />; |
| 93 | }; |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 94 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 95 | export const EditPictureButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 96 | return <RoundButton {...props} aria-label="edit picture" Icon={PenIcon} size="large" />; |
| 97 | }; |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 98 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 99 | export const UploadPictureButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 100 | return <RoundButton {...props} aria-label="upload picture" Icon={FolderIcon} size="large" />; |
| 101 | }; |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 102 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 103 | export const TakePictureButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 104 | return <RoundButton {...props} aria-label="take picture" Icon={CameraIcon} size="large" />; |
| 105 | }; |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 106 | |
Michelle Sepkap Sime | f5ebc2e | 2022-10-27 18:30:53 -0400 | [diff] [blame] | 107 | type InfoButtonProps = IconButtonProps & { |
| 108 | tooltipTitle: string; |
| 109 | }; |
| 110 | export const InfoButton = ({ tooltipTitle, ...props }: InfoButtonProps) => { |
| 111 | return ( |
| 112 | <CustomTooltip className="tooltip" title={tooltipTitle}> |
| 113 | <RoundButton {...props} aria-label="informations" Icon={InfoIcon} size="small" /> |
| 114 | </CustomTooltip> |
| 115 | ); |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 116 | }; |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 117 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 118 | export const TipButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 119 | return <RoundButton {...props} aria-label="tip" Icon={QuestionMark} size="medium" />; |
| 120 | }; |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 121 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 122 | export const MoreButton = styled((props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 123 | return ( |
| 124 | <IconButton {...props} disableRipple={true} aria-label="more"> |
| 125 | <CrossIcon fontSize="inherit" /> |
| 126 | </IconButton> |
| 127 | ); |
| 128 | })(({ theme }) => ({ |
| 129 | border: `1px solid ${theme.palette.primary.dark}`, |
| 130 | color: theme.palette.primary.dark, |
| 131 | fontSize: '10px', |
| 132 | height: '20px', |
| 133 | width: '20px', |
| 134 | '&:hover': { |
| 135 | background: theme.palette.primary.light, |
| 136 | }, |
| 137 | '&:active': { |
| 138 | color: '#FFF', |
| 139 | background: theme.palette.primary.dark, |
| 140 | }, |
| 141 | })); |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 142 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 143 | export const BackButton = styled((props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 144 | return ( |
| 145 | <IconButton {...props} disableRipple={true} aria-label="back"> |
| 146 | <ArrowIcon fontSize="inherit" /> |
| 147 | </IconButton> |
| 148 | ); |
| 149 | })(({ theme }) => ({ |
| 150 | color: theme.palette.primary.dark, |
| 151 | fontSize: '15px', |
| 152 | height: '30px', |
| 153 | width: '51px', |
| 154 | borderRadius: '5px', |
| 155 | '&:hover': { |
| 156 | background: theme.palette.primary.light, |
| 157 | }, |
| 158 | })); |
idillon | b3788bf | 2022-08-29 15:57:57 -0400 | [diff] [blame] | 159 | |
Gabriel Rochon | e3ec0d2 | 2022-10-08 14:27:03 -0400 | [diff] [blame] | 160 | export const CallingChatButton = (props: IconButtonProps) => { |
| 161 | return ( |
| 162 | <IconButton {...props} aria-label="chat" sx={{ color: 'white' }}> |
| 163 | <ChatBubbleIcon /> |
| 164 | </IconButton> |
| 165 | ); |
| 166 | }; |
| 167 | |
| 168 | export const CallingEndButton = (props: IconButtonProps) => { |
| 169 | return ( |
| 170 | <IconButton {...props} aria-label="end call" sx={{ color: 'white', backgroundColor: 'red' }}> |
| 171 | <CallEndIcon /> |
| 172 | </IconButton> |
| 173 | ); |
| 174 | }; |
| 175 | |
| 176 | export const CallingExtensionButton = (props: IconButtonProps) => { |
| 177 | return ( |
| 178 | <IconButton {...props} aria-label="extensions" sx={{ color: 'white' }}> |
| 179 | <ExtensionIcon /> |
| 180 | </IconButton> |
| 181 | ); |
| 182 | }; |
| 183 | |
| 184 | export const CallingFullscreenButton = (props: IconButtonProps) => { |
| 185 | return ( |
| 186 | <IconButton {...props} aria-label="fullscreen" sx={{ color: 'white' }}> |
| 187 | <FullscreenIcon /> |
| 188 | </IconButton> |
| 189 | ); |
| 190 | }; |
| 191 | |
| 192 | export const CallingGroupButton = (props: IconButtonProps) => { |
| 193 | return ( |
| 194 | <IconButton {...props} aria-label="group options" sx={{ color: 'white' }}> |
| 195 | <GroupAddIcon /> |
| 196 | </IconButton> |
| 197 | ); |
| 198 | }; |
| 199 | |
| 200 | export const CallingMicButton = (props: IconButtonProps) => { |
| 201 | return ( |
| 202 | <IconButton {...props} aria-label="microphone options" sx={{ color: 'white' }}> |
| 203 | <MicroIcon /> |
| 204 | </IconButton> |
| 205 | ); |
| 206 | }; |
| 207 | |
| 208 | export const CallingRecordButton = (props: IconButtonProps) => { |
| 209 | return ( |
| 210 | <IconButton {...props} aria-label="recording options" sx={{ color: 'white' }}> |
| 211 | <RecordingIcon /> |
| 212 | </IconButton> |
| 213 | ); |
| 214 | }; |
| 215 | |
| 216 | export const CallingScreenShareButton = (props: IconButtonProps) => { |
| 217 | return ( |
| 218 | <IconButton {...props} aria-label="screen share" sx={{ color: 'white' }}> |
| 219 | <ScreenShareIcon /> |
| 220 | </IconButton> |
| 221 | ); |
| 222 | }; |
| 223 | |
| 224 | export const CallingVideoCameraButton = (props: IconButtonProps) => { |
| 225 | return ( |
| 226 | <IconButton {...props} aria-label="camera options" sx={{ color: 'white' }}> |
| 227 | <VideoCameraIcon /> |
| 228 | </IconButton> |
| 229 | ); |
| 230 | }; |
| 231 | export const CallingVolumeButton = (props: IconButtonProps) => { |
| 232 | return ( |
| 233 | <IconButton {...props} aria-label="volume options" sx={{ color: 'white' }}> |
| 234 | <VolumeIcon /> |
| 235 | </IconButton> |
| 236 | ); |
| 237 | }; |
| 238 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 239 | export const CloseButton = styled((props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 240 | return ( |
| 241 | <IconButton {...props} disableRipple={true} aria-label="close"> |
| 242 | <SaltireIcon fontSize="inherit" /> |
| 243 | </IconButton> |
| 244 | ); |
| 245 | })(({ theme }) => ({ |
| 246 | color: theme.palette.primary.dark, |
| 247 | fontSize: '15px', |
| 248 | height: '30px', |
| 249 | width: '30px', |
| 250 | borderRadius: '5px', |
| 251 | '&:hover': { |
| 252 | background: theme.palette.primary.light, |
| 253 | }, |
| 254 | })); |
idillon | b3788bf | 2022-08-29 15:57:57 -0400 | [diff] [blame] | 255 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 256 | type ToggleVisibilityButtonProps = IconButtonProps & { |
| 257 | visible: boolean; |
| 258 | }; |
| 259 | export const ToggleVisibilityButton = styled(({ visible, ...props }: ToggleVisibilityButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 260 | const Icon = visible ? CrossedEyeIcon : EyeIcon; |
| 261 | return ( |
| 262 | <IconButton {...props} disableRipple={true}> |
| 263 | <Icon fontSize="inherit" /> |
| 264 | </IconButton> |
| 265 | ); |
| 266 | })(({ theme }) => ({ |
| 267 | color: theme.palette.primary.dark, |
| 268 | fontSize: '15px', |
| 269 | height: '15px', |
| 270 | width: '15px', |
| 271 | '&:hover': { |
| 272 | background: theme.palette.primary.light, |
| 273 | }, |
| 274 | })); |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 275 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 276 | const SquareButton = styled(({ Icon, ...props }: ShapedButtonProps) => ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 277 | <IconButton {...props} disableRipple={true}> |
| 278 | <Icon fontSize="inherit" /> |
| 279 | </IconButton> |
| 280 | ))(({ theme }) => ({ |
| 281 | color: '#7E7E7E', |
| 282 | fontSize: '25px', |
| 283 | height: '36px', |
| 284 | width: '36px', |
| 285 | borderRadius: '5px', |
| 286 | '&:hover': { |
| 287 | background: '#E5E5E5', |
| 288 | }, |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 289 | })); |
| 290 | |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 291 | export const AddParticipantButton = (props: IconButtonProps) => { |
| 292 | return <SquareButton {...props} aria-label="add participant" Icon={PeopleWithPlusSignIcon} />; |
| 293 | }; |
| 294 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 295 | export const RecordVideoMessageButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 296 | return <SquareButton {...props} aria-label="record video message" Icon={CameraInBubbleIcon} />; |
| 297 | }; |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 298 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 299 | export const RecordVoiceMessageButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 300 | return <SquareButton {...props} aria-label="record voice message" Icon={MicroInBubbleIcon} />; |
| 301 | }; |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 302 | |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 303 | export const ShowOptionsMenuButton = (props: IconButtonProps) => { |
| 304 | return <SquareButton {...props} aria-label="show options menu" Icon={ListIcon} />; |
| 305 | }; |
| 306 | |
| 307 | export const StartVideoCallButton = (props: IconButtonProps) => { |
| 308 | return <SquareButton {...props} aria-label="start audio call" Icon={AudioCallIcon} />; |
| 309 | }; |
| 310 | |
| 311 | export const StartAudioCallButton = (props: IconButtonProps) => { |
| 312 | return <SquareButton {...props} aria-label="start video call" Icon={VideoCallIcon} />; |
| 313 | }; |
| 314 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 315 | export const UploadFileButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 316 | return <SquareButton {...props} aria-label="upload file" Icon={PaperClipIcon} />; |
| 317 | }; |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 318 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 319 | export const SendMessageButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 320 | return <SquareButton {...props} aria-label="send message" Icon={Arrow2Icon} />; |
| 321 | }; |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 322 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 323 | export const ReplyMessageButton = styled((props: IconButtonProps) => ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 324 | <IconButton {...props} disableRipple={true} aria-label="send message"> |
| 325 | <Arrow3Icon fontSize="inherit" /> |
| 326 | </IconButton> |
| 327 | ))(({ theme }) => ({ |
| 328 | color: theme.palette.primary.dark, |
| 329 | fontSize: '20px', |
| 330 | height: '20px', |
| 331 | width: '20px', |
| 332 | borderRadius: '5px', |
| 333 | '&:hover': { |
| 334 | background: '#E5E5E5', |
| 335 | }, |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 336 | })); |
| 337 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 338 | type EmojiButtonProps = IconButtonProps & { |
| 339 | emoji: string; |
| 340 | }; |
| 341 | export const EmojiButton = styled(({ emoji, ...props }: EmojiButtonProps) => ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 342 | <IconButton {...props} disableRipple={true}> |
| 343 | {emoji} |
| 344 | </IconButton> |
| 345 | ))(({ theme }) => ({ |
| 346 | color: 'white', |
| 347 | fontSize: '20px', |
| 348 | height: '20px', |
| 349 | width: '20px', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 350 | })); |
| 351 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 352 | type SelectEmojiButtonProps = { |
| 353 | onEmojiSelected: (emoji: string) => void; |
| 354 | }; |
| 355 | export const SelectEmojiButton = ({ onEmojiSelected, ...props }: SelectEmojiButtonProps) => { |
| 356 | const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null); |
idillon | 1664bb2 | 2022-09-14 17:18:15 -0400 | [diff] [blame] | 357 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 358 | const handleOpenEmojiPicker = useCallback( |
| 359 | (e: MouseEvent<HTMLButtonElement>) => setAnchorEl(anchorEl ? null : e.currentTarget), |
| 360 | [anchorEl] |
| 361 | ); |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 362 | |
| 363 | const handleClose = useCallback(() => setAnchorEl(null), [setAnchorEl]); |
| 364 | |
| 365 | const onEmojiClick = useCallback( |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 366 | (e: MouseEvent, emojiObject: IEmojiData) => { |
simon | 80b7b3b | 2022-09-28 17:50:10 -0400 | [diff] [blame] | 367 | onEmojiSelected(emojiObject.emoji); |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 368 | handleClose(); |
| 369 | }, |
simon | 80b7b3b | 2022-09-28 17:50:10 -0400 | [diff] [blame] | 370 | [handleClose, onEmojiSelected] |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 371 | ); |
| 372 | |
| 373 | const open = Boolean(anchorEl); |
| 374 | const id = open ? 'simple-popover' : undefined; |
| 375 | |
| 376 | return ( |
| 377 | <ClickAwayListener onClickAway={handleClose}> |
| 378 | <Box> |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 379 | <SquareButton |
| 380 | aria-describedby={id} |
| 381 | aria-label="select emoji" |
| 382 | Icon={EmojiIcon} |
| 383 | onClick={handleOpenEmojiPicker} |
| 384 | /> |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 385 | <Popper id={id} open={open} anchorEl={anchorEl}> |
| 386 | <EmojiPicker onEmojiClick={onEmojiClick} disableAutoFocus={true} disableSkinTonePicker={true} native /> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 387 | </Popper> |
| 388 | </Box> |
| 389 | </ClickAwayListener> |
| 390 | ); |
| 391 | }; |