blob: 92ef37df62ca0e19e1771e4580ef5bf33e8ff9d1 [file] [log] [blame]
simon26e79f72022-10-05 22:16:08 -04001/*
2 * Copyright (C) 2022 Savoir-faire Linux Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation; either version 3 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
13 *
14 * You should have received a copy of the GNU Affero General Public
15 * License along with this program. If not, see
16 * <https://www.gnu.org/licenses/>.
17 */
simon1170c322022-10-31 14:51:31 -040018import { QuestionMark, RadioButtonChecked, RadioButtonUnchecked } from '@mui/icons-material';
simon33c06182022-11-02 17:39:31 -040019import {
20 Box,
21 ClickAwayListener,
simon492e8402022-11-29 16:48:37 -050022 FormControlLabel,
simon33c06182022-11-02 17:39:31 -040023 IconButton,
24 IconButtonProps,
25 ListItemIcon,
26 ListItemText,
27 Menu,
28 MenuItem,
29 Popper,
30 Radio,
31 RadioGroup,
simon492e8402022-11-29 16:48:37 -050032 RadioGroupProps,
simon33c06182022-11-02 17:39:31 -040033 SvgIconProps,
idillon18283ac2023-01-07 12:06:42 -050034 Theme,
simon33c06182022-11-02 17:39:31 -040035} from '@mui/material';
idillon18283ac2023-01-07 12:06:42 -050036import { PaletteColor, styled } from '@mui/material/styles';
simon35378692022-10-02 23:25:57 -040037import EmojiPicker, { IEmojiData } from 'emoji-picker-react';
simondaae9102022-12-02 16:51:31 -050038import { ComponentType, MouseEvent, ReactNode, useCallback, useState } from 'react';
simon07b4eb02022-09-29 17:50:26 -040039
simond47ef9e2022-09-28 22:24:28 -040040import {
41 Arrow2Icon,
42 Arrow3Icon,
43 ArrowIcon,
idillonae655dd2022-10-14 18:11:02 -040044 AudioCallIcon,
simond47ef9e2022-09-28 22:24:28 -040045 CameraIcon,
46 CameraInBubbleIcon,
47 CancelIcon,
48 CrossedEyeIcon,
49 CrossIcon,
50 EmojiIcon,
simon33c06182022-11-02 17:39:31 -040051 ExpandLessIcon,
simond47ef9e2022-09-28 22:24:28 -040052 EyeIcon,
53 FolderIcon,
54 InfoIcon,
idillonae655dd2022-10-14 18:11:02 -040055 ListIcon,
simond47ef9e2022-09-28 22:24:28 -040056 MicroInBubbleIcon,
57 PaperClipIcon,
58 PenIcon,
idillonae655dd2022-10-14 18:11:02 -040059 PeopleWithPlusSignIcon,
simond47ef9e2022-09-28 22:24:28 -040060 SaltireIcon,
idillonae655dd2022-10-14 18:11:02 -040061 VideoCallIcon,
simon35378692022-10-02 23:25:57 -040062} from './SvgIcon';
Michelle Sepkap Simef5ebc2e2022-10-27 18:30:53 -040063import CustomTooltip from './Tooltip';
idillon-sfl44b05342022-08-24 15:46:42 -040064
simonf929a362022-11-18 16:53:45 -050065export type ShapedButtonProps = IconButtonProps & {
simon35378692022-10-02 23:25:57 -040066 Icon: ComponentType<SvgIconProps>;
67};
68
simonf929a362022-11-18 16:53:45 -050069export const RoundButton = styled(({ Icon, ...props }: ShapedButtonProps) => (
simond47ef9e2022-09-28 22:24:28 -040070 <IconButton {...props} disableRipple={true}>
71 <Icon fontSize="inherit" />
72 </IconButton>
73))(({ theme }) => ({
74 border: `1px solid ${theme.palette.primary.dark}`,
75 color: theme.palette.primary.dark,
76 fontSize: '15px',
idillonb0ec86a2022-12-06 17:54:55 -050077 background: 'white',
78 opacity: 1,
simond47ef9e2022-09-28 22:24:28 -040079 '&:hover': {
80 background: theme.palette.primary.light,
81 },
82 '&:active': {
83 color: '#FFF',
84 background: theme.palette.primary.dark,
85 },
86 '&.MuiIconButton-sizeSmall': {
87 height: '15px',
88 width: '15px',
89 },
90 '&.MuiIconButton-sizeMedium': {
91 height: '30px',
92 width: '30px',
93 },
94 '&.MuiIconButton-sizeLarge': {
95 height: '53px',
96 width: '53px',
97 },
idillon-sfld5cc7862022-08-25 11:11:34 -040098}));
idillon-sfl44b05342022-08-24 15:46:42 -040099
simon33c06182022-11-02 17:39:31 -0400100type ExpandMenuOption = {
101 description: ReactNode;
102 icon?: ReactNode;
103};
104
simon492e8402022-11-29 16:48:37 -0500105export type ExpandMenuRadioOption = RadioGroupProps & {
simon33c06182022-11-02 17:39:31 -0400106 options: {
107 key: string;
108 description: ReactNode;
109 }[];
simon33c06182022-11-02 17:39:31 -0400110};
111
112export type ExpandableButtonProps = IconButtonProps & {
simon9a8fe202022-11-15 18:25:49 -0500113 isVertical?: boolean;
simon571240f2022-11-29 23:59:27 -0500114 expandMenuOnClick?: boolean;
simon33c06182022-11-02 17:39:31 -0400115 Icon?: ComponentType<SvgIconProps>;
116 expandMenuOptions?: (ExpandMenuOption | ExpandMenuRadioOption)[];
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500117 IconButtonComp?: ComponentType<IconButtonProps>;
simon33c06182022-11-02 17:39:31 -0400118};
119
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500120export const ExpandableButton = ({
simon9a8fe202022-11-15 18:25:49 -0500121 isVertical,
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500122 Icon,
simon571240f2022-11-29 23:59:27 -0500123 expandMenuOnClick,
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500124 expandMenuOptions = undefined,
125 IconButtonComp = IconButton,
126 ...props
127}: ExpandableButtonProps) => {
simon33c06182022-11-02 17:39:31 -0400128 const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
129 const handleClose = () => {
130 setAnchorEl(null);
131 };
132
simon33c06182022-11-02 17:39:31 -0400133 return (
simon9a8fe202022-11-15 18:25:49 -0500134 <>
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500135 {expandMenuOptions && (
136 <Menu
137 anchorEl={anchorEl}
138 open={!!anchorEl}
139 onClose={handleClose}
140 anchorOrigin={{
simon9a8fe202022-11-15 18:25:49 -0500141 vertical: !isVertical ? 'top' : 'center',
142 horizontal: !isVertical ? 'center' : 'left',
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500143 }}
144 transformOrigin={{
simon9a8fe202022-11-15 18:25:49 -0500145 vertical: !isVertical ? 'bottom' : 'center',
146 horizontal: !isVertical ? 'center' : 'right',
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500147 }}
148 >
149 {expandMenuOptions?.map((option, id) => {
150 if ('options' in option) {
simon492e8402022-11-29 16:48:37 -0500151 const { options, ...radioGroupProps } = option;
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500152 return (
simon492e8402022-11-29 16:48:37 -0500153 <RadioGroup key={id} {...radioGroupProps}>
154 {options.map(({ description, key }, i) => (
155 <MenuItem key={i}>
156 <FormControlLabel
157 value={key}
158 control={<Radio value={key} />}
159 label={<ListItemText>{description}</ListItemText>}
160 sx={{
161 width: '100%',
162 }}
163 />
164 </MenuItem>
165 ))}
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500166 </RadioGroup>
167 );
168 }
simon33c06182022-11-02 17:39:31 -0400169
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500170 return (
171 <MenuItem key={id} onClick={handleClose}>
172 <ListItemIcon>{option.icon}</ListItemIcon>
173 <ListItemText>{option.description}</ListItemText>
174 </MenuItem>
175 );
176 })}
177 </Menu>
178 )}
simon9a8fe202022-11-15 18:25:49 -0500179 <Box position="relative" display="flex" justifyContent="center" alignItems="center">
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500180 {expandMenuOptions && (
simon33c06182022-11-02 17:39:31 -0400181 <IconButton
simon33c06182022-11-02 17:39:31 -0400182 aria-label="expand options"
simon9a8fe202022-11-15 18:25:49 -0500183 onClick={(e) => setAnchorEl(e.currentTarget)}
simon33c06182022-11-02 17:39:31 -0400184 sx={{
simon9a8fe202022-11-15 18:25:49 -0500185 rotate: !isVertical ? '' : '-90deg',
simon33c06182022-11-02 17:39:31 -0400186 position: 'absolute',
simon9a8fe202022-11-15 18:25:49 -0500187 top: !isVertical ? '-55%' : 'auto',
188 left: !isVertical ? 'auto' : '-55%',
189 zIndex: 1,
simon33c06182022-11-02 17:39:31 -0400190 }}
simon9a8fe202022-11-15 18:25:49 -0500191 className={props.className}
simon33c06182022-11-02 17:39:31 -0400192 >
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500193 <ExpandLessIcon
simon9a8fe202022-11-15 18:25:49 -0500194 fontSize="small"
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500195 sx={{
196 backgroundColor: '#444444',
197 borderRadius: '5px',
198 }}
199 />
simon33c06182022-11-02 17:39:31 -0400200 </IconButton>
201 )}
simon571240f2022-11-29 23:59:27 -0500202 <IconButtonComp
203 onClick={
204 expandMenuOnClick
205 ? (event) => {
206 setAnchorEl(event.currentTarget);
207 }
208 : undefined
209 }
210 {...props}
211 >
212 {Icon && <Icon />}
213 </IconButtonComp>
simon33c06182022-11-02 17:39:31 -0400214 </Box>
simon9a8fe202022-11-15 18:25:49 -0500215 </>
simon33c06182022-11-02 17:39:31 -0400216 );
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500217};
simon33c06182022-11-02 17:39:31 -0400218
simon35378692022-10-02 23:25:57 -0400219export const CancelPictureButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400220 return <RoundButton {...props} aria-label="remove picture" Icon={CancelIcon} size="large" />;
221};
idillon-sfl44b05342022-08-24 15:46:42 -0400222
simon35378692022-10-02 23:25:57 -0400223export const EditPictureButton = (props: IconButtonProps) => {
idillonb0ec86a2022-12-06 17:54:55 -0500224 return <RoundButton {...props} aria-label="edit picture" Icon={PenIcon} size="medium" />;
simond47ef9e2022-09-28 22:24:28 -0400225};
idillon-sfl44b05342022-08-24 15:46:42 -0400226
simon35378692022-10-02 23:25:57 -0400227export const UploadPictureButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400228 return <RoundButton {...props} aria-label="upload picture" Icon={FolderIcon} size="large" />;
229};
idillon-sfl44b05342022-08-24 15:46:42 -0400230
simon35378692022-10-02 23:25:57 -0400231export const TakePictureButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400232 return <RoundButton {...props} aria-label="take picture" Icon={CameraIcon} size="large" />;
233};
idillon-sfl37c18df2022-08-26 18:44:27 -0400234
Michelle Sepkap Simef5ebc2e2022-10-27 18:30:53 -0400235type InfoButtonProps = IconButtonProps & {
236 tooltipTitle: string;
237};
238export const InfoButton = ({ tooltipTitle, ...props }: InfoButtonProps) => {
239 return (
240 <CustomTooltip className="tooltip" title={tooltipTitle}>
241 <RoundButton {...props} aria-label="informations" Icon={InfoIcon} size="small" />
242 </CustomTooltip>
243 );
simond47ef9e2022-09-28 22:24:28 -0400244};
idillon-sfl37c18df2022-08-26 18:44:27 -0400245
simon35378692022-10-02 23:25:57 -0400246export const TipButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400247 return <RoundButton {...props} aria-label="tip" Icon={QuestionMark} size="medium" />;
248};
idillon-sfl37c18df2022-08-26 18:44:27 -0400249
simon35378692022-10-02 23:25:57 -0400250export const MoreButton = styled((props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400251 return (
252 <IconButton {...props} disableRipple={true} aria-label="more">
253 <CrossIcon fontSize="inherit" />
254 </IconButton>
255 );
256})(({ theme }) => ({
257 border: `1px solid ${theme.palette.primary.dark}`,
258 color: theme.palette.primary.dark,
259 fontSize: '10px',
260 height: '20px',
261 width: '20px',
262 '&:hover': {
263 background: theme.palette.primary.light,
264 },
265 '&:active': {
266 color: '#FFF',
267 background: theme.palette.primary.dark,
268 },
269}));
idillon927b7592022-09-15 12:56:45 -0400270
simon35378692022-10-02 23:25:57 -0400271export const BackButton = styled((props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400272 return (
273 <IconButton {...props} disableRipple={true} aria-label="back">
274 <ArrowIcon fontSize="inherit" />
275 </IconButton>
276 );
277})(({ theme }) => ({
278 color: theme.palette.primary.dark,
279 fontSize: '15px',
280 height: '30px',
281 width: '51px',
282 borderRadius: '5px',
283 '&:hover': {
284 background: theme.palette.primary.light,
285 },
286}));
idillonb3788bf2022-08-29 15:57:57 -0400287
simon1170c322022-10-31 14:51:31 -0400288export type ToggleIconButtonProps = IconButtonProps & {
289 selected: boolean;
290 toggle: () => void;
291 IconOn?: ComponentType<SvgIconProps>;
292 IconOff?: ComponentType<SvgIconProps>;
Gabriel Rochone3ec0d22022-10-08 14:27:03 -0400293};
simon33c06182022-11-02 17:39:31 -0400294
simon1170c322022-10-31 14:51:31 -0400295export const ToggleIconButton = ({
296 IconOn = RadioButtonChecked,
297 IconOff = RadioButtonUnchecked,
298 selected,
299 toggle,
300 ...props
301}: ToggleIconButtonProps) => {
Gabriel Rochone3ec0d22022-10-08 14:27:03 -0400302 return (
simon1170c322022-10-31 14:51:31 -0400303 <IconButton
304 {...props}
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500305 sx={{
306 color: selected ? 'white' : 'red',
307 ...props.sx,
308 }}
simon1170c322022-10-31 14:51:31 -0400309 onClick={() => {
310 toggle();
311 }}
312 >
313 {selected ? <IconOn /> : <IconOff />}
Gabriel Rochone3ec0d22022-10-08 14:27:03 -0400314 </IconButton>
315 );
316};
317
simon35378692022-10-02 23:25:57 -0400318export const CloseButton = styled((props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400319 return (
320 <IconButton {...props} disableRipple={true} aria-label="close">
321 <SaltireIcon fontSize="inherit" />
322 </IconButton>
323 );
324})(({ theme }) => ({
325 color: theme.palette.primary.dark,
326 fontSize: '15px',
327 height: '30px',
328 width: '30px',
329 borderRadius: '5px',
330 '&:hover': {
331 background: theme.palette.primary.light,
332 },
333}));
idillonb3788bf2022-08-29 15:57:57 -0400334
simon35378692022-10-02 23:25:57 -0400335type ToggleVisibilityButtonProps = IconButtonProps & {
336 visible: boolean;
337};
338export const ToggleVisibilityButton = styled(({ visible, ...props }: ToggleVisibilityButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400339 const Icon = visible ? CrossedEyeIcon : EyeIcon;
340 return (
341 <IconButton {...props} disableRipple={true}>
342 <Icon fontSize="inherit" />
343 </IconButton>
344 );
345})(({ theme }) => ({
346 color: theme.palette.primary.dark,
347 fontSize: '15px',
348 height: '15px',
349 width: '15px',
350 '&:hover': {
351 background: theme.palette.primary.light,
352 },
353}));
idillonaedab942022-09-01 14:29:43 -0400354
idillon847b4642022-12-29 14:28:38 -0500355export const SquareButton = styled(({ Icon, ...props }: ShapedButtonProps) => (
simond47ef9e2022-09-28 22:24:28 -0400356 <IconButton {...props} disableRipple={true}>
357 <Icon fontSize="inherit" />
358 </IconButton>
simon416d0792022-11-03 02:46:18 -0400359))(() => ({
simond47ef9e2022-09-28 22:24:28 -0400360 color: '#7E7E7E',
361 fontSize: '25px',
362 height: '36px',
363 width: '36px',
364 borderRadius: '5px',
365 '&:hover': {
366 background: '#E5E5E5',
367 },
idillonaedab942022-09-01 14:29:43 -0400368}));
369
idillonae655dd2022-10-14 18:11:02 -0400370export const AddParticipantButton = (props: IconButtonProps) => {
371 return <SquareButton {...props} aria-label="add participant" Icon={PeopleWithPlusSignIcon} />;
372};
373
simon35378692022-10-02 23:25:57 -0400374export const RecordVideoMessageButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400375 return <SquareButton {...props} aria-label="record video message" Icon={CameraInBubbleIcon} />;
376};
idillonaedab942022-09-01 14:29:43 -0400377
simon35378692022-10-02 23:25:57 -0400378export const RecordVoiceMessageButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400379 return <SquareButton {...props} aria-label="record voice message" Icon={MicroInBubbleIcon} />;
380};
idillonaedab942022-09-01 14:29:43 -0400381
idillonae655dd2022-10-14 18:11:02 -0400382export const ShowOptionsMenuButton = (props: IconButtonProps) => {
383 return <SquareButton {...props} aria-label="show options menu" Icon={ListIcon} />;
384};
385
386export const StartVideoCallButton = (props: IconButtonProps) => {
simoncd698c52022-11-08 19:21:38 -0500387 return <SquareButton {...props} aria-label="start audio call" Icon={VideoCallIcon} />;
idillonae655dd2022-10-14 18:11:02 -0400388};
389
390export const StartAudioCallButton = (props: IconButtonProps) => {
simoncd698c52022-11-08 19:21:38 -0500391 return <SquareButton {...props} aria-label="start video call" Icon={AudioCallIcon} />;
idillonae655dd2022-10-14 18:11:02 -0400392};
393
simon35378692022-10-02 23:25:57 -0400394export const UploadFileButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400395 return <SquareButton {...props} aria-label="upload file" Icon={PaperClipIcon} />;
396};
idillonaedab942022-09-01 14:29:43 -0400397
simon35378692022-10-02 23:25:57 -0400398export const SendMessageButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400399 return <SquareButton {...props} aria-label="send message" Icon={Arrow2Icon} />;
400};
idillonaedab942022-09-01 14:29:43 -0400401
simon35378692022-10-02 23:25:57 -0400402export const ReplyMessageButton = styled((props: IconButtonProps) => (
simond47ef9e2022-09-28 22:24:28 -0400403 <IconButton {...props} disableRipple={true} aria-label="send message">
404 <Arrow3Icon fontSize="inherit" />
405 </IconButton>
406))(({ theme }) => ({
407 color: theme.palette.primary.dark,
408 fontSize: '20px',
409 height: '20px',
410 width: '20px',
411 borderRadius: '5px',
412 '&:hover': {
413 background: '#E5E5E5',
414 },
idillon927b7592022-09-15 12:56:45 -0400415}));
416
simon35378692022-10-02 23:25:57 -0400417type EmojiButtonProps = IconButtonProps & {
418 emoji: string;
419};
420export const EmojiButton = styled(({ emoji, ...props }: EmojiButtonProps) => (
simond47ef9e2022-09-28 22:24:28 -0400421 <IconButton {...props} disableRipple={true}>
422 {emoji}
423 </IconButton>
simon416d0792022-11-03 02:46:18 -0400424))(() => ({
simond47ef9e2022-09-28 22:24:28 -0400425 color: 'white',
426 fontSize: '20px',
427 height: '20px',
428 width: '20px',
idillon927b7592022-09-15 12:56:45 -0400429}));
430
simon35378692022-10-02 23:25:57 -0400431type SelectEmojiButtonProps = {
432 onEmojiSelected: (emoji: string) => void;
433};
simon416d0792022-11-03 02:46:18 -0400434export const SelectEmojiButton = ({ onEmojiSelected }: SelectEmojiButtonProps) => {
simon35378692022-10-02 23:25:57 -0400435 const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
idillon1664bb22022-09-14 17:18:15 -0400436
simon35378692022-10-02 23:25:57 -0400437 const handleOpenEmojiPicker = useCallback(
438 (e: MouseEvent<HTMLButtonElement>) => setAnchorEl(anchorEl ? null : e.currentTarget),
439 [anchorEl]
440 );
simond47ef9e2022-09-28 22:24:28 -0400441
442 const handleClose = useCallback(() => setAnchorEl(null), [setAnchorEl]);
443
444 const onEmojiClick = useCallback(
simon35378692022-10-02 23:25:57 -0400445 (e: MouseEvent, emojiObject: IEmojiData) => {
simon80b7b3b2022-09-28 17:50:10 -0400446 onEmojiSelected(emojiObject.emoji);
simond47ef9e2022-09-28 22:24:28 -0400447 handleClose();
448 },
simon80b7b3b2022-09-28 17:50:10 -0400449 [handleClose, onEmojiSelected]
simond47ef9e2022-09-28 22:24:28 -0400450 );
451
452 const open = Boolean(anchorEl);
453 const id = open ? 'simple-popover' : undefined;
454
455 return (
456 <ClickAwayListener onClickAway={handleClose}>
457 <Box>
idillonae655dd2022-10-14 18:11:02 -0400458 <SquareButton
459 aria-describedby={id}
460 aria-label="select emoji"
461 Icon={EmojiIcon}
462 onClick={handleOpenEmojiPicker}
463 />
simon35378692022-10-02 23:25:57 -0400464 <Popper id={id} open={open} anchorEl={anchorEl}>
465 <EmojiPicker onEmojiClick={onEmojiClick} disableAutoFocus={true} disableSkinTonePicker={true} native />
simond47ef9e2022-09-28 22:24:28 -0400466 </Popper>
467 </Box>
468 </ClickAwayListener>
469 );
470};
idillonb0ec86a2022-12-06 17:54:55 -0500471
472const RecordButtonSize = '50px';
473const RecordButtonOutlineWidth = '1px';
474const RecordButtonOutlineOffset = '4px';
475const RecordButtonInnerSize =
476 parseInt(RecordButtonSize) - parseInt(RecordButtonOutlineWidth) * 2 - parseInt(RecordButtonOutlineOffset) * 2 + 'px';
477export const RecordButton = styled((props: IconButtonProps) => (
478 <IconButton {...props} disableRipple={true}>
479 <Box
480 sx={{
481 width: RecordButtonInnerSize,
482 height: RecordButtonInnerSize,
483 borderRadius: '100%',
484 outline: `${RecordButtonOutlineWidth} solid #e57f90`,
485 outlineOffset: RecordButtonOutlineOffset,
486 backgroundColor: '#e57f90',
487 '&:hover': {
488 outlineColor: '#cc0022',
489 backgroundColor: '#cc0022',
490 },
491 }}
492 />
493 </IconButton>
494))({
495 width: RecordButtonSize,
496 height: RecordButtonSize,
497 padding: 0,
498});
499
500export const CornerCloseButton = styled(({ ...props }: IconButtonProps) => (
501 <IconButton {...props}>
502 <SaltireIcon fontSize="inherit" />
503 </IconButton>
504))({
505 position: 'absolute',
506 top: '20px',
507 right: '20px',
508 zIndex: 200,
509 color: 'white',
510 fontSize: '10px',
511});
idillon18283ac2023-01-07 12:06:42 -0500512
513export const ColoredRoundButton = styled(
514 ({
515 paletteColor,
516 Icon,
517 ...props
518 }: ShapedButtonProps & {
519 paletteColor?: PaletteColor | ((theme: Theme) => PaletteColor);
520 }) => {
521 return (
522 <IconButton {...props} disableRipple={true}>
523 <Icon fontSize="inherit" />
524 </IconButton>
525 );
526 }
527)(({ theme, paletteColor = theme.palette.primary }) => {
528 if (typeof paletteColor === 'function') {
529 paletteColor = paletteColor(theme);
530 }
531
532 return {
533 color: paletteColor.contrastText,
534 backgroundColor: paletteColor.dark,
535 '&:hover': {
536 backgroundColor: paletteColor.main,
537 },
538 '&:disabled': {
539 backgroundColor: theme.palette.action.disabled,
540 },
541 };
542});