blob: 1b26c0389f9287948163b928a9013191524660d2 [file] [log] [blame]
simond47ef9e2022-09-28 22:24:28 -04001import { QuestionMark } from '@mui/icons-material';
2import { Box, ClickAwayListener, IconButton, Popper } from '@mui/material';
3import { styled } from '@mui/material/styles';
4import EmojiPicker from 'emoji-picker-react';
5import React, { useState, useCallback } from 'react';
6import {
7 Arrow2Icon,
8 Arrow3Icon,
9 ArrowIcon,
10 CameraIcon,
11 CameraInBubbleIcon,
12 CancelIcon,
13 CrossedEyeIcon,
14 CrossIcon,
15 EmojiIcon,
16 EyeIcon,
17 FolderIcon,
18 InfoIcon,
19 MicroInBubbleIcon,
20 PaperClipIcon,
21 PenIcon,
22 SaltireIcon,
23} from './svgIcons';
idillon-sfl44b05342022-08-24 15:46:42 -040024
simond47ef9e2022-09-28 22:24:28 -040025const RoundButton = styled(({ Icon, ...props }) => (
26 <IconButton {...props} disableRipple={true}>
27 <Icon fontSize="inherit" />
28 </IconButton>
29))(({ theme }) => ({
30 border: `1px solid ${theme.palette.primary.dark}`,
31 color: theme.palette.primary.dark,
32 fontSize: '15px',
33 '&:hover': {
34 background: theme.palette.primary.light,
35 },
36 '&:active': {
37 color: '#FFF',
38 background: theme.palette.primary.dark,
39 },
40 '&.MuiIconButton-sizeSmall': {
41 height: '15px',
42 width: '15px',
43 },
44 '&.MuiIconButton-sizeMedium': {
45 height: '30px',
46 width: '30px',
47 },
48 '&.MuiIconButton-sizeLarge': {
49 height: '53px',
50 width: '53px',
51 },
idillon-sfld5cc7862022-08-25 11:11:34 -040052}));
idillon-sfl44b05342022-08-24 15:46:42 -040053
idillonaedab942022-09-01 14:29:43 -040054export const CancelPictureButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -040055 return <RoundButton {...props} aria-label="remove picture" Icon={CancelIcon} size="large" />;
56};
idillon-sfl44b05342022-08-24 15:46:42 -040057
idillonaedab942022-09-01 14:29:43 -040058export const EditPictureButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -040059 return <RoundButton {...props} aria-label="edit picture" Icon={PenIcon} size="large" />;
60};
idillon-sfl44b05342022-08-24 15:46:42 -040061
idillonaedab942022-09-01 14:29:43 -040062export const UploadPictureButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -040063 return <RoundButton {...props} aria-label="upload picture" Icon={FolderIcon} size="large" />;
64};
idillon-sfl44b05342022-08-24 15:46:42 -040065
66export const TakePictureButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -040067 return <RoundButton {...props} aria-label="take picture" Icon={CameraIcon} size="large" />;
68};
idillon-sfl37c18df2022-08-26 18:44:27 -040069
70export const InfoButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -040071 return <RoundButton {...props} aria-label="informations" Icon={InfoIcon} size="small" />;
72};
idillon-sfl37c18df2022-08-26 18:44:27 -040073
74export const TipButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -040075 return <RoundButton {...props} aria-label="tip" Icon={QuestionMark} size="medium" />;
76};
idillon-sfl37c18df2022-08-26 18:44:27 -040077
simond47ef9e2022-09-28 22:24:28 -040078export const MoreButton = styled((props) => {
79 return (
80 <IconButton {...props} disableRipple={true} aria-label="more">
81 <CrossIcon fontSize="inherit" />
82 </IconButton>
83 );
84})(({ theme }) => ({
85 border: `1px solid ${theme.palette.primary.dark}`,
86 color: theme.palette.primary.dark,
87 fontSize: '10px',
88 height: '20px',
89 width: '20px',
90 '&:hover': {
91 background: theme.palette.primary.light,
92 },
93 '&:active': {
94 color: '#FFF',
95 background: theme.palette.primary.dark,
96 },
97}));
idillon927b7592022-09-15 12:56:45 -040098
simond47ef9e2022-09-28 22:24:28 -040099export const BackButton = styled((props) => {
100 return (
101 <IconButton {...props} disableRipple={true} aria-label="back">
102 <ArrowIcon fontSize="inherit" />
103 </IconButton>
104 );
105})(({ theme }) => ({
106 color: theme.palette.primary.dark,
107 fontSize: '15px',
108 height: '30px',
109 width: '51px',
110 borderRadius: '5px',
111 '&:hover': {
112 background: theme.palette.primary.light,
113 },
114}));
idillonb3788bf2022-08-29 15:57:57 -0400115
simond47ef9e2022-09-28 22:24:28 -0400116export const CloseButton = styled((props) => {
117 return (
118 <IconButton {...props} disableRipple={true} aria-label="close">
119 <SaltireIcon fontSize="inherit" />
120 </IconButton>
121 );
122})(({ theme }) => ({
123 color: theme.palette.primary.dark,
124 fontSize: '15px',
125 height: '30px',
126 width: '30px',
127 borderRadius: '5px',
128 '&:hover': {
129 background: theme.palette.primary.light,
130 },
131}));
idillonb3788bf2022-08-29 15:57:57 -0400132
simond47ef9e2022-09-28 22:24:28 -0400133export const ToggleVisibilityButton = styled(({ visible, ...props }) => {
134 const Icon = visible ? CrossedEyeIcon : EyeIcon;
135 return (
136 <IconButton {...props} disableRipple={true}>
137 <Icon fontSize="inherit" />
138 </IconButton>
139 );
140})(({ theme }) => ({
141 color: theme.palette.primary.dark,
142 fontSize: '15px',
143 height: '15px',
144 width: '15px',
145 '&:hover': {
146 background: theme.palette.primary.light,
147 },
148}));
idillonaedab942022-09-01 14:29:43 -0400149
simond47ef9e2022-09-28 22:24:28 -0400150const SquareButton = styled(({ Icon, ...props }) => (
151 <IconButton {...props} disableRipple={true}>
152 <Icon fontSize="inherit" />
153 </IconButton>
154))(({ theme }) => ({
155 color: '#7E7E7E',
156 fontSize: '25px',
157 height: '36px',
158 width: '36px',
159 borderRadius: '5px',
160 '&:hover': {
161 background: '#E5E5E5',
162 },
idillonaedab942022-09-01 14:29:43 -0400163}));
164
165export const RecordVideoMessageButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -0400166 return <SquareButton {...props} aria-label="record video message" Icon={CameraInBubbleIcon} />;
167};
idillonaedab942022-09-01 14:29:43 -0400168
169export const RecordVoiceMessageButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -0400170 return <SquareButton {...props} aria-label="record voice message" Icon={MicroInBubbleIcon} />;
171};
idillonaedab942022-09-01 14:29:43 -0400172
173export const UploadFileButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -0400174 return <SquareButton {...props} aria-label="upload file" Icon={PaperClipIcon} />;
175};
idillonaedab942022-09-01 14:29:43 -0400176
177export const SendMessageButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -0400178 return <SquareButton {...props} aria-label="send message" Icon={Arrow2Icon} />;
179};
idillonaedab942022-09-01 14:29:43 -0400180
simond47ef9e2022-09-28 22:24:28 -0400181export const ReplyMessageButton = styled(({ Icon, ...props }) => (
182 <IconButton {...props} disableRipple={true} aria-label="send message">
183 <Arrow3Icon fontSize="inherit" />
184 </IconButton>
185))(({ theme }) => ({
186 color: theme.palette.primary.dark,
187 fontSize: '20px',
188 height: '20px',
189 width: '20px',
190 borderRadius: '5px',
191 '&:hover': {
192 background: '#E5E5E5',
193 },
idillon927b7592022-09-15 12:56:45 -0400194}));
195
simond47ef9e2022-09-28 22:24:28 -0400196export const EmojiButton = styled(({ emoji, ...props }) => (
197 <IconButton {...props} disableRipple={true}>
198 {emoji}
199 </IconButton>
200))(({ theme }) => ({
201 color: 'white',
202 fontSize: '20px',
203 height: '20px',
204 width: '20px',
idillon927b7592022-09-15 12:56:45 -0400205}));
206
idillonaedab942022-09-01 14:29:43 -0400207export const SelectEmojiButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -0400208 const [anchorEl, setAnchorEl] = useState(null);
idillon1664bb22022-09-14 17:18:15 -0400209
simond47ef9e2022-09-28 22:24:28 -0400210 const handleOpenEmojiPicker = useCallback((e) => setAnchorEl(anchorEl ? null : e.currentTarget), [anchorEl]);
211
212 const handleClose = useCallback(() => setAnchorEl(null), [setAnchorEl]);
213
214 const onEmojiClick = useCallback(
215 (e, emojiObject) => {
216 props.onEmojiSelected(emojiObject.emoji);
217 handleClose();
218 },
219 [handleClose, props.onEmojiSelected]
220 );
221
222 const open = Boolean(anchorEl);
223 const id = open ? 'simple-popover' : undefined;
224
225 return (
226 <ClickAwayListener onClickAway={handleClose}>
227 <Box>
228 <SquareButton
229 aria-describedby={id}
230 aria-label="select emoji"
231 Icon={EmojiIcon}
232 onClick={handleOpenEmojiPicker}
233 />
234 <Popper id={id} open={open} anchorEl={anchorEl} onClose={handleClose}>
235 <EmojiPicker.default
236 onEmojiClick={onEmojiClick}
237 disableAutoFocus={true}
238 disableSkinTonePicker={true}
239 native
240 />
241 </Popper>
242 </Box>
243 </ClickAwayListener>
244 );
245};