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'; |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 23 | import { useCallback, useMemo, useState } from 'react'; |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 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) => { |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 146 | const isUser = props.messages[0]?.author === props.account.getUri(); |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 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 | |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 151 | let authorName; |
| 152 | if (isUser) { |
| 153 | authorName = props.account.getDisplayName(); |
| 154 | } else { |
| 155 | const member = props.members.find((member) => props.messages[0]?.author === member.contact.getUri()); |
| 156 | const contact = member.contact; |
| 157 | authorName = contact.getDisplayName(); |
| 158 | } |
| 159 | |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 160 | return ( |
idillon | 89720a8 | 2022-09-06 18:47:05 -0400 | [diff] [blame] | 161 | <Stack // Row for a group of message bubbles with the user's infos |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 162 | direction="row" |
| 163 | justifyContent={position} |
idillon | 89720a8 | 2022-09-06 18:47:05 -0400 | [diff] [blame] | 164 | alignItems="end" |
| 165 | spacing="10px" |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 166 | > |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 167 | {!isUser && ( |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 168 | <ConversationAvatar displayName={authorName} sx={{ width: '22px', height: '22px', fontSize: '15px' }} /> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 169 | )} |
idillon | 89720a8 | 2022-09-06 18:47:05 -0400 | [diff] [blame] | 170 | <Stack // Container to align the bubbles to the same side of a row |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 171 | width="66.66%" |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 172 | alignItems={position} |
| 173 | > |
idillon | ae655dd | 2022-10-14 18:11:02 -0400 | [diff] [blame] | 174 | <ParticipantName name={authorName} position={position} /> |
idillon | 89720a8 | 2022-09-06 18:47:05 -0400 | [diff] [blame] | 175 | <Stack // Container for a group of message bubbles |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 176 | spacing="6px" |
| 177 | alignItems={position} |
| 178 | direction="column-reverse" |
| 179 | > |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 180 | {props.messages.map((message, index) => { |
| 181 | let Component; |
| 182 | switch (message.type) { |
| 183 | case 'text/plain': |
| 184 | Component = MessageText; |
| 185 | break; |
| 186 | case 'application/data-transfer+json': |
| 187 | Component = MessageDataTransfer; |
| 188 | break; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 189 | } |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 190 | return ( |
| 191 | <Component // Single message |
| 192 | key={message.id} |
| 193 | message={message} |
| 194 | textColor={textColor} |
| 195 | position={position} |
| 196 | bubbleColor={bubbleColor} |
| 197 | isFirstOfGroup={index == props.messages.length - 1} |
| 198 | isLastOfGroup={index == 0} |
| 199 | /> |
| 200 | ); |
| 201 | })} |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 202 | </Stack> |
| 203 | </Stack> |
| 204 | </Stack> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 205 | ); |
| 206 | }; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 207 | |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 208 | const MessageTooltip = styled(({ className, ...props }) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 209 | const [open, setOpen] = useState(false); |
| 210 | const emojis = ['😎', '😄', '😍']; // Should be last three used emojis |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 211 | const additionalOptions = [ |
| 212 | { |
| 213 | Icon: TwoSheetsIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 214 | text: 'Copy', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 215 | action: () => {}, |
| 216 | }, |
| 217 | { |
| 218 | Icon: OppositeArrowsIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 219 | text: 'Transfer', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 220 | action: () => {}, |
| 221 | }, |
| 222 | { |
| 223 | Icon: TrashBinIcon, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 224 | text: 'Delete message', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 225 | action: () => {}, |
| 226 | }, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 227 | ]; |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 228 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 229 | const toggleMoreMenu = useCallback(() => setOpen((open) => !open), [setOpen]); |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 230 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 231 | const onClose = useCallback(() => { |
| 232 | setOpen(false); |
| 233 | }, [setOpen]); |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 234 | |
| 235 | return ( |
| 236 | <Tooltip |
| 237 | {...props} |
| 238 | classes={{ tooltip: className }} // Required for styles. Don't know why |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 239 | placement={props.position == 'start' ? 'right-start' : 'left-start'} |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 240 | PopperProps={{ |
| 241 | modifiers: [ |
| 242 | { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 243 | name: 'offset', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 244 | options: { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 245 | offset: [-2, -30], |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 246 | }, |
| 247 | }, |
| 248 | ], |
| 249 | }} |
| 250 | onClose={onClose} |
| 251 | title={ |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 252 | <Stack> |
| 253 | {' '} |
| 254 | {/* Whole tooltip's content */} |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 255 | <Stack // Main options |
| 256 | direction="row" |
| 257 | spacing="16px" |
| 258 | > |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 259 | {emojis.map((emoji) => ( |
| 260 | <EmojiButton key={emoji} emoji={emoji} /> |
| 261 | ))} |
| 262 | <ReplyMessageButton /> |
| 263 | <MoreButton onClick={toggleMoreMenu} /> |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 264 | </Stack> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 265 | {open && ( // Additional menu options |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 266 | <> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 267 | <Divider sx={{ paddingTop: '16px' }} /> |
| 268 | <List sx={{ padding: 0, paddingTop: '8px', marginBottom: '-8px' }}> |
| 269 | {additionalOptions.map((option) => ( |
| 270 | <ListItemButton |
| 271 | key={option.text} |
| 272 | sx={{ |
| 273 | padding: '8px', |
| 274 | }} |
| 275 | > |
| 276 | <Stack // Could not find proper way to set spacing between ListItemIcon and ListItemText |
| 277 | direction="row" |
| 278 | spacing="16px" |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 279 | > |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 280 | <option.Icon |
| 281 | sx={{ |
| 282 | height: '16px', |
| 283 | margin: 0, |
| 284 | color: (theme) => theme.palette.primary.dark, |
| 285 | }} |
| 286 | /> |
| 287 | <ListItemText |
| 288 | primary={option.text} |
| 289 | primaryTypographyProps={{ |
| 290 | fontSize: '12px', |
| 291 | lineHeight: '16px', |
| 292 | }} |
| 293 | sx={{ |
| 294 | height: '16px', |
| 295 | margin: 0, |
| 296 | }} |
| 297 | /> |
| 298 | </Stack> |
| 299 | </ListItemButton> |
| 300 | ))} |
| 301 | </List> |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 302 | </> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 303 | )} |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 304 | </Stack> |
| 305 | } |
| 306 | /> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 307 | ); |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 308 | })(({ theme, position }) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 309 | const largeRadius = '20px'; |
| 310 | const smallRadius = '5px'; |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 311 | return { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 312 | backgroundColor: 'white', |
| 313 | padding: '16px', |
| 314 | boxShadow: '3px 3px 7px #00000029', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 315 | borderRadius: largeRadius, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 316 | borderStartStartRadius: position == 'start' ? smallRadius : largeRadius, |
| 317 | borderStartEndRadius: position == 'end' ? smallRadius : largeRadius, |
| 318 | }; |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 319 | }); |
| 320 | |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 321 | const MessageBubble = (props) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 322 | const largeRadius = '20px'; |
| 323 | const smallRadius = '5px'; |
Adrien Béraud | 023f7cf | 2022-09-18 14:57:53 -0400 | [diff] [blame] | 324 | const radius = useMemo(() => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 325 | if (props.position == 'start') { |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 326 | return { |
| 327 | borderStartStartRadius: props.isFirstOfGroup ? largeRadius : smallRadius, |
| 328 | borderStartEndRadius: largeRadius, |
| 329 | borderEndStartRadius: props.isLastOfGroup ? largeRadius : smallRadius, |
| 330 | borderEndEndRadius: largeRadius, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 331 | }; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 332 | } |
| 333 | return { |
| 334 | borderStartStartRadius: largeRadius, |
| 335 | borderStartEndRadius: props.isFirstOfGroup ? largeRadius : smallRadius, |
| 336 | borderEndStartRadius: largeRadius, |
| 337 | borderEndEndRadius: props.isLastOfGroup ? largeRadius : smallRadius, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 338 | }; |
| 339 | }, [props.isFirstOfGroup, props.isLastOfGroup, props.position]); |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 340 | |
| 341 | return ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 342 | <MessageTooltip position={props.position}> |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 343 | <Box |
| 344 | sx={{ |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 345 | width: 'fit-content', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 346 | backgroundColor: props.backgroundColor, |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 347 | padding: '16px', |
idillon | 927b759 | 2022-09-15 12:56:45 -0400 | [diff] [blame] | 348 | ...radius, |
| 349 | }} |
| 350 | > |
| 351 | {props.children} |
| 352 | </Box> |
| 353 | </MessageTooltip> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 354 | ); |
| 355 | }; |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 356 | |
| 357 | const ParticipantName = (props) => { |
| 358 | return ( |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 359 | <Box marginBottom="6px" marginLeft="16px" marginRight="16px"> |
| 360 | <Typography variant="caption" color="#A7A7A7" fontWeight={700}> |
idillon | bef18a5 | 2022-09-01 01:51:40 -0400 | [diff] [blame] | 361 | {props.name} |
| 362 | </Typography> |
| 363 | </Box> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 364 | ); |
| 365 | }; |