Skip to content

Commit 72c2ef9

Browse files
Adjustments & limitation removal
1 parent d756eff commit 72c2ef9

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

examples/vite/src/App.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ import {
2727
MessageList,
2828
Window,
2929
WithComponents,
30+
GroupAvatar,
31+
ReactionsList,
32+
useMessageContext,
3033
} from 'stream-chat-react';
3134
import { createTextComposerEmojiMiddleware, EmojiPicker } from 'stream-chat-react/emojis';
3235
import { init, SearchIndex } from 'emoji-mart';
@@ -79,6 +82,19 @@ const useUser = () => {
7982
return { userId: userId, tokenProvider };
8083
};
8184

85+
const CustomMessageReactions = (props: React.ComponentProps<typeof ReactionsList>) => {
86+
const { isMyMessage } = useMessageContext();
87+
const messageBelongsToCurrentUser = isMyMessage();
88+
89+
return (
90+
<ReactionsList
91+
{...props}
92+
horizontalPosition={messageBelongsToCurrentUser ? 'start' : 'end'}
93+
verticalPosition='top'
94+
/>
95+
);
96+
};
97+
8298
const App = () => {
8399
const { userId, tokenProvider } = useUser();
84100

@@ -141,7 +157,13 @@ const App = () => {
141157
if (!chatClient) return <>Loading...</>;
142158

143159
return (
144-
<WithComponents overrides={{ emojiSearchIndex: SearchIndex, EmojiPicker }}>
160+
<WithComponents
161+
overrides={{
162+
emojiSearchIndex: SearchIndex,
163+
EmojiPicker,
164+
ReactionsList: CustomMessageReactions,
165+
}}
166+
>
145167
<Chat client={chatClient} isMessageAIGenerated={isMessageAIGenerated}>
146168
<ChatView>
147169
<ChatView.Selector />

src/components/Message/styling/Message.scss

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255

256256
.str-chat__message-options {
257257
grid-area: options;
258-
align-items: center;
258+
align-items: flex-start;
259259
justify-content: flex-end;
260260
flex-direction: row-reverse;
261261
width: var(--str-chat-message-options-size);
@@ -303,14 +303,13 @@
303303
grid-area: reactions;
304304
min-width: 100%;
305305
z-index: 1;
306-
position: absolute;
307306

308307
&:has(.str-chat__message-reactions--top) {
309-
bottom: calc(100% - var(--spacing-xs));
308+
margin-bottom: calc(var(--spacing-xxs) * -1);
310309
}
311310

312311
&:has(.str-chat__message-reactions--bottom) {
313-
top: calc(100% + var(--spacing-xxs));
312+
padding-block: var(--spacing-xxs);
314313
}
315314

316315
&:has(.str-chat__message-reactions--end) {
@@ -323,19 +322,17 @@
323322
}
324323

325324
&:has(.str-chat__message-reactions--top) {
326-
margin-top: calc(26px - var(--spacing-xs));
327325
}
328326

329327
&:has(.str-chat__message-reactions--bottom) {
330-
margin-bottom: calc(26px + var(--spacing-xxs) * 2);
331-
332328
grid-template-areas:
333329
'message-bubble options'
334330
'reactions .';
335331
}
336332

337333
.str-chat__message-bubble {
338334
display: flex;
335+
justify-self: flex-start;
339336
grid-area: message-bubble;
340337
position: relative;
341338
min-width: 0;
@@ -354,6 +351,7 @@
354351
}
355352

356353
&.str-chat__message--me .str-chat__message-bubble {
354+
justify-self: flex-end;
357355
background-color: var(--str-chat__own-message-bubble-background-color);
358356
}
359357

0 commit comments

Comments
 (0)