From 5c1b1e96814ff861954940e178befa8a091bb23e Mon Sep 17 00:00:00 2001 From: 7w1 Date: Mon, 2 Mar 2026 00:33:33 -0600 Subject: [PATCH] fix #38 option for messages to be right aligned in bubble layout --- CHANGELOG.md | 5 +- src/app/components/message/layout/Bubble.tsx | 86 ++++++++++++++----- .../components/message/layout/layout.css.ts | 14 +++ src/app/features/room/message/Message.tsx | 8 +- .../features/settings/cosmetics/Cosmetics.tsx | 8 ++ src/app/state/settings.ts | 2 + 6 files changed, 98 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b6528db..f2ac2029 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ # Sable Client Changelog -## 1.2.3 - in dev +## 1.2.3 - 3/2/2026 - Actually fix quotes around colors for tuwunel homeservers ([#46](https://github.com/7w1/sable/issues/46)) +- Option to have your own message bubbles in bubble layout right aligned ([#38](https://github.com/7w1/sable/issues/38)) +- Allow responding to and rendering replies with files ([#54](https://github.com/7w1/sable/pull/54)) - [nushea](https://github.com/nushea) +- Added Gruvbox theme ([#51](https://github.com/7w1/sable/pull/51)) - [dollth.ing](https://github.com/dollth-ing) ## 1.2.2 v2 diff --git a/src/app/components/message/layout/Bubble.tsx b/src/app/components/message/layout/Bubble.tsx index 93ff84bc..32f341f2 100644 --- a/src/app/components/message/layout/Bubble.tsx +++ b/src/app/components/message/layout/Bubble.tsx @@ -25,39 +25,79 @@ function BubbleLeftArrow({ variant }: BubbleArrowProps) { ); } +function BubbleRightArrow({ variant }: BubbleArrowProps) { + return ( + + + + ); +} type BubbleLayoutProps = { hideBubble?: boolean; before?: ReactNode; header?: ReactNode; + align?: 'left' | 'right'; }; export const BubbleLayout = as<'div', BubbleLayoutProps>( - ({ hideBubble, before, header, children, ...props }, ref) => ( - - - {before} - - - {header} - {hideBubble ? ( - children - ) : ( - - - {before ? : null} - {children} + ({ hideBubble, before, header, align = 'left', children, ...props }, ref) => { + const isRight = align === 'right'; + + return ( + + {!isRight && ( + + {before} + + )} + + + {header} + {hideBubble ? ( + children + ) : ( + + + {before && !isRight ? : null} + {before && isRight ? : null} + + {children} + + )} + + + {isRight && ( + + {before} )} - - ) + ); + } ); diff --git a/src/app/components/message/layout/layout.css.ts b/src/app/components/message/layout/layout.css.ts index ffc7d172..1070c843 100644 --- a/src/app/components/message/layout/layout.css.ts +++ b/src/app/components/message/layout/layout.css.ts @@ -153,6 +153,10 @@ export const BubbleContentArrowLeft = style({ borderTopLeftRadius: 0, }); +export const BubbleContentArrowRight = style({ + borderTopRightRadius: 0, +}); + export const BubbleLeftArrow = style({ width: toRem(9), height: toRem(8), @@ -163,6 +167,16 @@ export const BubbleLeftArrow = style({ zIndex: 1, }); +export const BubbleRightArrow = style({ + width: toRem(9), + height: toRem(8), + + position: 'absolute', + top: 0, + right: toRem(-8), + zIndex: 1, +}); + export const Username = style({ overflow: 'hidden', whiteSpace: 'nowrap', diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index 7e266f91..e379d054 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -356,6 +356,7 @@ function MessageInternal( const [mobileOptionsOpen, setMobileOptionsOpen] = useState(false); const optionsRef = useRef(null); const [showPronouns] = useSetting(settingsAtom, 'showPronouns'); + const [useRightBubbles] = useSetting(settingsAtom, 'useRightBubbles'); useEffect(() => { if (!mobileOptionsOpen) return undefined; @@ -862,7 +863,12 @@ function MessageInternal( )} {messageLayout === MessageLayout.Bubble && ( - +
{msgContentJSX}
diff --git a/src/app/features/settings/cosmetics/Cosmetics.tsx b/src/app/features/settings/cosmetics/Cosmetics.tsx index 262e766c..8c0c6aca 100644 --- a/src/app/features/settings/cosmetics/Cosmetics.tsx +++ b/src/app/features/settings/cosmetics/Cosmetics.tsx @@ -170,6 +170,7 @@ function IdentityCosmetics() { 'renderGlobalNameColors' ); const [uniformIcons, setUniformIcons] = useSetting(settingsAtom, 'uniformIcons'); + const [rightBubbles, setRightBubbles] = useSetting(settingsAtom, 'useRightBubbles'); return ( @@ -210,6 +211,13 @@ function IdentityCosmetics() { after={} /> + + } + /> + ); } diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index fe98b7a4..ca442e53 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -63,6 +63,7 @@ export interface Settings { mobileGestures: boolean; rightSwipeAction: RightSwipeAction; hideMembershipInReadOnly: boolean; + useRightBubbles: boolean; } const defaultSettings: Settings = { @@ -112,6 +113,7 @@ const defaultSettings: Settings = { mobileGestures: true, rightSwipeAction: RightSwipeAction.Reply, hideMembershipInReadOnly: true, + useRightBubbles: false, }; export const getSettings = () => {