blob: 771033b01b31468c1aafa3a7b82ec975930cc83a [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";
3import { blue } from "@mui/material/colors";
idillon-sfld5cc7862022-08-25 11:11:34 -04004import { styled } from "@mui/styles";
idillonaedab942022-09-01 14:29:43 -04005import EmojiPicker from "emoji-picker-react";
6import React from "react";
7import { Arrow2Icon, ArrowIcon, CameraIcon, CameraInBubbleIcon, CancelIcon, CrossedEyeIcon, CrossIcon, EmojiIcon, EyeIcon, FolderIcon, InfoIcon, MicroInBubbleIcon, PaperClipIcon, PenIcon } from "./svgIcons";
idillon-sfl44b05342022-08-24 15:46:42 -04008
idillon-sfl37c18df2022-08-26 18:44:27 -04009const RoundButton = styled(
idillon-sfld5cc7862022-08-25 11:11:34 -040010 ({Icon, ...props}) => (
11 <IconButton {...props} disableRipple={true}>
idillon-sfl44b05342022-08-24 15:46:42 -040012 <Icon fontSize="inherit"/>
13 </IconButton>
14 )
idillon-sfldeabd282022-08-25 22:50:03 -040015)(({theme}) => ({
16 border: `1px solid ${theme.palette.primary.dark}`,
17 color: theme.palette.primary.dark,
idillon-sfld5cc7862022-08-25 11:11:34 -040018 fontSize: "15px",
19 "&:hover": {
idillon-sfldeabd282022-08-25 22:50:03 -040020 background: theme.palette.primary.light,
idillon-sfld5cc7862022-08-25 11:11:34 -040021 },
22 "&:active": {
23 color: "#FFF",
idillon-sfldeabd282022-08-25 22:50:03 -040024 background: theme.palette.primary.dark,
idillon-sfld5cc7862022-08-25 11:11:34 -040025 },
idillon-sfl37c18df2022-08-26 18:44:27 -040026 "&.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-sfld5cc7862022-08-25 11:11:34 -040038}));
idillon-sfl44b05342022-08-24 15:46:42 -040039
idillonaedab942022-09-01 14:29:43 -040040export const CancelPictureButton = (props) => {
idillon-sfl44b05342022-08-24 15:46:42 -040041 return (
idillon-sfl37c18df2022-08-26 18:44:27 -040042 <RoundButton {...props}
idillon-sfl44b05342022-08-24 15:46:42 -040043 aria-label="remove picture"
44 Icon={CancelIcon}
idillon-sfl37c18df2022-08-26 18:44:27 -040045 size="large"
idillon-sfl44b05342022-08-24 15:46:42 -040046 />
47 )
48}
49
idillonaedab942022-09-01 14:29:43 -040050export const EditPictureButton = (props) => {
idillon-sfl44b05342022-08-24 15:46:42 -040051 return (
idillon-sfl37c18df2022-08-26 18:44:27 -040052 <RoundButton {...props}
idillon-sfl44b05342022-08-24 15:46:42 -040053 aria-label="edit picture"
54 Icon={PenIcon}
idillon-sfl37c18df2022-08-26 18:44:27 -040055 size="large"
idillon-sfl44b05342022-08-24 15:46:42 -040056 />
57 )
58}
59
idillonaedab942022-09-01 14:29:43 -040060export const UploadPictureButton = (props) => {
idillon-sfl44b05342022-08-24 15:46:42 -040061 return (
idillon-sfl37c18df2022-08-26 18:44:27 -040062 <RoundButton {...props}
idillon-sfl44b05342022-08-24 15:46:42 -040063 aria-label="upload picture"
64 Icon={FolderIcon}
idillon-sfl37c18df2022-08-26 18:44:27 -040065 size="large"
idillon-sfl44b05342022-08-24 15:46:42 -040066 />
67 )
68}
69
70export const TakePictureButton = (props) => {
71 return (
idillon-sfl37c18df2022-08-26 18:44:27 -040072 <RoundButton {...props}
idillon-sfl44b05342022-08-24 15:46:42 -040073 aria-label="take picture"
74 Icon={CameraIcon}
idillon-sfl37c18df2022-08-26 18:44:27 -040075 size="large"
idillon-sfl44b05342022-08-24 15:46:42 -040076 />
77 )
78}
idillon-sfl37c18df2022-08-26 18:44:27 -040079
80export const InfoButton = (props) => {
81 return (
82 <RoundButton {...props}
83 aria-label="informations"
84 Icon={InfoIcon}
85 size="small"
86 />
87 )
88}
89
90export const TipButton = (props) => {
91 return (
92 <RoundButton {...props}
idillonaedab942022-09-01 14:29:43 -040093 aria-label="tip"
idillon-sfl37c18df2022-08-26 18:44:27 -040094 Icon={QuestionMark}
95 size="medium"
96 />
97 )
98}
99
idillonb3788bf2022-08-29 15:57:57 -0400100export const BackButton = styled(
101 (props) => {
102 return (
idillonaedab942022-09-01 14:29:43 -0400103 <IconButton
104 {...props}
105 disableRipple={true}
106 aria-label="back"
107 >
idillonb3788bf2022-08-29 15:57:57 -0400108 <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
123export const CloseButton = styled(
124 (props) => {
125 return (
idillonaedab942022-09-01 14:29:43 -0400126 <IconButton
127 {...props}
128 disableRipple={true}
129 aria-label="close"
130 >
idillonb3788bf2022-08-29 15:57:57 -0400131 <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-sfl37c18df2022-08-26 18:44:27 -0400146export 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 },
idillonb3788bf2022-08-29 15:57:57 -0400163}))
idillonaedab942022-09-01 14:29:43 -0400164
165const 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
182export const RecordVideoMessageButton = (props) => {
183 return (
184 <SquareButton {...props}
185 aria-label="record video message"
186 Icon={CameraInBubbleIcon}
187 />
188 )
189}
190
191export const RecordVoiceMessageButton = (props) => {
192 return (
193 <SquareButton {...props}
194 aria-label="record voice message"
195 Icon={MicroInBubbleIcon}
196 />
197 )
198}
199
200export const UploadFileButton = (props) => {
201 return (
202 <SquareButton {...props}
203 aria-label="upload file"
204 Icon={PaperClipIcon}
205 />
206 )
207}
208
209export const SendMessageButton = (props) => {
210 return (
211 <SquareButton {...props}
212 aria-label="send message"
213 Icon={Arrow2Icon}
214 />
215 )
216}
217
218export 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 }