@@ -3,28 +3,37 @@ import React, { useContext } from 'react';
33import { LocalizationContext } from '../../../../lib/LocalizationContext' ;
44import useSendbirdStateContext from '../../../../hooks/useSendbirdStateContext' ;
55import Label , { LabelTypography , LabelColors } from '../../../../ui/Label' ;
6- import IconButton from '../../../../ui/IconButton' ;
76
87import './index.scss' ;
98import Avatar from '../../../../ui/Avatar' ;
109
1110interface ChannelListHeaderInterface {
1211 renderHeader ?: ( props : void ) => React . ReactElement ;
12+ renderTitle ?: ( ) => React . ReactElement ;
1313 renderIconButton ?: ( props : void ) => React . ReactElement ;
1414 onEdit ?: ( props : void ) => void ;
1515 allowProfileEdit ?: boolean ;
1616}
1717
18- const ChannelListHeader : React . FC < ChannelListHeaderInterface > = ( {
18+ const ChannelListHeader : React . FC < ChannelListHeaderInterface > = ( {
1919 renderHeader,
20+ renderTitle,
2021 renderIconButton,
2122 onEdit,
2223 allowProfileEdit,
2324} : ChannelListHeaderInterface ) => {
24- const sbState = useSendbirdStateContext ( ) ;
25- const { user } = sbState ?. stores ?. userStore ;
25+ const { stores, config } = useSendbirdStateContext ?.( ) ;
26+ const { user } = stores ?. userStore ;
27+ const { logger } = config ;
2628
2729 const { stringSet } = useContext ( LocalizationContext ) ;
30+
31+ if ( renderHeader ) {
32+ logger ?. warning ( 'Recomend to use "renderTitle" instead of "renderHeader". It will be deprecated.' ) ;
33+ }
34+ // renderTitle should have higher priority
35+ const titleRenderer = renderHeader || renderTitle ;
36+
2837 return (
2938 < div
3039 className = { [
@@ -33,45 +42,43 @@ const ChannelListHeader : React.FC<ChannelListHeaderInterface> = ({
3342 ] . join ( ' ' ) }
3443 >
3544 {
36- renderHeader
37- ? renderHeader ( )
38- : (
39- < div
40- className = "sendbird-channel-header__title"
41- role = "button"
42- onClick = { ( ) => { onEdit ( ) } }
43- onKeyDown = { ( ) => { onEdit ( ) } }
44- tabIndex = { 0 }
45- >
46- < div className = "sendbird-channel-header__title__left" >
47- < Avatar
48- width = "32px"
49- height = "32px"
50- src = { user . profileUrl }
51- alt = { user . nickname }
52- />
53- </ div >
54- < div className = "sendbird-channel-header__title__right" >
55- < Label
56- className = "sendbird-channel-header__title__right__name"
57- type = { LabelTypography . SUBTITLE_2 }
58- color = { LabelColors . ONBACKGROUND_1 }
59- >
60- { user . nickname || stringSet . NO_NAME }
61- </ Label >
62- < Label
63- className = "sendbird-channel-header__title__right__user-id"
64- type = { LabelTypography . BODY_2 }
65- color = { LabelColors . ONBACKGROUND_2 }
66- >
67- { user . userId }
68- </ Label >
69- </ div >
45+ titleRenderer ?.( ) || (
46+ < div
47+ className = "sendbird-channel-header__title"
48+ role = "button"
49+ onClick = { ( ) => { onEdit ?.( ) } }
50+ onKeyDown = { ( ) => { onEdit ?.( ) } }
51+ tabIndex = { 0 }
52+ >
53+ < div className = "sendbird-channel-header__title__left" >
54+ < Avatar
55+ width = "32px"
56+ height = "32px"
57+ src = { user . profileUrl }
58+ alt = { user . nickname }
59+ />
60+ </ div >
61+ < div className = "sendbird-channel-header__title__right" >
62+ < Label
63+ className = "sendbird-channel-header__title__right__name"
64+ type = { LabelTypography . SUBTITLE_2 }
65+ color = { LabelColors . ONBACKGROUND_1 }
66+ >
67+ { user . nickname || stringSet . NO_NAME }
68+ </ Label >
69+ < Label
70+ className = "sendbird-channel-header__title__right__user-id"
71+ type = { LabelTypography . BODY_2 }
72+ color = { LabelColors . ONBACKGROUND_2 }
73+ >
74+ { user . userId }
75+ </ Label >
7076 </ div >
71- )
77+ </ div >
78+ )
7279 }
7380 < div className = "sendbird-channel-header__right-icon" >
74- { renderIconButton ( ) || < IconButton /> }
81+ { renderIconButton ?. ( ) }
7582 </ div >
7683 </ div >
7784 ) ;
0 commit comments