blob: 0f7666e5fb4c4ee2263e8611e807e302f91b1741 [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';
simon07b4eb02022-09-29 17:50:26 -04005import React, { useCallback, useState } from 'react';
6
simond47ef9e2022-09-28 22:24:28 -04007import {
8 Arrow2Icon,
9 Arrow3Icon,
10 ArrowIcon,
11 CameraIcon,
12 CameraInBubbleIcon,
13 CancelIcon,
14 CrossedEyeIcon,
15 CrossIcon,
16 EmojiIcon,
17 EyeIcon,
18 FolderIcon,
19 InfoIcon,
20 MicroInBubbleIcon,
21 PaperClipIcon,
22 PenIcon,
23 SaltireIcon,
24} from './svgIcons';
idillon-sfl44b05342022-08-24 15:46:42 -040025
simond47ef9e2022-09-28 22:24:28 -040026const RoundButton = styled(({ Icon, ...props }) => (
27 <IconButton {...props} disableRipple={true}>
28 <Icon fontSize="inherit" />
29 </IconButton>
30))(({ theme }) => ({
31 border: `1px solid ${theme.palette.primary.dark}`,
32 color: theme.palette.primary.dark,
33 fontSize: '15px',
34 '&:hover': {
35 background: theme.palette.primary.light,
36 },
37 '&:active': {
38 color: '#FFF',
39 background: theme.palette.primary.dark,
40 },
41 '&.MuiIconButton-sizeSmall': {
42 height: '15px',
43 width: '15px',
44 },
45 '&.MuiIconButton-sizeMedium': {
46 height: '30px',
47 width: '30px',
48 },
49 '&.MuiIconButton-sizeLarge': {
50 height: '53px',
51 width: '53px',
52 },
idillon-sfld5cc7862022-08-25 11:11:34 -040053}));
idillon-sfl44b05342022-08-24 15:46:42 -040054
idillonaedab942022-09-01 14:29:43 -040055export const CancelPictureButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -040056 return <RoundButton {...props} aria-label="remove picture" Icon={CancelIcon} size="large" />;
57};
idillon-sfl44b05342022-08-24 15:46:42 -040058
idillonaedab942022-09-01 14:29:43 -040059export const EditPictureButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -040060 return <RoundButton {...props} aria-label="edit picture" Icon={PenIcon} size="large" />;
61};
idillon-sfl44b05342022-08-24 15:46:42 -040062
idillonaedab942022-09-01 14:29:43 -040063export const UploadPictureButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -040064 return <RoundButton {...props} aria-label="upload picture" Icon={FolderIcon} size="large" />;
65};
idillon-sfl44b05342022-08-24 15:46:42 -040066
67export const TakePictureButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -040068 return <RoundButton {...props} aria-label="take picture" Icon={CameraIcon} size="large" />;
69};
idillon-sfl37c18df2022-08-26 18:44:27 -040070
71export const InfoButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -040072 return <RoundButton {...props} aria-label="informations" Icon={InfoIcon} size="small" />;
73};
idillon-sfl37c18df2022-08-26 18:44:27 -040074
75export const TipButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -040076 return <RoundButton {...props} aria-label="tip" Icon={QuestionMark} size="medium" />;
77};
idillon-sfl37c18df2022-08-26 18:44:27 -040078
simond47ef9e2022-09-28 22:24:28 -040079export const MoreButton = styled((props) => {
80 return (
81 <IconButton {...props} disableRipple={true} aria-label="more">
82 <CrossIcon fontSize="inherit" />
83 </IconButton>
84 );
85})(({ theme }) => ({
86 border: `1px solid ${theme.palette.primary.dark}`,
87 color: theme.palette.primary.dark,
88 fontSize: '10px',
89 height: '20px',
90 width: '20px',
91 '&:hover': {
92 background: theme.palette.primary.light,
93 },
94 '&:active': {
95 color: '#FFF',
96 background: theme.palette.primary.dark,
97 },
98}));
idillon927b7592022-09-15 12:56:45 -040099
simond47ef9e2022-09-28 22:24:28 -0400100export const BackButton = styled((props) => {
101 return (
102 <IconButton {...props} disableRipple={true} aria-label="back">
103 <ArrowIcon fontSize="inherit" />
104 </IconButton>
105 );
106})(({ theme }) => ({
107 color: theme.palette.primary.dark,
108 fontSize: '15px',
109 height: '30px',
110 width: '51px',
111 borderRadius: '5px',
112 '&:hover': {
113 background: theme.palette.primary.light,
114 },
115}));
idillonb3788bf2022-08-29 15:57:57 -0400116
simond47ef9e2022-09-28 22:24:28 -0400117export const CloseButton = styled((props) => {
118 return (
119 <IconButton {...props} disableRipple={true} aria-label="close">
120 <SaltireIcon fontSize="inherit" />
121 </IconButton>
122 );
123})(({ theme }) => ({
124 color: theme.palette.primary.dark,
125 fontSize: '15px',
126 height: '30px',
127 width: '30px',
128 borderRadius: '5px',
129 '&:hover': {
130 background: theme.palette.primary.light,
131 },
132}));
idillonb3788bf2022-08-29 15:57:57 -0400133
simond47ef9e2022-09-28 22:24:28 -0400134export const ToggleVisibilityButton = styled(({ visible, ...props }) => {
135 const Icon = visible ? CrossedEyeIcon : EyeIcon;
136 return (
137 <IconButton {...props} disableRipple={true}>
138 <Icon fontSize="inherit" />
139 </IconButton>
140 );
141})(({ theme }) => ({
142 color: theme.palette.primary.dark,
143 fontSize: '15px',
144 height: '15px',
145 width: '15px',
146 '&:hover': {
147 background: theme.palette.primary.light,
148 },
149}));
idillonaedab942022-09-01 14:29:43 -0400150
simond47ef9e2022-09-28 22:24:28 -0400151const SquareButton = styled(({ Icon, ...props }) => (
152 <IconButton {...props} disableRipple={true}>
153 <Icon fontSize="inherit" />
154 </IconButton>
155))(({ theme }) => ({
156 color: '#7E7E7E',
157 fontSize: '25px',
158 height: '36px',
159 width: '36px',
160 borderRadius: '5px',
161 '&:hover': {
162 background: '#E5E5E5',
163 },
idillonaedab942022-09-01 14:29:43 -0400164}));
165
166export const RecordVideoMessageButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -0400167 return <SquareButton {...props} aria-label="record video message" Icon={CameraInBubbleIcon} />;
168};
idillonaedab942022-09-01 14:29:43 -0400169
170export const RecordVoiceMessageButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -0400171 return <SquareButton {...props} aria-label="record voice message" Icon={MicroInBubbleIcon} />;
172};
idillonaedab942022-09-01 14:29:43 -0400173
174export const UploadFileButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -0400175 return <SquareButton {...props} aria-label="upload file" Icon={PaperClipIcon} />;
176};
idillonaedab942022-09-01 14:29:43 -0400177
178export const SendMessageButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -0400179 return <SquareButton {...props} aria-label="send message" Icon={Arrow2Icon} />;
180};
idillonaedab942022-09-01 14:29:43 -0400181
simond47ef9e2022-09-28 22:24:28 -0400182export const ReplyMessageButton = styled(({ Icon, ...props }) => (
183 <IconButton {...props} disableRipple={true} aria-label="send message">
184 <Arrow3Icon fontSize="inherit" />
185 </IconButton>
186))(({ theme }) => ({
187 color: theme.palette.primary.dark,
188 fontSize: '20px',
189 height: '20px',
190 width: '20px',
191 borderRadius: '5px',
192 '&:hover': {
193 background: '#E5E5E5',
194 },
idillon927b7592022-09-15 12:56:45 -0400195}));
196
simond47ef9e2022-09-28 22:24:28 -0400197export const EmojiButton = styled(({ emoji, ...props }) => (
198 <IconButton {...props} disableRipple={true}>
199 {emoji}
200 </IconButton>
201))(({ theme }) => ({
202 color: 'white',
203 fontSize: '20px',
204 height: '20px',
205 width: '20px',
idillon927b7592022-09-15 12:56:45 -0400206}));
207
idillonaedab942022-09-01 14:29:43 -0400208export const SelectEmojiButton = (props) => {
simond47ef9e2022-09-28 22:24:28 -0400209 const [anchorEl, setAnchorEl] = useState(null);
idillon1664bb22022-09-14 17:18:15 -0400210
simond47ef9e2022-09-28 22:24:28 -0400211 const handleOpenEmojiPicker = useCallback((e) => setAnchorEl(anchorEl ? null : e.currentTarget), [anchorEl]);
212
213 const handleClose = useCallback(() => setAnchorEl(null), [setAnchorEl]);
214
215 const onEmojiClick = useCallback(
216 (e, emojiObject) => {
217 props.onEmojiSelected(emojiObject.emoji);
218 handleClose();
219 },
220 [handleClose, props.onEmojiSelected]
221 );
222
223 const open = Boolean(anchorEl);
224 const id = open ? 'simple-popover' : undefined;
225
226 return (
227 <ClickAwayListener onClickAway={handleClose}>
228 <Box>
229 <SquareButton
230 aria-describedby={id}
231 aria-label="select emoji"
232 Icon={EmojiIcon}
233 onClick={handleOpenEmojiPicker}
234 />
235 <Popper id={id} open={open} anchorEl={anchorEl} onClose={handleClose}>
236 <EmojiPicker.default
237 onEmojiClick={onEmojiClick}
238 disableAutoFocus={true}
239 disableSkinTonePicker={true}
240 native
241 />
242 </Popper>
243 </Box>
244 </ClickAwayListener>
245 );
246};