blob: feb5531be4102416a6c120594d65d4c2a1237b7c [file] [log] [blame]
idillon-sfl37c18df2022-08-26 18:44:27 -04001import { QuestionMark } from "@mui/icons-material";
idillonaedab942022-09-01 14:29:43 -04002import { Box, IconButton, Popper } from "@mui/material";
idillonfb2af5b2022-09-16 13:40:08 -04003import { styled } from "@mui/material/styles";
idillonaedab942022-09-01 14:29:43 -04004import EmojiPicker from "emoji-picker-react";
5import React from "react";
6import { Arrow2Icon, ArrowIcon, CameraIcon, CameraInBubbleIcon, CancelIcon, CrossedEyeIcon, CrossIcon, EmojiIcon, EyeIcon, FolderIcon, InfoIcon, MicroInBubbleIcon, PaperClipIcon, PenIcon } from "./svgIcons";
idillon-sfl44b05342022-08-24 15:46:42 -04007
idillon-sfl37c18df2022-08-26 18:44:27 -04008const RoundButton = styled(
idillon-sfld5cc7862022-08-25 11:11:34 -04009 ({Icon, ...props}) => (
10 <IconButton {...props} disableRipple={true}>
idillon-sfl44b05342022-08-24 15:46:42 -040011 <Icon fontSize="inherit"/>
12 </IconButton>
13 )
idillon-sfldeabd282022-08-25 22:50:03 -040014)(({theme}) => ({
15 border: `1px solid ${theme.palette.primary.dark}`,
16 color: theme.palette.primary.dark,
idillon-sfld5cc7862022-08-25 11:11:34 -040017 fontSize: "15px",
18 "&:hover": {
idillon-sfldeabd282022-08-25 22:50:03 -040019 background: theme.palette.primary.light,
idillon-sfld5cc7862022-08-25 11:11:34 -040020 },
21 "&:active": {
22 color: "#FFF",
idillon-sfldeabd282022-08-25 22:50:03 -040023 background: theme.palette.primary.dark,
idillon-sfld5cc7862022-08-25 11:11:34 -040024 },
idillon-sfl37c18df2022-08-26 18:44:27 -040025 "&.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-sfld5cc7862022-08-25 11:11:34 -040037}));
idillon-sfl44b05342022-08-24 15:46:42 -040038
idillonaedab942022-09-01 14:29:43 -040039export const CancelPictureButton = (props) => {
idillon-sfl44b05342022-08-24 15:46:42 -040040 return (
idillon-sfl37c18df2022-08-26 18:44:27 -040041 <RoundButton {...props}
idillon-sfl44b05342022-08-24 15:46:42 -040042 aria-label="remove picture"
43 Icon={CancelIcon}
idillon-sfl37c18df2022-08-26 18:44:27 -040044 size="large"
idillon-sfl44b05342022-08-24 15:46:42 -040045 />
46 )
47}
48
idillonaedab942022-09-01 14:29:43 -040049export const EditPictureButton = (props) => {
idillon-sfl44b05342022-08-24 15:46:42 -040050 return (
idillon-sfl37c18df2022-08-26 18:44:27 -040051 <RoundButton {...props}
idillon-sfl44b05342022-08-24 15:46:42 -040052 aria-label="edit picture"
53 Icon={PenIcon}
idillon-sfl37c18df2022-08-26 18:44:27 -040054 size="large"
idillon-sfl44b05342022-08-24 15:46:42 -040055 />
56 )
57}
58
idillonaedab942022-09-01 14:29:43 -040059export const UploadPictureButton = (props) => {
idillon-sfl44b05342022-08-24 15:46:42 -040060 return (
idillon-sfl37c18df2022-08-26 18:44:27 -040061 <RoundButton {...props}
idillon-sfl44b05342022-08-24 15:46:42 -040062 aria-label="upload picture"
63 Icon={FolderIcon}
idillon-sfl37c18df2022-08-26 18:44:27 -040064 size="large"
idillon-sfl44b05342022-08-24 15:46:42 -040065 />
66 )
67}
68
69export const TakePictureButton = (props) => {
70 return (
idillon-sfl37c18df2022-08-26 18:44:27 -040071 <RoundButton {...props}
idillon-sfl44b05342022-08-24 15:46:42 -040072 aria-label="take picture"
73 Icon={CameraIcon}
idillon-sfl37c18df2022-08-26 18:44:27 -040074 size="large"
idillon-sfl44b05342022-08-24 15:46:42 -040075 />
76 )
77}
idillon-sfl37c18df2022-08-26 18:44:27 -040078
79export const InfoButton = (props) => {
80 return (
81 <RoundButton {...props}
82 aria-label="informations"
83 Icon={InfoIcon}
84 size="small"
85 />
86 )
87}
88
89export const TipButton = (props) => {
90 return (
91 <RoundButton {...props}
idillonaedab942022-09-01 14:29:43 -040092 aria-label="tip"
idillon-sfl37c18df2022-08-26 18:44:27 -040093 Icon={QuestionMark}
94 size="medium"
95 />
96 )
97}
98
idillonb3788bf2022-08-29 15:57:57 -040099export const BackButton = styled(
100 (props) => {
101 return (
idillonaedab942022-09-01 14:29:43 -0400102 <IconButton
103 {...props}
104 disableRipple={true}
105 aria-label="back"
106 >
idillonb3788bf2022-08-29 15:57:57 -0400107 <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
122export const CloseButton = styled(
123 (props) => {
124 return (
idillonaedab942022-09-01 14:29:43 -0400125 <IconButton
126 {...props}
127 disableRipple={true}
128 aria-label="close"
129 >
idillonb3788bf2022-08-29 15:57:57 -0400130 <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-sfl37c18df2022-08-26 18:44:27 -0400145export 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 },
idillonb3788bf2022-08-29 15:57:57 -0400162}))
idillonaedab942022-09-01 14:29:43 -0400163
164const 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
181export const RecordVideoMessageButton = (props) => {
182 return (
183 <SquareButton {...props}
184 aria-label="record video message"
185 Icon={CameraInBubbleIcon}
186 />
187 )
188}
189
190export const RecordVoiceMessageButton = (props) => {
191 return (
192 <SquareButton {...props}
193 aria-label="record voice message"
194 Icon={MicroInBubbleIcon}
195 />
196 )
197}
198
199export const UploadFileButton = (props) => {
200 return (
201 <SquareButton {...props}
202 aria-label="upload file"
203 Icon={PaperClipIcon}
204 />
205 )
206}
207
208export const SendMessageButton = (props) => {
209 return (
210 <SquareButton {...props}
211 aria-label="send message"
212 Icon={Arrow2Icon}
213 />
214 )
215}
216
217export 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 (
242 <Box>
243 <SquareButton
244 aria-describedby={id}
245 aria-label="select emoji"
246 Icon={EmojiIcon}
247 onClick={handleOpenEmojiPicker}
248 />
249 <Popper
250 id={id}
251 open={open}
252 anchorEl={anchorEl}
253 onClose={handleClose}
254 >
255 <EmojiPicker.default
256 onEmojiClick={onEmojiClick}
257 disableAutoFocus={true}
258 disableSkinTonePicker={true}
259 native
260 />
261 </Popper>
262 </Box>
263 )
264 }