idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 1 | import { QuestionMark } from "@mui/icons-material"; |
idillon | 1664bb2 | 2022-09-14 17:18:15 -0400 | [diff] [blame] | 2 | import { Box, ClickAwayListener, IconButton, Popper } from "@mui/material"; |
idillon | fb2af5b | 2022-09-16 13:40:08 -0400 | [diff] [blame] | 3 | import { styled } from "@mui/material/styles"; |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 4 | import EmojiPicker from "emoji-picker-react"; |
| 5 | import React from "react"; |
| 6 | import { Arrow2Icon, ArrowIcon, CameraIcon, CameraInBubbleIcon, CancelIcon, CrossedEyeIcon, CrossIcon, EmojiIcon, EyeIcon, FolderIcon, InfoIcon, MicroInBubbleIcon, PaperClipIcon, PenIcon } from "./svgIcons"; |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 7 | |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 8 | const RoundButton = styled( |
idillon-sfl | d5cc786 | 2022-08-25 11:11:34 -0400 | [diff] [blame] | 9 | ({Icon, ...props}) => ( |
| 10 | <IconButton {...props} disableRipple={true}> |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 11 | <Icon fontSize="inherit"/> |
| 12 | </IconButton> |
| 13 | ) |
idillon-sfl | deabd28 | 2022-08-25 22:50:03 -0400 | [diff] [blame] | 14 | )(({theme}) => ({ |
| 15 | border: `1px solid ${theme.palette.primary.dark}`, |
| 16 | color: theme.palette.primary.dark, |
idillon-sfl | d5cc786 | 2022-08-25 11:11:34 -0400 | [diff] [blame] | 17 | fontSize: "15px", |
| 18 | "&:hover": { |
idillon-sfl | deabd28 | 2022-08-25 22:50:03 -0400 | [diff] [blame] | 19 | background: theme.palette.primary.light, |
idillon-sfl | d5cc786 | 2022-08-25 11:11:34 -0400 | [diff] [blame] | 20 | }, |
| 21 | "&:active": { |
| 22 | color: "#FFF", |
idillon-sfl | deabd28 | 2022-08-25 22:50:03 -0400 | [diff] [blame] | 23 | background: theme.palette.primary.dark, |
idillon-sfl | d5cc786 | 2022-08-25 11:11:34 -0400 | [diff] [blame] | 24 | }, |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 25 | "&.MuiIconButton-sizeSmall": { |
| 26 | height: "15px", |
| 27 | width: "15px", |
| 28 | }, |
| 29 | "&.MuiIconButton-sizeMedium": { |
| 30 | height: "30px", |
| 31 | width: "30px", |
| 32 | }, |
| 33 | "&.MuiIconButton-sizeLarge": { |
| 34 | height: "53px", |
| 35 | width: "53px", |
| 36 | } |
idillon-sfl | d5cc786 | 2022-08-25 11:11:34 -0400 | [diff] [blame] | 37 | })); |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 38 | |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 39 | export const CancelPictureButton = (props) => { |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 40 | return ( |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 41 | <RoundButton {...props} |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 42 | aria-label="remove picture" |
| 43 | Icon={CancelIcon} |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 44 | size="large" |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 45 | /> |
| 46 | ) |
| 47 | } |
| 48 | |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 49 | export const EditPictureButton = (props) => { |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 50 | return ( |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 51 | <RoundButton {...props} |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 52 | aria-label="edit picture" |
| 53 | Icon={PenIcon} |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 54 | size="large" |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 55 | /> |
| 56 | ) |
| 57 | } |
| 58 | |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 59 | export const UploadPictureButton = (props) => { |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 60 | return ( |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 61 | <RoundButton {...props} |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 62 | aria-label="upload picture" |
| 63 | Icon={FolderIcon} |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 64 | size="large" |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 65 | /> |
| 66 | ) |
| 67 | } |
| 68 | |
| 69 | export const TakePictureButton = (props) => { |
| 70 | return ( |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 71 | <RoundButton {...props} |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 72 | aria-label="take picture" |
| 73 | Icon={CameraIcon} |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 74 | size="large" |
idillon-sfl | 44b0534 | 2022-08-24 15:46:42 -0400 | [diff] [blame] | 75 | /> |
| 76 | ) |
| 77 | } |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 78 | |
| 79 | export const InfoButton = (props) => { |
| 80 | return ( |
| 81 | <RoundButton {...props} |
| 82 | aria-label="informations" |
| 83 | Icon={InfoIcon} |
| 84 | size="small" |
| 85 | /> |
| 86 | ) |
| 87 | } |
| 88 | |
| 89 | export const TipButton = (props) => { |
| 90 | return ( |
| 91 | <RoundButton {...props} |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 92 | aria-label="tip" |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 93 | Icon={QuestionMark} |
| 94 | size="medium" |
| 95 | /> |
| 96 | ) |
| 97 | } |
| 98 | |
idillon | b3788bf | 2022-08-29 15:57:57 -0400 | [diff] [blame] | 99 | export const BackButton = styled( |
| 100 | (props) => { |
| 101 | return ( |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 102 | <IconButton |
| 103 | {...props} |
| 104 | disableRipple={true} |
| 105 | aria-label="back" |
| 106 | > |
idillon | b3788bf | 2022-08-29 15:57:57 -0400 | [diff] [blame] | 107 | <ArrowIcon fontSize="inherit"/> |
| 108 | </IconButton> |
| 109 | ) |
| 110 | } |
| 111 | )(({theme}) => ({ |
| 112 | color: theme.palette.primary.dark, |
| 113 | fontSize: "15px", |
| 114 | height: "30px", |
| 115 | width: "51px", |
| 116 | borderRadius: "5px", |
| 117 | "&:hover": { |
| 118 | background: theme.palette.primary.light, |
| 119 | }, |
| 120 | })) |
| 121 | |
| 122 | export const CloseButton = styled( |
| 123 | (props) => { |
| 124 | return ( |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 125 | <IconButton |
| 126 | {...props} |
| 127 | disableRipple={true} |
| 128 | aria-label="close" |
| 129 | > |
idillon | b3788bf | 2022-08-29 15:57:57 -0400 | [diff] [blame] | 130 | <CrossIcon fontSize="inherit"/> |
| 131 | </IconButton> |
| 132 | ) |
| 133 | } |
| 134 | )(({theme}) => ({ |
| 135 | color: theme.palette.primary.dark, |
| 136 | fontSize: "15px", |
| 137 | height: "30px", |
| 138 | width: "30px", |
| 139 | borderRadius: "5px", |
| 140 | "&:hover": { |
| 141 | background: theme.palette.primary.light, |
| 142 | }, |
| 143 | })) |
| 144 | |
idillon-sfl | 37c18df | 2022-08-26 18:44:27 -0400 | [diff] [blame] | 145 | export const ToggleVisibilityButton = styled( |
| 146 | ({visible, ...props}) => { |
| 147 | const Icon = visible ? CrossedEyeIcon : EyeIcon |
| 148 | return ( |
| 149 | <IconButton {...props} disableRipple={true}> |
| 150 | <Icon fontSize="inherit"/> |
| 151 | </IconButton> |
| 152 | ) |
| 153 | } |
| 154 | )(({theme}) => ({ |
| 155 | color: theme.palette.primary.dark, |
| 156 | fontSize: "15px", |
| 157 | height: "15px", |
| 158 | width: "15px", |
| 159 | "&:hover": { |
| 160 | background: theme.palette.primary.light, |
| 161 | }, |
idillon | b3788bf | 2022-08-29 15:57:57 -0400 | [diff] [blame] | 162 | })) |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 163 | |
| 164 | const SquareButton = styled( |
| 165 | ({Icon, ...props}) => ( |
| 166 | <IconButton {...props} disableRipple={true}> |
| 167 | <Icon fontSize="inherit"/> |
| 168 | </IconButton> |
| 169 | ) |
| 170 | )(({theme}) => ({ |
| 171 | color: "#7E7E7E", |
| 172 | fontSize: "25px", |
| 173 | height: "36px", |
| 174 | width: "36px", |
| 175 | borderRadius: "5px", |
| 176 | "&:hover": { |
| 177 | background: "#E5E5E5", |
| 178 | }, |
| 179 | })); |
| 180 | |
| 181 | export const RecordVideoMessageButton = (props) => { |
| 182 | return ( |
| 183 | <SquareButton {...props} |
| 184 | aria-label="record video message" |
| 185 | Icon={CameraInBubbleIcon} |
| 186 | /> |
| 187 | ) |
| 188 | } |
| 189 | |
| 190 | export const RecordVoiceMessageButton = (props) => { |
| 191 | return ( |
| 192 | <SquareButton {...props} |
| 193 | aria-label="record voice message" |
| 194 | Icon={MicroInBubbleIcon} |
| 195 | /> |
| 196 | ) |
| 197 | } |
| 198 | |
| 199 | export const UploadFileButton = (props) => { |
| 200 | return ( |
| 201 | <SquareButton {...props} |
| 202 | aria-label="upload file" |
| 203 | Icon={PaperClipIcon} |
| 204 | /> |
| 205 | ) |
| 206 | } |
| 207 | |
| 208 | export const SendMessageButton = (props) => { |
| 209 | return ( |
| 210 | <SquareButton {...props} |
| 211 | aria-label="send message" |
| 212 | Icon={Arrow2Icon} |
| 213 | /> |
| 214 | ) |
| 215 | } |
| 216 | |
| 217 | export const SelectEmojiButton = (props) => { |
| 218 | const [anchorEl, setAnchorEl] = React.useState(null) |
| 219 | |
| 220 | const handleOpenEmojiPicker = React.useCallback( |
| 221 | e => setAnchorEl(anchorEl ? null : e.currentTarget), |
| 222 | [anchorEl], |
| 223 | ) |
| 224 | |
| 225 | const handleClose = React.useCallback( |
| 226 | () => setAnchorEl(null), |
| 227 | [setAnchorEl], |
| 228 | ) |
| 229 | |
| 230 | const onEmojiClick = React.useCallback( |
| 231 | (e, emojiObject) => { |
| 232 | props.onEmojiSelected(emojiObject.emoji) |
| 233 | handleClose() |
| 234 | }, |
| 235 | [handleClose, props.onEmojiSelected], |
| 236 | ) |
| 237 | |
| 238 | const open = Boolean(anchorEl) |
| 239 | const id = open ? 'simple-popover' : undefined |
| 240 | |
| 241 | return ( |
idillon | 1664bb2 | 2022-09-14 17:18:15 -0400 | [diff] [blame] | 242 | <ClickAwayListener onClickAway={handleClose}> |
| 243 | <Box> |
| 244 | <SquareButton |
| 245 | aria-describedby={id} |
| 246 | aria-label="select emoji" |
| 247 | Icon={EmojiIcon} |
| 248 | onClick={handleOpenEmojiPicker} |
| 249 | /> |
| 250 | <Popper |
| 251 | id={id} |
| 252 | open={open} |
| 253 | anchorEl={anchorEl} |
| 254 | onClose={handleClose} |
| 255 | > |
| 256 | <EmojiPicker.default |
| 257 | onEmojiClick={onEmojiClick} |
| 258 | disableAutoFocus={true} |
| 259 | disableSkinTonePicker={true} |
| 260 | native |
| 261 | /> |
| 262 | </Popper> |
| 263 | </Box> |
| 264 | </ClickAwayListener> |
idillon | aedab94 | 2022-09-01 14:29:43 -0400 | [diff] [blame] | 265 | ) |
idillon | 1664bb2 | 2022-09-14 17:18:15 -0400 | [diff] [blame] | 266 | } |
| 267 | |