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