blob: 3aff314f6725a7ad56cc5edd52048d0afb66bcc0 [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 */
Ziwei Wanga41e1662023-01-27 14:56:32 -050018import QuestionMark from '@mui/icons-material/AddCircle';
19import RadioButtonChecked from '@mui/icons-material/AddCircle';
20import RadioButtonUnchecked from '@mui/icons-material/AddCircle';
simon33c06182022-11-02 17:39:31 -040021import {
22 Box,
23 ClickAwayListener,
simon492e8402022-11-29 16:48:37 -050024 FormControlLabel,
simon33c06182022-11-02 17:39:31 -040025 IconButton,
26 IconButtonProps,
27 ListItemIcon,
28 ListItemText,
29 Menu,
30 MenuItem,
31 Popper,
32 Radio,
33 RadioGroup,
simon492e8402022-11-29 16:48:37 -050034 RadioGroupProps,
simon33c06182022-11-02 17:39:31 -040035 SvgIconProps,
idillon18283ac2023-01-07 12:06:42 -050036 Theme,
simon33c06182022-11-02 17:39:31 -040037} from '@mui/material';
idillon18283ac2023-01-07 12:06:42 -050038import { PaletteColor, styled } from '@mui/material/styles';
simon35378692022-10-02 23:25:57 -040039import EmojiPicker, { IEmojiData } from 'emoji-picker-react';
simondaae9102022-12-02 16:51:31 -050040import { ComponentType, MouseEvent, ReactNode, useCallback, useState } from 'react';
simon07b4eb02022-09-29 17:50:26 -040041
simond47ef9e2022-09-28 22:24:28 -040042import {
43 Arrow2Icon,
44 Arrow3Icon,
45 ArrowIcon,
idillonae655dd2022-10-14 18:11:02 -040046 AudioCallIcon,
simond47ef9e2022-09-28 22:24:28 -040047 CameraIcon,
48 CameraInBubbleIcon,
49 CancelIcon,
50 CrossedEyeIcon,
51 CrossIcon,
52 EmojiIcon,
simon33c06182022-11-02 17:39:31 -040053 ExpandLessIcon,
simond47ef9e2022-09-28 22:24:28 -040054 EyeIcon,
55 FolderIcon,
56 InfoIcon,
idillonae655dd2022-10-14 18:11:02 -040057 ListIcon,
simond47ef9e2022-09-28 22:24:28 -040058 MicroInBubbleIcon,
59 PaperClipIcon,
60 PenIcon,
idillonae655dd2022-10-14 18:11:02 -040061 PeopleWithPlusSignIcon,
simond47ef9e2022-09-28 22:24:28 -040062 SaltireIcon,
idillonae655dd2022-10-14 18:11:02 -040063 VideoCallIcon,
simon35378692022-10-02 23:25:57 -040064} from './SvgIcon';
Michelle Sepkap Simef5ebc2e2022-10-27 18:30:53 -040065import CustomTooltip from './Tooltip';
idillon-sfl44b05342022-08-24 15:46:42 -040066
simonf929a362022-11-18 16:53:45 -050067export type ShapedButtonProps = IconButtonProps & {
simon35378692022-10-02 23:25:57 -040068 Icon: ComponentType<SvgIconProps>;
69};
70
simonf929a362022-11-18 16:53:45 -050071export const RoundButton = styled(({ Icon, ...props }: ShapedButtonProps) => (
simond47ef9e2022-09-28 22:24:28 -040072 <IconButton {...props} disableRipple={true}>
73 <Icon fontSize="inherit" />
74 </IconButton>
75))(({ theme }) => ({
76 border: `1px solid ${theme.palette.primary.dark}`,
77 color: theme.palette.primary.dark,
78 fontSize: '15px',
idillonb0ec86a2022-12-06 17:54:55 -050079 background: 'white',
80 opacity: 1,
simond47ef9e2022-09-28 22:24:28 -040081 '&:hover': {
82 background: theme.palette.primary.light,
83 },
84 '&:active': {
85 color: '#FFF',
86 background: theme.palette.primary.dark,
87 },
88 '&.MuiIconButton-sizeSmall': {
89 height: '15px',
90 width: '15px',
91 },
92 '&.MuiIconButton-sizeMedium': {
93 height: '30px',
94 width: '30px',
95 },
96 '&.MuiIconButton-sizeLarge': {
97 height: '53px',
98 width: '53px',
99 },
idillon-sfld5cc7862022-08-25 11:11:34 -0400100}));
idillon-sfl44b05342022-08-24 15:46:42 -0400101
simon33c06182022-11-02 17:39:31 -0400102type ExpandMenuOption = {
103 description: ReactNode;
104 icon?: ReactNode;
105};
106
simon492e8402022-11-29 16:48:37 -0500107export type ExpandMenuRadioOption = RadioGroupProps & {
simon33c06182022-11-02 17:39:31 -0400108 options: {
109 key: string;
110 description: ReactNode;
111 }[];
simon33c06182022-11-02 17:39:31 -0400112};
113
114export type ExpandableButtonProps = IconButtonProps & {
simon9a8fe202022-11-15 18:25:49 -0500115 isVertical?: boolean;
simon571240f2022-11-29 23:59:27 -0500116 expandMenuOnClick?: boolean;
simon33c06182022-11-02 17:39:31 -0400117 Icon?: ComponentType<SvgIconProps>;
118 expandMenuOptions?: (ExpandMenuOption | ExpandMenuRadioOption)[];
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500119 IconButtonComp?: ComponentType<IconButtonProps>;
simon33c06182022-11-02 17:39:31 -0400120};
121
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500122export const ExpandableButton = ({
simon9a8fe202022-11-15 18:25:49 -0500123 isVertical,
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500124 Icon,
simon571240f2022-11-29 23:59:27 -0500125 expandMenuOnClick,
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500126 expandMenuOptions = undefined,
127 IconButtonComp = IconButton,
128 ...props
129}: ExpandableButtonProps) => {
simon33c06182022-11-02 17:39:31 -0400130 const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
131 const handleClose = () => {
132 setAnchorEl(null);
133 };
134
simon33c06182022-11-02 17:39:31 -0400135 return (
simon9a8fe202022-11-15 18:25:49 -0500136 <>
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500137 {expandMenuOptions && (
138 <Menu
139 anchorEl={anchorEl}
140 open={!!anchorEl}
141 onClose={handleClose}
142 anchorOrigin={{
simon9a8fe202022-11-15 18:25:49 -0500143 vertical: !isVertical ? 'top' : 'center',
144 horizontal: !isVertical ? 'center' : 'left',
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500145 }}
146 transformOrigin={{
simon9a8fe202022-11-15 18:25:49 -0500147 vertical: !isVertical ? 'bottom' : 'center',
148 horizontal: !isVertical ? 'center' : 'right',
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500149 }}
150 >
151 {expandMenuOptions?.map((option, id) => {
152 if ('options' in option) {
simon492e8402022-11-29 16:48:37 -0500153 const { options, ...radioGroupProps } = option;
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500154 return (
simon492e8402022-11-29 16:48:37 -0500155 <RadioGroup key={id} {...radioGroupProps}>
156 {options.map(({ description, key }, i) => (
157 <MenuItem key={i}>
158 <FormControlLabel
159 value={key}
160 control={<Radio value={key} />}
161 label={<ListItemText>{description}</ListItemText>}
162 sx={{
163 width: '100%',
164 }}
165 />
166 </MenuItem>
167 ))}
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500168 </RadioGroup>
169 );
170 }
simon33c06182022-11-02 17:39:31 -0400171
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500172 return (
173 <MenuItem key={id} onClick={handleClose}>
174 <ListItemIcon>{option.icon}</ListItemIcon>
175 <ListItemText>{option.description}</ListItemText>
176 </MenuItem>
177 );
178 })}
179 </Menu>
180 )}
simon9a8fe202022-11-15 18:25:49 -0500181 <Box position="relative" display="flex" justifyContent="center" alignItems="center">
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500182 {expandMenuOptions && (
simon33c06182022-11-02 17:39:31 -0400183 <IconButton
simon33c06182022-11-02 17:39:31 -0400184 aria-label="expand options"
simon9a8fe202022-11-15 18:25:49 -0500185 onClick={(e) => setAnchorEl(e.currentTarget)}
simon33c06182022-11-02 17:39:31 -0400186 sx={{
simon9a8fe202022-11-15 18:25:49 -0500187 rotate: !isVertical ? '' : '-90deg',
simon33c06182022-11-02 17:39:31 -0400188 position: 'absolute',
simon9a8fe202022-11-15 18:25:49 -0500189 top: !isVertical ? '-55%' : 'auto',
190 left: !isVertical ? 'auto' : '-55%',
191 zIndex: 1,
simon33c06182022-11-02 17:39:31 -0400192 }}
simon9a8fe202022-11-15 18:25:49 -0500193 className={props.className}
simon33c06182022-11-02 17:39:31 -0400194 >
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500195 <ExpandLessIcon
simon9a8fe202022-11-15 18:25:49 -0500196 fontSize="small"
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500197 sx={{
198 backgroundColor: '#444444',
199 borderRadius: '5px',
200 }}
201 />
simon33c06182022-11-02 17:39:31 -0400202 </IconButton>
203 )}
simon571240f2022-11-29 23:59:27 -0500204 <IconButtonComp
205 onClick={
206 expandMenuOnClick
207 ? (event) => {
208 setAnchorEl(event.currentTarget);
209 }
210 : undefined
211 }
212 {...props}
213 >
214 {Icon && <Icon />}
215 </IconButtonComp>
simon33c06182022-11-02 17:39:31 -0400216 </Box>
simon9a8fe202022-11-15 18:25:49 -0500217 </>
simon33c06182022-11-02 17:39:31 -0400218 );
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500219};
simon33c06182022-11-02 17:39:31 -0400220
simon35378692022-10-02 23:25:57 -0400221export const CancelPictureButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400222 return <RoundButton {...props} aria-label="remove picture" Icon={CancelIcon} size="large" />;
223};
idillon-sfl44b05342022-08-24 15:46:42 -0400224
simon35378692022-10-02 23:25:57 -0400225export const EditPictureButton = (props: IconButtonProps) => {
idillonb0ec86a2022-12-06 17:54:55 -0500226 return <RoundButton {...props} aria-label="edit picture" Icon={PenIcon} size="medium" />;
simond47ef9e2022-09-28 22:24:28 -0400227};
idillon-sfl44b05342022-08-24 15:46:42 -0400228
simon35378692022-10-02 23:25:57 -0400229export const UploadPictureButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400230 return <RoundButton {...props} aria-label="upload picture" Icon={FolderIcon} size="large" />;
231};
idillon-sfl44b05342022-08-24 15:46:42 -0400232
simon35378692022-10-02 23:25:57 -0400233export const TakePictureButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400234 return <RoundButton {...props} aria-label="take picture" Icon={CameraIcon} size="large" />;
235};
idillon-sfl37c18df2022-08-26 18:44:27 -0400236
Michelle Sepkap Simef5ebc2e2022-10-27 18:30:53 -0400237type InfoButtonProps = IconButtonProps & {
238 tooltipTitle: string;
239};
240export const InfoButton = ({ tooltipTitle, ...props }: InfoButtonProps) => {
241 return (
242 <CustomTooltip className="tooltip" title={tooltipTitle}>
243 <RoundButton {...props} aria-label="informations" Icon={InfoIcon} size="small" />
244 </CustomTooltip>
245 );
simond47ef9e2022-09-28 22:24:28 -0400246};
idillon-sfl37c18df2022-08-26 18:44:27 -0400247
simon35378692022-10-02 23:25:57 -0400248export const TipButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400249 return <RoundButton {...props} aria-label="tip" Icon={QuestionMark} size="medium" />;
250};
idillon-sfl37c18df2022-08-26 18:44:27 -0400251
simon35378692022-10-02 23:25:57 -0400252export const MoreButton = styled((props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400253 return (
254 <IconButton {...props} disableRipple={true} aria-label="more">
255 <CrossIcon fontSize="inherit" />
256 </IconButton>
257 );
258})(({ theme }) => ({
259 border: `1px solid ${theme.palette.primary.dark}`,
260 color: theme.palette.primary.dark,
261 fontSize: '10px',
262 height: '20px',
263 width: '20px',
264 '&:hover': {
265 background: theme.palette.primary.light,
266 },
267 '&:active': {
268 color: '#FFF',
269 background: theme.palette.primary.dark,
270 },
271}));
idillon927b7592022-09-15 12:56:45 -0400272
simon35378692022-10-02 23:25:57 -0400273export const BackButton = styled((props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400274 return (
275 <IconButton {...props} disableRipple={true} aria-label="back">
276 <ArrowIcon fontSize="inherit" />
277 </IconButton>
278 );
279})(({ theme }) => ({
280 color: theme.palette.primary.dark,
281 fontSize: '15px',
282 height: '30px',
283 width: '51px',
284 borderRadius: '5px',
285 '&:hover': {
286 background: theme.palette.primary.light,
287 },
288}));
idillonb3788bf2022-08-29 15:57:57 -0400289
simon1170c322022-10-31 14:51:31 -0400290export type ToggleIconButtonProps = IconButtonProps & {
291 selected: boolean;
292 toggle: () => void;
293 IconOn?: ComponentType<SvgIconProps>;
294 IconOff?: ComponentType<SvgIconProps>;
Gabriel Rochone3ec0d22022-10-08 14:27:03 -0400295};
simon33c06182022-11-02 17:39:31 -0400296
simon1170c322022-10-31 14:51:31 -0400297export const ToggleIconButton = ({
298 IconOn = RadioButtonChecked,
299 IconOff = RadioButtonUnchecked,
300 selected,
301 toggle,
302 ...props
303}: ToggleIconButtonProps) => {
Gabriel Rochone3ec0d22022-10-08 14:27:03 -0400304 return (
simon1170c322022-10-31 14:51:31 -0400305 <IconButton
306 {...props}
Gabriel Rochon8321a0d2022-11-06 23:18:36 -0500307 sx={{
308 color: selected ? 'white' : 'red',
309 ...props.sx,
310 }}
simon1170c322022-10-31 14:51:31 -0400311 onClick={() => {
312 toggle();
313 }}
314 >
315 {selected ? <IconOn /> : <IconOff />}
Gabriel Rochone3ec0d22022-10-08 14:27:03 -0400316 </IconButton>
317 );
318};
319
simon35378692022-10-02 23:25:57 -0400320export const CloseButton = styled((props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400321 return (
322 <IconButton {...props} disableRipple={true} aria-label="close">
323 <SaltireIcon fontSize="inherit" />
324 </IconButton>
325 );
326})(({ theme }) => ({
327 color: theme.palette.primary.dark,
328 fontSize: '15px',
329 height: '30px',
330 width: '30px',
331 borderRadius: '5px',
332 '&:hover': {
333 background: theme.palette.primary.light,
334 },
335}));
idillonb3788bf2022-08-29 15:57:57 -0400336
simon35378692022-10-02 23:25:57 -0400337type ToggleVisibilityButtonProps = IconButtonProps & {
338 visible: boolean;
339};
340export const ToggleVisibilityButton = styled(({ visible, ...props }: ToggleVisibilityButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400341 const Icon = visible ? CrossedEyeIcon : EyeIcon;
342 return (
343 <IconButton {...props} disableRipple={true}>
344 <Icon fontSize="inherit" />
345 </IconButton>
346 );
347})(({ theme }) => ({
348 color: theme.palette.primary.dark,
349 fontSize: '15px',
350 height: '15px',
351 width: '15px',
352 '&:hover': {
353 background: theme.palette.primary.light,
354 },
355}));
idillonaedab942022-09-01 14:29:43 -0400356
idillon847b4642022-12-29 14:28:38 -0500357export const SquareButton = styled(({ Icon, ...props }: ShapedButtonProps) => (
simond47ef9e2022-09-28 22:24:28 -0400358 <IconButton {...props} disableRipple={true}>
359 <Icon fontSize="inherit" />
360 </IconButton>
simon416d0792022-11-03 02:46:18 -0400361))(() => ({
simond47ef9e2022-09-28 22:24:28 -0400362 color: '#7E7E7E',
363 fontSize: '25px',
364 height: '36px',
365 width: '36px',
366 borderRadius: '5px',
367 '&:hover': {
368 background: '#E5E5E5',
369 },
idillonaedab942022-09-01 14:29:43 -0400370}));
371
idillonae655dd2022-10-14 18:11:02 -0400372export const AddParticipantButton = (props: IconButtonProps) => {
373 return <SquareButton {...props} aria-label="add participant" Icon={PeopleWithPlusSignIcon} />;
374};
375
simon35378692022-10-02 23:25:57 -0400376export const RecordVideoMessageButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400377 return <SquareButton {...props} aria-label="record video message" Icon={CameraInBubbleIcon} />;
378};
idillonaedab942022-09-01 14:29:43 -0400379
simon35378692022-10-02 23:25:57 -0400380export const RecordVoiceMessageButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400381 return <SquareButton {...props} aria-label="record voice message" Icon={MicroInBubbleIcon} />;
382};
idillonaedab942022-09-01 14:29:43 -0400383
idillonae655dd2022-10-14 18:11:02 -0400384export const ShowOptionsMenuButton = (props: IconButtonProps) => {
385 return <SquareButton {...props} aria-label="show options menu" Icon={ListIcon} />;
386};
387
388export const StartVideoCallButton = (props: IconButtonProps) => {
simoncd698c52022-11-08 19:21:38 -0500389 return <SquareButton {...props} aria-label="start audio call" Icon={VideoCallIcon} />;
idillonae655dd2022-10-14 18:11:02 -0400390};
391
392export const StartAudioCallButton = (props: IconButtonProps) => {
simoncd698c52022-11-08 19:21:38 -0500393 return <SquareButton {...props} aria-label="start video call" Icon={AudioCallIcon} />;
idillonae655dd2022-10-14 18:11:02 -0400394};
395
simon35378692022-10-02 23:25:57 -0400396export const UploadFileButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400397 return <SquareButton {...props} aria-label="upload file" Icon={PaperClipIcon} />;
398};
idillonaedab942022-09-01 14:29:43 -0400399
simon35378692022-10-02 23:25:57 -0400400export const SendMessageButton = (props: IconButtonProps) => {
simond47ef9e2022-09-28 22:24:28 -0400401 return <SquareButton {...props} aria-label="send message" Icon={Arrow2Icon} />;
402};
idillonaedab942022-09-01 14:29:43 -0400403
simon35378692022-10-02 23:25:57 -0400404export const ReplyMessageButton = styled((props: IconButtonProps) => (
simond47ef9e2022-09-28 22:24:28 -0400405 <IconButton {...props} disableRipple={true} aria-label="send message">
406 <Arrow3Icon fontSize="inherit" />
407 </IconButton>
408))(({ theme }) => ({
409 color: theme.palette.primary.dark,
410 fontSize: '20px',
411 height: '20px',
412 width: '20px',
413 borderRadius: '5px',
414 '&:hover': {
415 background: '#E5E5E5',
416 },
idillon927b7592022-09-15 12:56:45 -0400417}));
418
simon35378692022-10-02 23:25:57 -0400419type EmojiButtonProps = IconButtonProps & {
420 emoji: string;
421};
422export const EmojiButton = styled(({ emoji, ...props }: EmojiButtonProps) => (
simond47ef9e2022-09-28 22:24:28 -0400423 <IconButton {...props} disableRipple={true}>
424 {emoji}
425 </IconButton>
simon416d0792022-11-03 02:46:18 -0400426))(() => ({
simond47ef9e2022-09-28 22:24:28 -0400427 color: 'white',
428 fontSize: '20px',
429 height: '20px',
430 width: '20px',
idillon927b7592022-09-15 12:56:45 -0400431}));
432
simon35378692022-10-02 23:25:57 -0400433type SelectEmojiButtonProps = {
434 onEmojiSelected: (emoji: string) => void;
435};
simon416d0792022-11-03 02:46:18 -0400436export const SelectEmojiButton = ({ onEmojiSelected }: SelectEmojiButtonProps) => {
simon35378692022-10-02 23:25:57 -0400437 const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
idillon1664bb22022-09-14 17:18:15 -0400438
simon35378692022-10-02 23:25:57 -0400439 const handleOpenEmojiPicker = useCallback(
440 (e: MouseEvent<HTMLButtonElement>) => setAnchorEl(anchorEl ? null : e.currentTarget),
441 [anchorEl]
442 );
simond47ef9e2022-09-28 22:24:28 -0400443
444 const handleClose = useCallback(() => setAnchorEl(null), [setAnchorEl]);
445
446 const onEmojiClick = useCallback(
simon35378692022-10-02 23:25:57 -0400447 (e: MouseEvent, emojiObject: IEmojiData) => {
simon80b7b3b2022-09-28 17:50:10 -0400448 onEmojiSelected(emojiObject.emoji);
simond47ef9e2022-09-28 22:24:28 -0400449 handleClose();
450 },
simon80b7b3b2022-09-28 17:50:10 -0400451 [handleClose, onEmojiSelected]
simond47ef9e2022-09-28 22:24:28 -0400452 );
453
454 const open = Boolean(anchorEl);
455 const id = open ? 'simple-popover' : undefined;
456
457 return (
458 <ClickAwayListener onClickAway={handleClose}>
459 <Box>
idillonae655dd2022-10-14 18:11:02 -0400460 <SquareButton
461 aria-describedby={id}
462 aria-label="select emoji"
463 Icon={EmojiIcon}
464 onClick={handleOpenEmojiPicker}
465 />
simon35378692022-10-02 23:25:57 -0400466 <Popper id={id} open={open} anchorEl={anchorEl}>
467 <EmojiPicker onEmojiClick={onEmojiClick} disableAutoFocus={true} disableSkinTonePicker={true} native />
simond47ef9e2022-09-28 22:24:28 -0400468 </Popper>
469 </Box>
470 </ClickAwayListener>
471 );
472};
idillonb0ec86a2022-12-06 17:54:55 -0500473
474const RecordButtonSize = '50px';
475const RecordButtonOutlineWidth = '1px';
476const RecordButtonOutlineOffset = '4px';
477const RecordButtonInnerSize =
478 parseInt(RecordButtonSize) - parseInt(RecordButtonOutlineWidth) * 2 - parseInt(RecordButtonOutlineOffset) * 2 + 'px';
479export const RecordButton = styled((props: IconButtonProps) => (
480 <IconButton {...props} disableRipple={true}>
481 <Box
482 sx={{
483 width: RecordButtonInnerSize,
484 height: RecordButtonInnerSize,
485 borderRadius: '100%',
486 outline: `${RecordButtonOutlineWidth} solid #e57f90`,
487 outlineOffset: RecordButtonOutlineOffset,
488 backgroundColor: '#e57f90',
489 '&:hover': {
490 outlineColor: '#cc0022',
491 backgroundColor: '#cc0022',
492 },
493 }}
494 />
495 </IconButton>
496))({
497 width: RecordButtonSize,
498 height: RecordButtonSize,
499 padding: 0,
500});
501
502export const CornerCloseButton = styled(({ ...props }: IconButtonProps) => (
503 <IconButton {...props}>
504 <SaltireIcon fontSize="inherit" />
505 </IconButton>
506))({
507 position: 'absolute',
508 top: '20px',
509 right: '20px',
510 zIndex: 200,
511 color: 'white',
512 fontSize: '10px',
513});
idillon18283ac2023-01-07 12:06:42 -0500514
515export const ColoredRoundButton = styled(
516 ({
517 paletteColor,
518 Icon,
519 ...props
520 }: ShapedButtonProps & {
521 paletteColor?: PaletteColor | ((theme: Theme) => PaletteColor);
522 }) => {
523 return (
524 <IconButton {...props} disableRipple={true}>
525 <Icon fontSize="inherit" />
526 </IconButton>
527 );
528 }
529)(({ theme, paletteColor = theme.palette.primary }) => {
530 if (typeof paletteColor === 'function') {
531 paletteColor = paletteColor(theme);
532 }
533
534 return {
535 color: paletteColor.contrastText,
536 backgroundColor: paletteColor.dark,
537 '&:hover': {
538 backgroundColor: paletteColor.main,
539 },
540 '&:disabled': {
541 backgroundColor: theme.palette.action.disabled,
542 },
543 };
544});