Skip to content

Commit d477072

Browse files
fix: add theme to ChatView component (#2494)
### 🎯 Goal `ChatView` component wraps whole `Chat` inner component tree but components rendered outside `Channel` component tree can only access default theme variables as `theme` property is only applied to the element `Channel` component renders. To make theming work for thread-related components too, the `theme` is also applied to the element `ChatView` renders.
1 parent b1718a7 commit d477072

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/components/ChatView/ChatView.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useChatContext } from '../../context';
77

88
import type { PropsWithChildren } from 'react';
99
import type { Thread, ThreadManagerState } from 'stream-chat';
10+
import clsx from 'clsx';
1011

1112
const availableChatViews = ['channels', 'threads'] as const;
1213

@@ -25,11 +26,13 @@ export const ChatView = ({ children }: PropsWithChildren) => {
2526
'channels',
2627
);
2728

29+
const { theme } = useChatContext();
30+
2831
const value = useMemo(() => ({ activeChatView, setActiveChatView }), [activeChatView]);
2932

3033
return (
3134
<ChatViewContext.Provider value={value}>
32-
<div className='str-chat str-chat__chat-view'>{children}</div>
35+
<div className={clsx('str-chat', theme, 'str-chat__chat-view')}>{children}</div>
3336
</ChatViewContext.Provider>
3437
);
3538
};

0 commit comments

Comments
 (0)