fix #38 option for messages to be right aligned in bubble layout

This commit is contained in:
7w1 committed 2026-03-02 00:33:33 -06:00
1 parent 7c9bd53306
commit 5c1b1e9681
6 files changed
+98 -25

No files matched your search

+4 -1
View File
@@ -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
+63 -23
View File
@@ -25,39 +25,79 @@ function BubbleLeftArrow({ variant }: BubbleArrowProps) {
</svg>
);
}
function BubbleRightArrow({ variant }: BubbleArrowProps) {
return (
<svg
className={css.BubbleRightArrow}
style={{ transform: 'scaleX(-1)' }}
width="9"
height="8"
viewBox="0 0 9 8"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M9.00004 8V0H4.82847C3.04666 0 2.15433 2.15428 3.41426 3.41421L8.00004 8H9.00004Z"
fill={color[variant].Container}
/>
</svg>
);
}
type BubbleLayoutProps = {
hideBubble?: boolean;
before?: ReactNode;
header?: ReactNode;
align?: 'left' | 'right';
};
export const BubbleLayout = as<'div', BubbleLayoutProps>(
({ hideBubble, before, header, children, ...props }, ref) => (
<Box gap="300" {...props} ref={ref}>
<Box className={css.BubbleBefore} shrink="No">
{before}
</Box>
<Box grow="Yes" direction="Column">
{header}
{hideBubble ? (
children
) : (
<Box>
<Box
className={
hideBubble
? undefined
: classNames(css.BubbleContent, before ? css.BubbleContentArrowLeft : undefined)
}
direction="Column"
>
{before ? <BubbleLeftArrow variant="SurfaceVariant" /> : null}
{children}
({ hideBubble, before, header, align = 'left', children, ...props }, ref) => {
const isRight = align === 'right';
return (
<Box gap="300" {...props} ref={ref}>
{!isRight && (
<Box className={css.BubbleBefore} shrink="No">
{before}
</Box>
)}
<Box grow="Yes" direction="Column" alignItems={isRight ? 'End' : 'Start'}>
{header}
{hideBubble ? (
children
) : (
<Box>
<Box
className={
hideBubble
? undefined
: classNames(
css.BubbleContent,
before && !isRight ? css.BubbleContentArrowLeft : undefined,
before && isRight ? css.BubbleContentArrowRight : undefined
)
}
direction="Column"
>
{before && !isRight ? <BubbleLeftArrow variant="SurfaceVariant" /> : null}
{before && isRight ? <BubbleRightArrow variant="SurfaceVariant" /> : null}
{children}
</Box>
</Box>
)}
</Box>
{isRight && (
<Box className={css.BubbleBefore} shrink="No">
{before}
</Box>
)}
</Box>
</Box>
)
);
}
);
@@ -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',
+7 -1
View File
@@ -356,6 +356,7 @@ function MessageInternal(
const [mobileOptionsOpen, setMobileOptionsOpen] = useState(false);
const optionsRef = useRef<HTMLDivElement>(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 && (
<SwipeableMessageWrapper onReply={handleSwipeReply}>
<BubbleLayout before={avatarJSX} header={headerJSX} onContextMenu={handleContextMenu}>
<BubbleLayout
before={avatarJSX}
header={headerJSX}
onContextMenu={handleContextMenu}
align={useRightBubbles && senderId === mx.getUserId() ? 'right' : 'left'}
>
<div onPointerDown={onDoubleTap}>{msgContentJSX}</div>
</BubbleLayout>
</SwipeableMessageWrapper>
@@ -170,6 +170,7 @@ function IdentityCosmetics() {
'renderGlobalNameColors'
);
const [uniformIcons, setUniformIcons] = useSetting(settingsAtom, 'uniformIcons');
const [rightBubbles, setRightBubbles] = useSetting(settingsAtom, 'useRightBubbles');
return (
<Box direction="Column" gap="100">
@@ -210,6 +211,13 @@ function IdentityCosmetics() {
after={<Switch variant="Primary" value={uniformIcons} onChange={setUniformIcons} />}
/>
</SequenceCard>
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
<SettingTile
title="Right Aligned Bubbles"
description="When using bubble layout, have your bubbles right aligned."
after={<Switch variant="Primary" value={rightBubbles} onChange={setRightBubbles} />}
/>
</SequenceCard>
</Box>
);
}
+2
View File
@@ -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 = () => {