Skip to content

Commit 19dff83

Browse files
authored
feat: reaction list bottom redesign (#3424)
This pull request introduces a new `reactionListType` prop to the message and channel components, allowing the bottom reaction list to be displayed in either a "segmented" or "clustered" style. It also refactors the `ReactionListBottom` component for improved flexibility and code clarity, and adds support for selecting reactions and customizing their appearance. **Key changes:** **1. Reaction List Type and Propagation** - Added a new `reactionListType` prop (default: `'segmented'`) to `Channel`, `Message`, and `MessageSimple` components, and ensured it is passed through all relevant contexts and props. This enables consumers to control the visual style of the bottom reaction list. [[1]](diffhunk://#diff-f7139f4cdb523365cfc277d72b827a3432325b9c6460cf14628f9df67d0e4d85R389) [[2]](diffhunk://#diff-f7139f4cdb523365cfc277d72b827a3432325b9c6460cf14628f9df67d0e4d85R712) [[3]](diffhunk://#diff-f7139f4cdb523365cfc277d72b827a3432325b9c6460cf14628f9df67d0e4d85R1965) [[4]](diffhunk://#diff-d3e4f4cdcef10807a38eab86f6ead6bbfe01980e7326f3cadfeb8186760d7af1R89) [[5]](diffhunk://#diff-d3e4f4cdcef10807a38eab86f6ead6bbfe01980e7326f3cadfeb8186760d7af1R202) [[6]](diffhunk://#diff-6c4943fcf0d32148b663091935ac039195d602cef7654b16bb93514ca2b3ba83R78) [[7]](diffhunk://#diff-6c4943fcf0d32148b663091935ac039195d602cef7654b16bb93514ca2b3ba83R117) [[8]](diffhunk://#diff-6c4943fcf0d32148b663091935ac039195d602cef7654b16bb93514ca2b3ba83R457) [[9]](diffhunk://#diff-6c4943fcf0d32148b663091935ac039195d602cef7654b16bb93514ca2b3ba83R492) [[10]](diffhunk://#diff-2335969a90d85933b956775f38af8bf0485cd538b0e73115b8087467d7ed116aR242) **2. ReactionListBottom Component Refactor** - Refactored `ReactionListBottom` to support both "segmented" and "clustered" layouts, with the new `type` prop determining the style. The component now uses a more flexible rendering approach and improved styling, including item separators and alignment based on message direction. [[1]](diffhunk://#diff-926ded9f8a41b99e3b915a72424b44c11631585a26cfc0fa236d68979dafddb6L1-R4) [[2]](diffhunk://#diff-926ded9f8a41b99e3b915a72424b44c11631585a26cfc0fa236d68979dafddb6L193-R178) [[3]](diffhunk://#diff-926ded9f8a41b99e3b915a72424b44c11631585a26cfc0fa236d68979dafddb6R188-R193) [[4]](diffhunk://#diff-926ded9f8a41b99e3b915a72424b44c11631585a26cfc0fa236d68979dafddb6R206-R232) [[5]](diffhunk://#diff-926ded9f8a41b99e3b915a72424b44c11631585a26cfc0fa236d68979dafddb6L257-R357) **3. Reaction Selection and Overlay Improvements** - Improved the reaction selection logic by adding a `selectedReaction` state and updating the `showReactionsOverlay` callback to accept an optional reaction type. This allows the overlay to highlight the selected reaction. [[1]](diffhunk://#diff-4234b2ddfee0f9e29e7b465026e851cf75f5d16f03a175c86374168589335d8eL251-L253) [[2]](diffhunk://#diff-4234b2ddfee0f9e29e7b465026e851cf75f5d16f03a175c86374168589335d8eL352-R354) [[3]](diffhunk://#diff-4234b2ddfee0f9e29e7b465026e851cf75f5d16f03a175c86374168589335d8eR882) **4. ReactionListBottom Item Enhancements** - Updated `ReactionListBottomItem` to accept `selected` and `showCount` props, and refactored its rendering to use a wrapper component and remove unnecessary animation code. The icon and count display logic has been simplified and improved for accessibility and maintainability. [[1]](diffhunk://#diff-926ded9f8a41b99e3b915a72424b44c11631585a26cfc0fa236d68979dafddb6R50-R51) [[2]](diffhunk://#diff-926ded9f8a41b99e3b915a72424b44c11631585a26cfc0fa236d68979dafddb6R64-R79) [[3]](diffhunk://#diff-926ded9f8a41b99e3b915a72424b44c11631585a26cfc0fa236d68979dafddb6L127) [[4]](diffhunk://#diff-926ded9f8a41b99e3b915a72424b44c11631585a26cfc0fa236d68979dafddb6L140-R132) **5. Styling and Theming Updates** - Introduced a new `useStyles` hook for `ReactionListBottom` to handle dynamic styling based on message alignment and theme, and improved the structure of style definitions for better consistency and flexibility. These changes collectively improve the flexibility, usability, and maintainability of the reaction list feature in the messaging UI.
1 parent 565601d commit 19dff83

10 files changed

Lines changed: 301 additions & 136 deletions

File tree

package/src/components/Channel/Channel.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ export type ChannelPropsWithContext = Pick<ChannelContextValue, 'channel'> &
386386
| 'MessageUserReactionsItem'
387387
| 'ReactionListBottom'
388388
| 'reactionListPosition'
389+
| 'reactionListType'
389390
| 'ReactionListTop'
390391
| 'Reply'
391392
| 'shouldShowUnreadUnderlay'
@@ -708,6 +709,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
708709
PollContent,
709710
ReactionListBottom = ReactionListBottomDefault,
710711
reactionListPosition = 'top',
712+
reactionListType = 'segmented',
711713
ReactionListTop = ReactionListTopDefault,
712714
Reply = ReplyDefault,
713715
ScrollToBottomButton = ScrollToBottomButtonDefault,
@@ -1960,6 +1962,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
19601962
PollContent,
19611963
ReactionListBottom,
19621964
reactionListPosition,
1965+
reactionListType,
19631966
ReactionListTop,
19641967
removeMessage,
19651968
Reply,

package/src/components/Channel/hooks/useCreateMessagesContext.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export const useCreateMessagesContext = ({
8686
PollContent,
8787
ReactionListBottom,
8888
reactionListPosition,
89+
reactionListType,
8990
ReactionListTop,
9091
removeMessage,
9192
Reply,
@@ -198,6 +199,7 @@ export const useCreateMessagesContext = ({
198199
PollContent,
199200
ReactionListBottom,
200201
reactionListPosition,
202+
reactionListType,
201203
ReactionListTop,
202204
removeMessage,
203205
Reply,

package/src/components/Message/Message.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ export type MessagePropsWithContext = Pick<
248248
*/
249249
const MessageWithContext = (props: MessagePropsWithContext) => {
250250
const [isErrorInMessage, setIsErrorInMessage] = useState(false);
251-
const [showMessageReactions, setShowMessageReactions] = useState(false);
251+
const [showMessageReactions, setShowMessageReactions] = useState<boolean>(false);
252+
const [selectedReaction, setSelectedReaction] = useState<string | undefined>(undefined);
252253
const [isBounceDialogOpen, setIsBounceDialogOpen] = useState(false);
253-
// const [selectedReaction, setSelectedReaction] = useState<string | undefined>(undefined);
254254

255255
const {
256256
channel,
@@ -349,10 +349,9 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
349349
}
350350
});
351351

352-
const showReactionsOverlay = useStableCallback(() => {
353-
if (!showMessageReactions) {
354-
setShowMessageReactions(true);
355-
}
352+
const showReactionsOverlay = useStableCallback((reactionType?: string) => {
353+
setShowMessageReactions(true);
354+
setSelectedReaction(reactionType);
356355
});
357356

358357
const { setNativeScrollability } = useMessageListItemContext();
@@ -880,6 +879,7 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
880879
message={message}
881880
MessageUserReactionsAvatar={MessageUserReactionsAvatar}
882881
MessageUserReactionsItem={MessageUserReactionsItem}
882+
selectedReaction={selectedReaction}
883883
/>
884884
</BottomSheetModal>
885885
) : null}

package/src/components/Message/MessageSimple/MessageSimple.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export type MessageSimplePropsWithContext = Pick<
7575
| 'messageSwipeToReplyHitSlop'
7676
| 'ReactionListBottom'
7777
| 'reactionListPosition'
78+
| 'reactionListType'
7879
| 'ReactionListTop'
7980
> & {
8081
/**
@@ -113,6 +114,7 @@ const MessageSimpleWithContext = forwardRef<View, MessageSimplePropsWithContext>
113114
otherAttachments,
114115
ReactionListBottom,
115116
reactionListPosition,
117+
reactionListType,
116118
ReactionListTop,
117119
shouldRenderSwipeableWrapper,
118120
setQuotedMessage,
@@ -274,7 +276,7 @@ const MessageSimpleWithContext = forwardRef<View, MessageSimplePropsWithContext>
274276
</View>
275277

276278
{reactionListPosition === 'bottom' && ReactionListBottom ? (
277-
<ReactionListBottom />
279+
<ReactionListBottom type={reactionListType} />
278280
) : null}
279281
<MessageFooter date={message.created_at} isDeleted={!!isMessageTypeDeleted} />
280282
</View>
@@ -452,6 +454,7 @@ export const MessageSimple = forwardRef<View, MessageSimpleProps>((props, ref) =
452454
myMessageTheme,
453455
ReactionListBottom,
454456
reactionListPosition,
457+
reactionListType,
455458
ReactionListTop,
456459
} = useMessagesContext();
457460
const isAIGenerated = useMemo(
@@ -486,6 +489,7 @@ export const MessageSimple = forwardRef<View, MessageSimpleProps>((props, ref) =
486489
otherAttachments,
487490
ReactionListBottom,
488491
reactionListPosition,
492+
reactionListType,
489493
ReactionListTop,
490494
setQuotedMessage,
491495
shouldRenderSwipeableWrapper,

0 commit comments

Comments
 (0)