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 | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 18 | import { QuestionMark, RadioButtonChecked, RadioButtonUnchecked } from '@mui/icons-material'; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 19 | import { |
| 20 | Box, |
| 21 | ClickAwayListener, |
| 22 | IconButton, |
| 23 | IconButtonProps, |
| 24 | ListItemIcon, |
| 25 | ListItemText, |
| 26 | Menu, |
| 27 | MenuItem, |
| 28 | Popper, |
| 29 | Radio, |
| 30 | RadioGroup, |
| 31 | SvgIconProps, |
| 32 | } from '@mui/material'; |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 33 | import { styled } from '@mui/material/styles'; |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 34 | import EmojiPicker, { IEmojiData } from 'emoji-picker-react'; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 35 | import React, { ComponentType, MouseEvent, ReactNode, useCallback, useState } from 'react'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 36 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 37 | import { |
| 38 | Arrow2Icon, |
| 39 | Arrow3Icon, |
| 40 | ArrowIcon, |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 41 | AudioCallIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 42 | CameraIcon, |
| 43 | CameraInBubbleIcon, |
| 44 | CancelIcon, |
| 45 | CrossedEyeIcon, |
| 46 | CrossIcon, |
| 47 | EmojiIcon, |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 48 | ExpandLessIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 49 | EyeIcon, |
| 50 | FolderIcon, |
| 51 | InfoIcon, |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 52 | ListIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 53 | MicroInBubbleIcon, |
| 54 | PaperClipIcon, |
| 55 | PenIcon, |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 56 | PeopleWithPlusSignIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 57 | SaltireIcon, |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 58 | VideoCallIcon, |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 59 | } from './SvgIcon'; |
Michelle Sepkap Sime | f5ebc2e | 2022-10-27 18:30:53 -0400 | [diff] [blame] | 60 | import CustomTooltip from './Tooltip'; |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 61 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 62 | type ShapedButtonProps = IconButtonProps & { |
| 63 | Icon: ComponentType<SvgIconProps>; |
| 64 | }; |
| 65 | |
| 66 | const RoundButton = styled(({ Icon, ...props }: ShapedButtonProps) => ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 67 | <IconButton {...props} disableRipple={true}> |
| 68 | <Icon fontSize="inherit" /> |
| 69 | </IconButton> |
| 70 | ))(({ theme }) => ({ |
| 71 | border: `1px solid ${theme.palette.primary.dark}`, |
| 72 | color: theme.palette.primary.dark, |
| 73 | fontSize: '15px', |
| 74 | '&:hover': { |
| 75 | background: theme.palette.primary.light, |
| 76 | }, |
| 77 | '&:active': { |
| 78 | color: '#FFF', |
| 79 | background: theme.palette.primary.dark, |
| 80 | }, |
| 81 | '&.MuiIconButton-sizeSmall': { |
| 82 | height: '15px', |
| 83 | width: '15px', |
| 84 | }, |
| 85 | '&.MuiIconButton-sizeMedium': { |
| 86 | height: '30px', |
| 87 | width: '30px', |
| 88 | }, |
| 89 | '&.MuiIconButton-sizeLarge': { |
| 90 | height: '53px', |
| 91 | width: '53px', |
| 92 | }, |
idillon-sfl | d5cc786 | 2022-08-25 11:11:34 -0400 | [diff] [blame] | 93 | })); |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 94 | |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 95 | type ExpandMenuOption = { |
| 96 | description: ReactNode; |
| 97 | icon?: ReactNode; |
| 98 | }; |
| 99 | |
| 100 | type ExpandMenuRadioOption = { |
| 101 | options: { |
| 102 | key: string; |
| 103 | description: ReactNode; |
| 104 | }[]; |
| 105 | defaultSelectedOption?: string; |
| 106 | }; |
| 107 | |
| 108 | export type ExpandableButtonProps = IconButtonProps & { |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 109 | isVertical?: boolean; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 110 | Icon?: ComponentType<SvgIconProps>; |
| 111 | expandMenuOptions?: (ExpandMenuOption | ExpandMenuRadioOption)[]; |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 112 | IconButtonComp?: ComponentType<IconButtonProps>; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 113 | }; |
| 114 | |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 115 | export const ExpandableButton = ({ |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 116 | isVertical, |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 117 | Icon, |
| 118 | expandMenuOptions = undefined, |
| 119 | IconButtonComp = IconButton, |
| 120 | ...props |
| 121 | }: ExpandableButtonProps) => { |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 122 | const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null); |
| 123 | const handleClose = () => { |
| 124 | setAnchorEl(null); |
| 125 | }; |
| 126 | |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 127 | return ( |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 128 | <> |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 129 | {expandMenuOptions && ( |
| 130 | <Menu |
| 131 | anchorEl={anchorEl} |
| 132 | open={!!anchorEl} |
| 133 | onClose={handleClose} |
| 134 | anchorOrigin={{ |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 135 | vertical: !isVertical ? 'top' : 'center', |
| 136 | horizontal: !isVertical ? 'center' : 'left', |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 137 | }} |
| 138 | transformOrigin={{ |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 139 | vertical: !isVertical ? 'bottom' : 'center', |
| 140 | horizontal: !isVertical ? 'center' : 'right', |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 141 | }} |
| 142 | > |
| 143 | {expandMenuOptions?.map((option, id) => { |
| 144 | if ('options' in option) { |
| 145 | const { options, defaultSelectedOption } = option; |
| 146 | return ( |
| 147 | <RadioGroup key={id} defaultValue={defaultSelectedOption}> |
| 148 | {options.map(({ description, key }) => { |
| 149 | return ( |
| 150 | <MenuItem key={key}> |
| 151 | <ListItemIcon> |
| 152 | <Radio value={key} /> |
| 153 | </ListItemIcon> |
| 154 | <ListItemText>{description}</ListItemText> |
| 155 | </MenuItem> |
| 156 | ); |
| 157 | })} |
| 158 | </RadioGroup> |
| 159 | ); |
| 160 | } |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 161 | |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 162 | return ( |
| 163 | <MenuItem key={id} onClick={handleClose}> |
| 164 | <ListItemIcon>{option.icon}</ListItemIcon> |
| 165 | <ListItemText>{option.description}</ListItemText> |
| 166 | </MenuItem> |
| 167 | ); |
| 168 | })} |
| 169 | </Menu> |
| 170 | )} |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 171 | <Box position="relative" display="flex" justifyContent="center" alignItems="center"> |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 172 | {expandMenuOptions && ( |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 173 | <IconButton |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 174 | aria-label="expand options" |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 175 | onClick={(e) => setAnchorEl(e.currentTarget)} |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 176 | sx={{ |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 177 | rotate: !isVertical ? '' : '-90deg', |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 178 | position: 'absolute', |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 179 | top: !isVertical ? '-55%' : 'auto', |
| 180 | left: !isVertical ? 'auto' : '-55%', |
| 181 | zIndex: 1, |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 182 | }} |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 183 | className={props.className} |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 184 | > |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 185 | <ExpandLessIcon |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 186 | fontSize="small" |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 187 | sx={{ |
| 188 | backgroundColor: '#444444', |
| 189 | borderRadius: '5px', |
| 190 | }} |
| 191 | /> |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 192 | </IconButton> |
| 193 | )} |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 194 | <IconButtonComp {...props}>{Icon && <Icon />}</IconButtonComp> |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 195 | </Box> |
simon | 9a8fe20 | 2022-11-15 18:25:49 -0500 | [diff] [blame] | 196 | </> |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 197 | ); |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 198 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 199 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 200 | export const CancelPictureButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 201 | return <RoundButton {...props} aria-label="remove picture" Icon={CancelIcon} size="large" />; |
| 202 | }; |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 203 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 204 | export const EditPictureButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 205 | return <RoundButton {...props} aria-label="edit picture" Icon={PenIcon} size="large" />; |
| 206 | }; |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 207 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 208 | export const UploadPictureButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 209 | return <RoundButton {...props} aria-label="upload picture" Icon={FolderIcon} size="large" />; |
| 210 | }; |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 211 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 212 | export const TakePictureButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 213 | return <RoundButton {...props} aria-label="take picture" Icon={CameraIcon} size="large" />; |
| 214 | }; |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 215 | |
Michelle Sepkap Sime | f5ebc2e | 2022-10-27 18:30:53 -0400 | [diff] [blame] | 216 | type InfoButtonProps = IconButtonProps & { |
| 217 | tooltipTitle: string; |
| 218 | }; |
| 219 | export const InfoButton = ({ tooltipTitle, ...props }: InfoButtonProps) => { |
| 220 | return ( |
| 221 | <CustomTooltip className="tooltip" title={tooltipTitle}> |
| 222 | <RoundButton {...props} aria-label="informations" Icon={InfoIcon} size="small" /> |
| 223 | </CustomTooltip> |
| 224 | ); |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 225 | }; |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 226 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 227 | export const TipButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 228 | return <RoundButton {...props} aria-label="tip" Icon={QuestionMark} size="medium" />; |
| 229 | }; |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 230 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 231 | export const MoreButton = styled((props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 232 | return ( |
| 233 | <IconButton {...props} disableRipple={true} aria-label="more"> |
| 234 | <CrossIcon fontSize="inherit" /> |
| 235 | </IconButton> |
| 236 | ); |
| 237 | })(({ theme }) => ({ |
| 238 | border: `1px solid ${theme.palette.primary.dark}`, |
| 239 | color: theme.palette.primary.dark, |
| 240 | fontSize: '10px', |
| 241 | height: '20px', |
| 242 | width: '20px', |
| 243 | '&:hover': { |
| 244 | background: theme.palette.primary.light, |
| 245 | }, |
| 246 | '&:active': { |
| 247 | color: '#FFF', |
| 248 | background: theme.palette.primary.dark, |
| 249 | }, |
| 250 | })); |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 251 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 252 | export const BackButton = styled((props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 253 | return ( |
| 254 | <IconButton {...props} disableRipple={true} aria-label="back"> |
| 255 | <ArrowIcon fontSize="inherit" /> |
| 256 | </IconButton> |
| 257 | ); |
| 258 | })(({ theme }) => ({ |
| 259 | color: theme.palette.primary.dark, |
| 260 | fontSize: '15px', |
| 261 | height: '30px', |
| 262 | width: '51px', |
| 263 | borderRadius: '5px', |
| 264 | '&:hover': { |
| 265 | background: theme.palette.primary.light, |
| 266 | }, |
| 267 | })); |
idillon | b3788bf | 2022-08-29 15:57:57 -0400 | [diff] [blame] | 268 | |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 269 | export type ToggleIconButtonProps = IconButtonProps & { |
| 270 | selected: boolean; |
| 271 | toggle: () => void; |
| 272 | IconOn?: ComponentType<SvgIconProps>; |
| 273 | IconOff?: ComponentType<SvgIconProps>; |
Gabriel Rochon | e3ec0d2 | 2022-10-08 14:27:03 -0400 | [diff] [blame] | 274 | }; |
simon | 33c0618 | 2022-11-02 17:39:31 -0400 | [diff] [blame] | 275 | |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 276 | export const ToggleIconButton = ({ |
| 277 | IconOn = RadioButtonChecked, |
| 278 | IconOff = RadioButtonUnchecked, |
| 279 | selected, |
| 280 | toggle, |
| 281 | ...props |
| 282 | }: ToggleIconButtonProps) => { |
Gabriel Rochon | e3ec0d2 | 2022-10-08 14:27:03 -0400 | [diff] [blame] | 283 | return ( |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 284 | <IconButton |
| 285 | {...props} |
Gabriel Rochon | 8321a0d | 2022-11-06 23:18:36 -0500 | [diff] [blame] | 286 | sx={{ |
| 287 | color: selected ? 'white' : 'red', |
| 288 | ...props.sx, |
| 289 | }} |
simon | 1170c32 | 2022-10-31 14:51:31 -0400 | [diff] [blame] | 290 | onClick={() => { |
| 291 | toggle(); |
| 292 | }} |
| 293 | > |
| 294 | {selected ? <IconOn /> : <IconOff />} |
Gabriel Rochon | e3ec0d2 | 2022-10-08 14:27:03 -0400 | [diff] [blame] | 295 | </IconButton> |
| 296 | ); |
| 297 | }; |
| 298 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 299 | export const CloseButton = styled((props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 300 | return ( |
| 301 | <IconButton {...props} disableRipple={true} aria-label="close"> |
| 302 | <SaltireIcon fontSize="inherit" /> |
| 303 | </IconButton> |
| 304 | ); |
| 305 | })(({ theme }) => ({ |
| 306 | color: theme.palette.primary.dark, |
| 307 | fontSize: '15px', |
| 308 | height: '30px', |
| 309 | width: '30px', |
| 310 | borderRadius: '5px', |
| 311 | '&:hover': { |
| 312 | background: theme.palette.primary.light, |
| 313 | }, |
| 314 | })); |
idillon | b3788bf | 2022-08-29 15:57:57 -0400 | [diff] [blame] | 315 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 316 | type ToggleVisibilityButtonProps = IconButtonProps & { |
| 317 | visible: boolean; |
| 318 | }; |
| 319 | export const ToggleVisibilityButton = styled(({ visible, ...props }: ToggleVisibilityButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 320 | const Icon = visible ? CrossedEyeIcon : EyeIcon; |
| 321 | return ( |
| 322 | <IconButton {...props} disableRipple={true}> |
| 323 | <Icon fontSize="inherit" /> |
| 324 | </IconButton> |
| 325 | ); |
| 326 | })(({ theme }) => ({ |
| 327 | color: theme.palette.primary.dark, |
| 328 | fontSize: '15px', |
| 329 | height: '15px', |
| 330 | width: '15px', |
| 331 | '&:hover': { |
| 332 | background: theme.palette.primary.light, |
| 333 | }, |
| 334 | })); |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 335 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 336 | const SquareButton = styled(({ Icon, ...props }: ShapedButtonProps) => ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 337 | <IconButton {...props} disableRipple={true}> |
| 338 | <Icon fontSize="inherit" /> |
| 339 | </IconButton> |
simon | 416d079 | 2022-11-03 02:46:18 -0400 | [diff] [blame] | 340 | ))(() => ({ |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 341 | color: '#7E7E7E', |
| 342 | fontSize: '25px', |
| 343 | height: '36px', |
| 344 | width: '36px', |
| 345 | borderRadius: '5px', |
| 346 | '&:hover': { |
| 347 | background: '#E5E5E5', |
| 348 | }, |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 349 | })); |
| 350 | |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 351 | export const AddParticipantButton = (props: IconButtonProps) => { |
| 352 | return <SquareButton {...props} aria-label="add participant" Icon={PeopleWithPlusSignIcon} />; |
| 353 | }; |
| 354 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 355 | export const RecordVideoMessageButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 356 | return <SquareButton {...props} aria-label="record video message" Icon={CameraInBubbleIcon} />; |
| 357 | }; |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 358 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 359 | export const RecordVoiceMessageButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 360 | return <SquareButton {...props} aria-label="record voice message" Icon={MicroInBubbleIcon} />; |
| 361 | }; |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 362 | |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 363 | export const ShowOptionsMenuButton = (props: IconButtonProps) => { |
| 364 | return <SquareButton {...props} aria-label="show options menu" Icon={ListIcon} />; |
| 365 | }; |
| 366 | |
| 367 | export const StartVideoCallButton = (props: IconButtonProps) => { |
simon | cd698c5 | 2022-11-08 19:21:38 -0500 | [diff] [blame] | 368 | return <SquareButton {...props} aria-label="start audio call" Icon={VideoCallIcon} />; |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 369 | }; |
| 370 | |
| 371 | export const StartAudioCallButton = (props: IconButtonProps) => { |
simon | cd698c5 | 2022-11-08 19:21:38 -0500 | [diff] [blame] | 372 | return <SquareButton {...props} aria-label="start video call" Icon={AudioCallIcon} />; |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 373 | }; |
| 374 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 375 | export const UploadFileButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 376 | return <SquareButton {...props} aria-label="upload file" Icon={PaperClipIcon} />; |
| 377 | }; |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 378 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 379 | export const SendMessageButton = (props: IconButtonProps) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 380 | return <SquareButton {...props} aria-label="send message" Icon={Arrow2Icon} />; |
| 381 | }; |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 382 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 383 | export const ReplyMessageButton = styled((props: IconButtonProps) => ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 384 | <IconButton {...props} disableRipple={true} aria-label="send message"> |
| 385 | <Arrow3Icon fontSize="inherit" /> |
| 386 | </IconButton> |
| 387 | ))(({ theme }) => ({ |
| 388 | color: theme.palette.primary.dark, |
| 389 | fontSize: '20px', |
| 390 | height: '20px', |
| 391 | width: '20px', |
| 392 | borderRadius: '5px', |
| 393 | '&:hover': { |
| 394 | background: '#E5E5E5', |
| 395 | }, |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 396 | })); |
| 397 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 398 | type EmojiButtonProps = IconButtonProps & { |
| 399 | emoji: string; |
| 400 | }; |
| 401 | export const EmojiButton = styled(({ emoji, ...props }: EmojiButtonProps) => ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 402 | <IconButton {...props} disableRipple={true}> |
| 403 | {emoji} |
| 404 | </IconButton> |
simon | 416d079 | 2022-11-03 02:46:18 -0400 | [diff] [blame] | 405 | ))(() => ({ |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 406 | color: 'white', |
| 407 | fontSize: '20px', |
| 408 | height: '20px', |
| 409 | width: '20px', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 410 | })); |
| 411 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 412 | type SelectEmojiButtonProps = { |
| 413 | onEmojiSelected: (emoji: string) => void; |
| 414 | }; |
simon | 416d079 | 2022-11-03 02:46:18 -0400 | [diff] [blame] | 415 | export const SelectEmojiButton = ({ onEmojiSelected }: SelectEmojiButtonProps) => { |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 416 | const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null); |
idillon | 1664bb2 | 2022-09-14 17:18:15 -0400 | [diff] [blame] | 417 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 418 | const handleOpenEmojiPicker = useCallback( |
| 419 | (e: MouseEvent<HTMLButtonElement>) => setAnchorEl(anchorEl ? null : e.currentTarget), |
| 420 | [anchorEl] |
| 421 | ); |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 422 | |
| 423 | const handleClose = useCallback(() => setAnchorEl(null), [setAnchorEl]); |
| 424 | |
| 425 | const onEmojiClick = useCallback( |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 426 | (e: MouseEvent, emojiObject: IEmojiData) => { |
simon | 80b7b3b | 2022-09-28 17:50:10 -0400 | [diff] [blame] | 427 | onEmojiSelected(emojiObject.emoji); |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 428 | handleClose(); |
| 429 | }, |
simon | 80b7b3b | 2022-09-28 17:50:10 -0400 | [diff] [blame] | 430 | [handleClose, onEmojiSelected] |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 431 | ); |
| 432 | |
| 433 | const open = Boolean(anchorEl); |
| 434 | const id = open ? 'simple-popover' : undefined; |
| 435 | |
| 436 | return ( |
| 437 | <ClickAwayListener onClickAway={handleClose}> |
| 438 | <Box> |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 439 | <SquareButton |
| 440 | aria-describedby={id} |
| 441 | aria-label="select emoji" |
| 442 | Icon={EmojiIcon} |
| 443 | onClick={handleOpenEmojiPicker} |
| 444 | /> |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 445 | <Popper id={id} open={open} anchorEl={anchorEl}> |
| 446 | <EmojiPicker onEmojiClick={onEmojiClick} disableAutoFocus={true} disableSkinTonePicker={true} native /> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 447 | </Popper> |
| 448 | </Box> |
| 449 | </ClickAwayListener> |
| 450 | ); |
| 451 | }; |