Skip to content

Commit 88ed5e3

Browse files
authored
fix: customize channel avatar size using theme (#2874)
1 parent a596287 commit 88ed5e3

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

package/src/components/ChannelPreview/ChannelAvatar.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useChannelPreviewDisplayAvatar } from './hooks/useChannelPreviewDisplay
55
import { useChannelPreviewDisplayPresence } from './hooks/useChannelPreviewDisplayPresence';
66

77
import { ChatContextValue, useChatContext } from '../../contexts/chatContext/ChatContext';
8+
import { useTheme } from '../../contexts/themeContext/ThemeContext';
89
import type { DefaultStreamChatGenerics } from '../../types/types';
910
import { Avatar } from '../Avatar/Avatar';
1011
import { GroupAvatar } from '../Avatar/GroupAvatar';
@@ -22,6 +23,13 @@ export const ChannelAvatarWithContext = <
2223
props: ChannelAvatarProps<StreamChatGenerics> & Pick<ChatContextValue, 'ImageComponent'>,
2324
) => {
2425
const { channel, ImageComponent } = props;
26+
const {
27+
theme: {
28+
channelPreview: {
29+
avatar: { size },
30+
},
31+
},
32+
} = useTheme();
2533

2634
const displayAvatar = useChannelPreviewDisplayAvatar(channel);
2735
const displayPresence = useChannelPreviewDisplayPresence(channel);
@@ -32,7 +40,7 @@ export const ChannelAvatarWithContext = <
3240
ImageComponent={ImageComponent}
3341
images={displayAvatar.images}
3442
names={displayAvatar.names}
35-
size={40}
43+
size={size}
3644
/>
3745
);
3846
}
@@ -43,7 +51,7 @@ export const ChannelAvatarWithContext = <
4351
ImageComponent={ImageComponent}
4452
name={displayAvatar.name}
4553
online={displayPresence}
46-
size={40}
54+
size={size}
4755
/>
4856
);
4957
};

package/src/contexts/themeContext/utils/theme.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ export type Theme = {
160160
maskFillColor?: ColorValue;
161161
};
162162
channelPreview: {
163+
avatar: {
164+
size: number;
165+
};
163166
checkAllIcon: IconProps;
164167
checkIcon: IconProps;
165168
container: ViewStyle;
@@ -914,6 +917,9 @@ export const defaultTheme: Theme = {
914917
height: 64,
915918
},
916919
channelPreview: {
920+
avatar: {
921+
size: 40,
922+
},
917923
checkAllIcon: {
918924
height: DEFAULT_STATUS_ICON_SIZE,
919925
width: DEFAULT_STATUS_ICON_SIZE,

0 commit comments

Comments
 (0)