From 01d57deea1c53544ff1809d755df0e7f9b559e9f Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Sun, 31 Aug 2025 08:18:10 +0530 Subject: [PATCH] Add arrow to message bubbles and improve spacing --- src/app/components/message/layout/Bubble.tsx | 35 ++++++++++++----- .../components/message/layout/layout.css.ts | 39 ++++++++++++++++++- src/app/features/room/message/Message.tsx | 7 +++- src/app/features/room/message/styles.css.ts | 3 ++ 4 files changed, 72 insertions(+), 12 deletions(-) diff --git a/src/app/components/message/layout/Bubble.tsx b/src/app/components/message/layout/Bubble.tsx index 6f8e70da..3e0a68dc 100644 --- a/src/app/components/message/layout/Bubble.tsx +++ b/src/app/components/message/layout/Bubble.tsx @@ -1,18 +1,35 @@ import React, { ReactNode } from 'react'; +import classNames from 'classnames'; import { Box, as } from 'folds'; import * as css from './layout.css'; type BubbleLayoutProps = { + self?: boolean; before?: ReactNode; }; -export const BubbleLayout = as<'div', BubbleLayoutProps>(({ before, children, ...props }, ref) => ( - - - {before} +export const BubbleLayout = as<'div', BubbleLayoutProps>( + ({ self, before, children, ...props }, ref) => ( + + + {before} + + + {children} + - - {children} - - -)); + ) +); diff --git a/src/app/components/message/layout/layout.css.ts b/src/app/components/message/layout/layout.css.ts index 43949cef..89343d41 100644 --- a/src/app/components/message/layout/layout.css.ts +++ b/src/app/components/message/layout/layout.css.ts @@ -140,7 +140,44 @@ export const BubbleContent = style({ padding: config.space.S200, backgroundColor: color.SurfaceVariant.Container, color: color.SurfaceVariant.OnContainer, - borderRadius: config.radii.R400, + borderRadius: config.radii.R500, + position: 'relative', +}); + +export const BubbleContentArrow = style({ + selectors: { + '&::before': { + content: '', + display: 'inline-block', + background: 'inherit', + width: toRem(8), + height: toRem(8), + position: 'absolute', + transform: 'rotateZ(45deg)', + }, + }, +}); + +export const BubbleContentArrowLeft = style({ + selectors: { + '&::before': { + left: toRem(-4), + top: config.radii.R500, + zIndex: 1, + borderBottomLeftRadius: toRem(2), + }, + }, +}); + +export const BubbleContentArrowRight = style({ + selectors: { + '&::before': { + right: toRem(-4), + top: config.radii.R500, + zIndex: 1, + borderTopRightRadius: toRem(2), + }, + }, }); export const Username = style({ diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index fbe35770..a1556261 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -723,6 +723,7 @@ export const Message = as<'div', MessageProps>( const mx = useMatrixClient(); const useAuthentication = useMediaAuthentication(); const senderId = mEvent.getSender() ?? ''; + const [hover, setHover] = useState(false); const { hoverProps } = useHover({ onHoverChange: setHover }); const { focusWithinProps } = useFocusWithin({ onFocusWithinChange: setHover }); @@ -746,7 +747,7 @@ export const Message = as<'div', MessageProps>( @@ -875,7 +876,9 @@ export const Message = as<'div', MessageProps>( return (