simon | 26e79f7 | 2022-10-05 22:16:08 -0400 | [diff] [blame] | 1 | /* |
| 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 | */ |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 18 | import { Box, Chip, Divider, List, ListItemButton, ListItemText, Stack, Tooltip, Typography } from '@mui/material'; |
| 19 | import { styled } from '@mui/material/styles'; |
| 20 | import dayjs from 'dayjs'; |
| 21 | import isToday from 'dayjs/plugin/isToday'; |
| 22 | import isYesterday from 'dayjs/plugin/isYesterday'; |
| 23 | import React, { useCallback, useMemo, useState } from 'react'; |
| 24 | import { useTranslation } from 'react-i18next'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 25 | |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 26 | import { EmojiButton, MoreButton, ReplyMessageButton } from './Button.tsx'; |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 27 | import ConversationAvatar from './ConversationAvatar'; |
simon | 3537869 | 2022-10-02 23:25:57 -0400 | [diff] [blame] | 28 | import { OppositeArrowsIcon, TrashBinIcon, TwoSheetsIcon } from './SvgIcon.tsx'; |
Larbi Gharib | e9af973 | 2021-03-31 15:08:01 +0100 | [diff] [blame] | 29 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 30 | dayjs.extend(isToday); |
| 31 | dayjs.extend(isYesterday); |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 32 | |
| 33 | export const MessageCall = (props) => { |
simon | 80b7b3b | 2022-09-28 17:50:10 -0400 | [diff] [blame] | 34 | return <Stack alignItems="center">"Appel"</Stack>; |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 35 | }; |
Larbi Gharib | e9af973 | 2021-03-31 15:08:01 +0100 | [diff] [blame] | 36 | |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 37 | export const MessageInitial = (props) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 38 | const { t } = useTranslation(); |
| 39 | return <Stack alignItems="center">{t('message_swarm_created')}</Stack>; |
| 40 | }; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 41 | |
| 42 | export const MessageDataTransfer = (props) => { |
| 43 | return ( |
| 44 | <MessageBubble |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 45 | backgroundColor={'#E5E5E5'} |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 46 | position={props.position} |
| 47 | isFirstOfGroup={props.isFirstOfGroup} |
| 48 | isLastOfGroup={props.isLastOfGroup} |
| 49 | > |
simon | 80b7b3b | 2022-09-28 17:50:10 -0400 | [diff] [blame] | 50 | "data-transfer" |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 51 | </MessageBubble> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 52 | ); |
| 53 | }; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 54 | |
| 55 | export const MessageMember = (props) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 56 | const { t } = useTranslation(); |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 57 | return ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 58 | <Stack alignItems="center"> |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 59 | <Chip |
| 60 | sx={{ |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 61 | width: 'fit-content', |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 62 | }} |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 63 | label={t('message_user_joined', { user: props.message.author })} |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 64 | /> |
| 65 | </Stack> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 66 | ); |
| 67 | }; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 68 | |
| 69 | export const MessageMerge = (props) => { |
simon | 80b7b3b | 2022-09-28 17:50:10 -0400 | [diff] [blame] | 70 | return <Stack alignItems="center">"merge"</Stack>; |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 71 | }; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 72 | |
| 73 | export const MessageText = (props) => { |
| 74 | return ( |
| 75 | <MessageBubble |
| 76 | backgroundColor={props.bubbleColor} |
| 77 | position={props.position} |
| 78 | isFirstOfGroup={props.isFirstOfGroup} |
| 79 | isLastOfGroup={props.isLastOfGroup} |
| 80 | > |
idillon | 89720a8 | 2022-09-06 18:47:05 -0400 | [diff] [blame] | 81 | <Typography variant="body1" color={props.textColor} textAlign={props.position}> |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 82 | {props.message.body} |
| 83 | </Typography> |
| 84 | </MessageBubble> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 85 | ); |
| 86 | }; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 87 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 88 | export const MessageDate = ({ time }) => { |
| 89 | let textDate; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 90 | |
| 91 | if (time.isToday()) { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 92 | textDate = 'Today'; |
| 93 | } else if (time.isYesterday()) { |
| 94 | textDate = 'Yesterday'; |
| 95 | } else { |
| 96 | const date = time.date().toString().padStart(2, '0'); |
| 97 | const month = (time.month() + 1).toString().padStart(2, '0'); |
| 98 | textDate = `${date}/${month}/${time.year()}`; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | return ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 102 | <Box marginTop="30px"> |
idillon | 04245a1 | 2022-09-01 11:12:17 -0400 | [diff] [blame] | 103 | <Divider |
| 104 | sx={{ |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 105 | '.MuiDivider-wrapper': { |
idillon | 04245a1 | 2022-09-01 11:12:17 -0400 | [diff] [blame] | 106 | margin: 0, |
| 107 | padding: 0, |
| 108 | }, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 109 | '&::before': { |
| 110 | borderTop: '1px solid #E5E5E5', |
idillon | 04245a1 | 2022-09-01 11:12:17 -0400 | [diff] [blame] | 111 | }, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 112 | '&::after': { |
| 113 | borderTop: '1px solid #E5E5E5', |
idillon | 04245a1 | 2022-09-01 11:12:17 -0400 | [diff] [blame] | 114 | }, |
| 115 | }} |
| 116 | > |
| 117 | <Typography |
| 118 | variant="caption" |
| 119 | fontWeight={700} |
| 120 | border="1px solid #E5E5E5" |
| 121 | borderRadius="5px" |
| 122 | padding="10px 16px" |
| 123 | > |
| 124 | {textDate} |
| 125 | </Typography> |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 126 | </Divider> |
| 127 | </Box> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 128 | ); |
| 129 | }; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 130 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 131 | export const MessageTime = ({ time, hasDateOnTop }) => { |
| 132 | const hour = time.hour().toString().padStart(2, '0'); |
| 133 | const minute = time.minute().toString().padStart(2, '0'); |
| 134 | const textTime = `${hour}:${minute}`; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 135 | |
| 136 | return ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 137 | <Stack direction="row" justifyContent="center" margin="30px" marginTop={hasDateOnTop ? '20px' : '30px'}> |
| 138 | <Typography variant="caption" color="#A7A7A7" fontWeight={700}> |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 139 | {textTime} |
| 140 | </Typography> |
| 141 | </Stack> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 142 | ); |
| 143 | }; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 144 | |
| 145 | export const MessageBubblesGroup = (props) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 146 | const isUser = false; // should access user from the store |
| 147 | const position = isUser ? 'end' : 'start'; |
| 148 | const bubbleColor = isUser ? '#005699' : '#E5E5E5'; |
| 149 | const textColor = isUser ? 'white' : 'black'; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 150 | |
| 151 | return ( |
idillon | 89720a8 | 2022-09-06 18:47:05 -0400 | [diff] [blame] | 152 | <Stack // Row for a group of message bubbles with the user's infos |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 153 | direction="row" |
| 154 | justifyContent={position} |
idillon | 89720a8 | 2022-09-06 18:47:05 -0400 | [diff] [blame] | 155 | alignItems="end" |
| 156 | spacing="10px" |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 157 | > |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 158 | {!isUser && ( |
| 159 | <ConversationAvatar displayName="TempDisplayName" sx={{ width: '22px', height: '22px', fontSize: '15px' }} /> |
| 160 | )} |
idillon | 89720a8 | 2022-09-06 18:47:05 -0400 | [diff] [blame] | 161 | <Stack // Container to align the bubbles to the same side of a row |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 162 | width="66.66%" |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 163 | alignItems={position} |
| 164 | > |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 165 | <ParticipantName name={props.messages[0]?.author} position={position} /> |
idillon | 89720a8 | 2022-09-06 18:47:05 -0400 | [diff] [blame] | 166 | <Stack // Container for a group of message bubbles |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 167 | spacing="6px" |
| 168 | alignItems={position} |
| 169 | direction="column-reverse" |
| 170 | > |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 171 | {props.messages.map((message, index) => { |
| 172 | let Component; |
| 173 | switch (message.type) { |
| 174 | case 'text/plain': |
| 175 | Component = MessageText; |
| 176 | break; |
| 177 | case 'application/data-transfer+json': |
| 178 | Component = MessageDataTransfer; |
| 179 | break; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 180 | } |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 181 | return ( |
| 182 | <Component // Single message |
| 183 | key={message.id} |
| 184 | message={message} |
| 185 | textColor={textColor} |
| 186 | position={position} |
| 187 | bubbleColor={bubbleColor} |
| 188 | isFirstOfGroup={index == props.messages.length - 1} |
| 189 | isLastOfGroup={index == 0} |
| 190 | /> |
| 191 | ); |
| 192 | })} |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 193 | </Stack> |
| 194 | </Stack> |
| 195 | </Stack> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 196 | ); |
| 197 | }; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 198 | |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 199 | const MessageTooltip = styled(({ className, ...props }) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 200 | const [open, setOpen] = useState(false); |
| 201 | const emojis = ['😎', '😄', '😍']; // Should be last three used emojis |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 202 | const additionalOptions = [ |
| 203 | { |
| 204 | Icon: TwoSheetsIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 205 | text: 'Copy', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 206 | action: () => {}, |
| 207 | }, |
| 208 | { |
| 209 | Icon: OppositeArrowsIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 210 | text: 'Transfer', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 211 | action: () => {}, |
| 212 | }, |
| 213 | { |
| 214 | Icon: TrashBinIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 215 | text: 'Delete message', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 216 | action: () => {}, |
| 217 | }, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 218 | ]; |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 219 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 220 | const toggleMoreMenu = useCallback(() => setOpen((open) => !open), [setOpen]); |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 221 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 222 | const onClose = useCallback(() => { |
| 223 | setOpen(false); |
| 224 | }, [setOpen]); |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 225 | |
| 226 | return ( |
| 227 | <Tooltip |
| 228 | {...props} |
| 229 | classes={{ tooltip: className }} // Required for styles. Don't know why |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 230 | placement={props.position == 'start' ? 'right-start' : 'left-start'} |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 231 | PopperProps={{ |
| 232 | modifiers: [ |
| 233 | { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 234 | name: 'offset', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 235 | options: { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 236 | offset: [-2, -30], |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 237 | }, |
| 238 | }, |
| 239 | ], |
| 240 | }} |
| 241 | onClose={onClose} |
| 242 | title={ |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 243 | <Stack> |
| 244 | {' '} |
| 245 | {/* Whole tooltip's content */} |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 246 | <Stack // Main options |
| 247 | direction="row" |
| 248 | spacing="16px" |
| 249 | > |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 250 | {emojis.map((emoji) => ( |
| 251 | <EmojiButton key={emoji} emoji={emoji} /> |
| 252 | ))} |
| 253 | <ReplyMessageButton /> |
| 254 | <MoreButton onClick={toggleMoreMenu} /> |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 255 | </Stack> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 256 | {open && ( // Additional menu options |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 257 | <> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 258 | <Divider sx={{ paddingTop: '16px' }} /> |
| 259 | <List sx={{ padding: 0, paddingTop: '8px', marginBottom: '-8px' }}> |
| 260 | {additionalOptions.map((option) => ( |
| 261 | <ListItemButton |
| 262 | key={option.text} |
| 263 | sx={{ |
| 264 | padding: '8px', |
| 265 | }} |
| 266 | > |
| 267 | <Stack // Could not find proper way to set spacing between ListItemIcon and ListItemText |
| 268 | direction="row" |
| 269 | spacing="16px" |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 270 | > |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 271 | <option.Icon |
| 272 | sx={{ |
| 273 | height: '16px', |
| 274 | margin: 0, |
| 275 | color: (theme) => theme.palette.primary.dark, |
| 276 | }} |
| 277 | /> |
| 278 | <ListItemText |
| 279 | primary={option.text} |
| 280 | primaryTypographyProps={{ |
| 281 | fontSize: '12px', |
| 282 | lineHeight: '16px', |
| 283 | }} |
| 284 | sx={{ |
| 285 | height: '16px', |
| 286 | margin: 0, |
| 287 | }} |
| 288 | /> |
| 289 | </Stack> |
| 290 | </ListItemButton> |
| 291 | ))} |
| 292 | </List> |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 293 | </> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 294 | )} |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 295 | </Stack> |
| 296 | } |
| 297 | /> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 298 | ); |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 299 | })(({ theme, position }) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 300 | const largeRadius = '20px'; |
| 301 | const smallRadius = '5px'; |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 302 | return { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 303 | backgroundColor: 'white', |
| 304 | padding: '16px', |
| 305 | boxShadow: '3px 3px 7px #00000029', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 306 | borderRadius: largeRadius, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 307 | borderStartStartRadius: position == 'start' ? smallRadius : largeRadius, |
| 308 | borderStartEndRadius: position == 'end' ? smallRadius : largeRadius, |
| 309 | }; |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 310 | }); |
| 311 | |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 312 | const MessageBubble = (props) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 313 | const largeRadius = '20px'; |
| 314 | const smallRadius = '5px'; |
Adrien Béraud | 023f7cf | 2022-09-18 14:57:53 -0400 | [diff] [blame] | 315 | const radius = useMemo(() => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 316 | if (props.position == 'start') { |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 317 | return { |
| 318 | borderStartStartRadius: props.isFirstOfGroup ? largeRadius : smallRadius, |
| 319 | borderStartEndRadius: largeRadius, |
| 320 | borderEndStartRadius: props.isLastOfGroup ? largeRadius : smallRadius, |
| 321 | borderEndEndRadius: largeRadius, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 322 | }; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 323 | } |
| 324 | return { |
| 325 | borderStartStartRadius: largeRadius, |
| 326 | borderStartEndRadius: props.isFirstOfGroup ? largeRadius : smallRadius, |
| 327 | borderEndStartRadius: largeRadius, |
| 328 | borderEndEndRadius: props.isLastOfGroup ? largeRadius : smallRadius, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 329 | }; |
| 330 | }, [props.isFirstOfGroup, props.isLastOfGroup, props.position]); |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 331 | |
| 332 | return ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 333 | <MessageTooltip position={props.position}> |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 334 | <Box |
| 335 | sx={{ |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 336 | width: 'fit-content', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 337 | backgroundColor: props.backgroundColor, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 338 | padding: '16px', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 339 | ...radius, |
| 340 | }} |
| 341 | > |
| 342 | {props.children} |
| 343 | </Box> |
| 344 | </MessageTooltip> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 345 | ); |
| 346 | }; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 347 | |
| 348 | const ParticipantName = (props) => { |
| 349 | return ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 350 | <Box marginBottom="6px" marginLeft="16px" marginRight="16px"> |
| 351 | <Typography variant="caption" color="#A7A7A7" fontWeight={700}> |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 352 | {props.name} |
| 353 | </Typography> |
| 354 | </Box> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 355 | ); |
| 356 | }; |