@@ -26,17 +26,48 @@ import TextWithTooltip from "../elements/TextWithTooltip";
2626import { useRoomMembers } from "../../../hooks/useRoomMembers" ;
2727import MatrixClientContext from "../../../contexts/MatrixClientContext" ;
2828
29+ interface IProps extends HTMLAttributes < HTMLSpanElement > {
30+ faces : ReactNode [ ] ;
31+ overflow : boolean ;
32+ tooltip ?: ReactNode ;
33+ children ?: ReactNode ;
34+ }
35+
36+ const FacePile = ( { faces, overflow, tooltip, children, ...props } : IProps ) => {
37+ const pileContents = < >
38+ { overflow ? < span className = "mx_FacePile_more" /> : null }
39+ { faces }
40+ </ > ;
41+
42+ return < div { ...props } className = "mx_FacePile" >
43+ { tooltip ? (
44+ < TextWithTooltip class = "mx_FacePile_faces" tooltip = { tooltip } tooltipProps = { { yOffset : 32 } } >
45+ { pileContents }
46+ </ TextWithTooltip >
47+ ) : (
48+ < div className = "mx_FacePile_faces" >
49+ { pileContents }
50+ </ div >
51+ ) }
52+ { children }
53+ </ div > ;
54+ } ;
55+
56+ export default FacePile ;
57+
2958const DEFAULT_NUM_FACES = 5 ;
3059
31- interface IProps extends HTMLAttributes < HTMLSpanElement > {
60+ const isKnownMember = ( member : RoomMember ) => ! ! DMRoomMap . shared ( ) . getDMRoomsForUserId ( member . userId ) ?. length ;
61+
62+ interface IRoomProps extends HTMLAttributes < HTMLSpanElement > {
3263 room : Room ;
3364 onlyKnownUsers ?: boolean ;
3465 numShown ?: number ;
3566}
3667
37- const isKnownMember = ( member : RoomMember ) => ! ! DMRoomMap . shared ( ) . getDMRoomsForUserId ( member . userId ) ?. length ;
38-
39- const FacePile = ( { room , onlyKnownUsers = true , numShown = DEFAULT_NUM_FACES , ... props } : IProps ) => {
68+ export const RoomFacePile = (
69+ { room , onlyKnownUsers = true , numShown = DEFAULT_NUM_FACES , ... props } : IRoomProps ,
70+ ) => {
4071 const cli = useContext ( MatrixClientContext ) ;
4172 const isJoined = room . getMyMembership ( ) === "join" ;
4273 let members = useRoomMembers ( room ) ;
@@ -58,6 +89,8 @@ const FacePile = ({ room, onlyKnownUsers = true, numShown = DEFAULT_NUM_FACES, .
5889 // We reverse the order of the shown faces in CSS to simplify their visual overlap,
5990 // reverse members in tooltip order to make the order between the two match up.
6091 const commaSeparatedMembers = shownMembers . map ( m => m . rawDisplayName ) . reverse ( ) . join ( ", " ) ;
92+ const faces = shownMembers . map ( m =>
93+ < MemberAvatar key = { m . userId } member = { m } width = { 28 } height = { 28 } /> ) ;
6194
6295 let tooltip : ReactNode ;
6396 if ( props . onClick ) {
@@ -90,16 +123,9 @@ const FacePile = ({ room, onlyKnownUsers = true, numShown = DEFAULT_NUM_FACES, .
90123 }
91124 }
92125
93- return < div { ...props } className = "mx_FacePile" >
94- < TextWithTooltip class = "mx_FacePile_faces" tooltip = { tooltip } tooltipProps = { { yOffset : 32 } } >
95- { members . length > numShown ? < span className = "mx_FacePile_face mx_FacePile_more" /> : null }
96- { shownMembers . map ( m =>
97- < MemberAvatar key = { m . userId } member = { m } width = { 28 } height = { 28 } className = "mx_FacePile_face" /> ) }
98- </ TextWithTooltip >
126+ return < FacePile faces = { faces } overflow = { members . length > numShown } tooltip = { tooltip } >
99127 { onlyKnownUsers && < span className = "mx_FacePile_summary" >
100128 { _t ( "%(count)s people you know have already joined" , { count : members . length } ) }
101129 </ span > }
102- </ div > ;
130+ </ FacePile > ;
103131} ;
104-
105- export default FacePile ;
0 commit comments